Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some resolver bugs #686

Merged
merged 4 commits into from Jun 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions NOTICE
Expand Up @@ -14,6 +14,7 @@ under the licensing terms detailed in LICENSE:
* Nidin Vinayakan <01@01alchemist.com>
* Aaron Turner <aaron@aaronthedev.com>
* Willem Wyndham <willem@cs.umd.edu>
* Bowen Wang <bowen@nearprotocol.com>

Portions of this software are derived from third-party works licensed under
the following terms:
Expand Down
26 changes: 20 additions & 6 deletions src/resolver.ts
Expand Up @@ -748,14 +748,22 @@ export class Resolver extends DiagnosticEmitter {
return null;
}
let arrayType = indexedGet.signature.returnType;

// }
if (!(target = arrayType.classReference)) {
this.error(
DiagnosticCode.Property_0_does_not_exist_on_type_1,
propertyAccess.property.range, propertyName, arrayType.toString()
);
return null;
let classReference = arrayType.classReference;
if (!classReference) {
let typeClasses = this.program.typeClasses;
if (!arrayType.is(TypeFlags.REFERENCE) && typeClasses.has(arrayType.kind)) {
classReference = typeClasses.get(arrayType.kind)!;
} else {
this.error(
DiagnosticCode.Property_0_does_not_exist_on_type_1,
propertyAccess.property.range, propertyName, arrayType.toString()
);
return null;
}
}
target = classReference;
}
break;
}
Expand Down Expand Up @@ -1333,6 +1341,7 @@ export class Resolver extends DiagnosticEmitter {
contextualType,
reportMode
);

if (!target) return null;
if (target.kind == ElementKind.FUNCTION_PROTOTYPE) {
// `unchecked(expr: *): *` is special
Expand Down Expand Up @@ -1365,6 +1374,11 @@ export class Resolver extends DiagnosticEmitter {
// reuse resolvedThisExpression (might be property access)
// reuse resolvedElementExpression (might be element access)
return functionTarget;
} else {
let typeClasses = this.program.typeClasses;
if (!returnType.is(TypeFlags.REFERENCE) && typeClasses.has(returnType.kind)) {
return typeClasses.get(returnType.kind);
}
}
}
if (reportMode == ReportMode.REPORT) {
Expand Down
5 changes: 5 additions & 0 deletions tests/compiler/resolve-access.json
@@ -0,0 +1,5 @@
{
"asc_flags": [
"--runtime none"
]
}