Skip to content

Add resolve-propertyaccess test #864

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

Merged
merged 3 commits into from
Sep 23, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ export class Resolver extends DiagnosticEmitter {
}
if (isTypedElement(kind)) {
let type = (<TypedElement>element).type;
assert(type != Type.void);
let classReference = type.classReference;
if (classReference) {
let wrappedType = classReference.wrappedType;
Expand Down Expand Up @@ -1142,14 +1143,13 @@ export class Resolver extends DiagnosticEmitter {
/** Resolves a lazily compiled global, i.e. a static class field or annotated `@lazy`. */
private ensureResolvedLazyGlobal(global: Global, reportMode: ReportMode = ReportMode.REPORT): bool {
if (global.is(CommonFlags.RESOLVED)) return true;
var type: Type | null;
var typeNode = global.typeNode;
if (!typeNode) return false;
var type = this.resolveType( // reports
typeNode,
global.parent,
null,
reportMode
);
if (typeNode) {
type = this.resolveType(typeNode, global.parent, null, reportMode);
} else {
type = this.resolveExpression(assert(global.initializerNode), global.file.startFunction.flow, Type.auto, reportMode);
}
if (!type) return false;
global.setType(type); // also sets resolved
return true;
Expand All @@ -1174,6 +1174,7 @@ export class Resolver extends DiagnosticEmitter {
// Resolve variable-likes to their class type first
switch (target.kind) {
case ElementKind.GLOBAL: if (!this.ensureResolvedLazyGlobal(<Global>target, reportMode)) return null;
case ElementKind.ENUMVALUE:
case ElementKind.LOCAL:
case ElementKind.FIELD: { // someVar.prop
let type = (<VariableLikeElement>target).type; assert(type != Type.void);
Expand Down
5 changes: 5 additions & 0 deletions tests/compiler/resolve-propertyaccess.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"asc_flags": [
"--runtime none"
]
}
Loading