Skip to content

Commit 5a8eee0

Browse files
bowenwang1996dcodeIO
authored andcommitted
Pick up backing classes of basic types in more locations (#686)
1 parent 726e45c commit 5a8eee0

File tree

6 files changed

+2704
-6
lines changed

6 files changed

+2704
-6
lines changed

NOTICE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ under the licensing terms detailed in LICENSE:
1414
* Nidin Vinayakan <[email protected]>
1515
* Aaron Turner <[email protected]>
1616
* Willem Wyndham <[email protected]>
17+
* Bowen Wang <[email protected]>
1718

1819
Portions of this software are derived from third-party works licensed under
1920
the following terms:

src/resolver.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -748,14 +748,22 @@ export class Resolver extends DiagnosticEmitter {
748748
return null;
749749
}
750750
let arrayType = indexedGet.signature.returnType;
751+
751752
// }
752-
if (!(target = arrayType.classReference)) {
753-
this.error(
754-
DiagnosticCode.Property_0_does_not_exist_on_type_1,
755-
propertyAccess.property.range, propertyName, arrayType.toString()
756-
);
757-
return null;
753+
let classReference = arrayType.classReference;
754+
if (!classReference) {
755+
let typeClasses = this.program.typeClasses;
756+
if (!arrayType.is(TypeFlags.REFERENCE) && typeClasses.has(arrayType.kind)) {
757+
classReference = typeClasses.get(arrayType.kind)!;
758+
} else {
759+
this.error(
760+
DiagnosticCode.Property_0_does_not_exist_on_type_1,
761+
propertyAccess.property.range, propertyName, arrayType.toString()
762+
);
763+
return null;
764+
}
758765
}
766+
target = classReference;
759767
}
760768
break;
761769
}
@@ -1333,6 +1341,7 @@ export class Resolver extends DiagnosticEmitter {
13331341
contextualType,
13341342
reportMode
13351343
);
1344+
13361345
if (!target) return null;
13371346
if (target.kind == ElementKind.FUNCTION_PROTOTYPE) {
13381347
// `unchecked(expr: *): *` is special
@@ -1365,6 +1374,11 @@ export class Resolver extends DiagnosticEmitter {
13651374
// reuse resolvedThisExpression (might be property access)
13661375
// reuse resolvedElementExpression (might be element access)
13671376
return functionTarget;
1377+
} else {
1378+
let typeClasses = this.program.typeClasses;
1379+
if (!returnType.is(TypeFlags.REFERENCE) && typeClasses.has(returnType.kind)) {
1380+
return typeClasses.get(returnType.kind);
1381+
}
13681382
}
13691383
}
13701384
if (reportMode == ReportMode.REPORT) {

tests/compiler/resolve-access.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"asc_flags": [
3+
"--runtime none"
4+
]
5+
}

0 commit comments

Comments
 (0)