Index: pkg/compiler/lib/src/resolution/members.dart |
diff --git a/pkg/compiler/lib/src/resolution/members.dart b/pkg/compiler/lib/src/resolution/members.dart |
index 24ea86acaaee2387d9165f6bf96055235f8f4d12..97d25d31e1f2af31c3c529724b0126b463f613fe 100644 |
--- a/pkg/compiler/lib/src/resolution/members.dart |
+++ b/pkg/compiler/lib/src/resolution/members.dart |
@@ -762,41 +762,49 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
/// [AccessSemantics] in case of an error, `null` otherwise. |
AccessSemantics checkSuperAccess(Send node) { |
if (!inInstanceContext) { |
- return new StaticAccess.invalid( |
- reportAndCreateErroneousElement( |
- node, 'super', |
- MessageKind.NO_SUPER_IN_STATIC, {}, |
- isError: true)); |
+ ErroneousElement error = reportAndCreateErroneousElement( |
+ node, 'super', |
+ MessageKind.NO_SUPER_IN_STATIC, {}, |
+ isError: true); |
+ registry.registerCompileTimeError(error); |
+ return new StaticAccess.invalid(error); |
} |
if (node.isConditional) { |
// `super?.foo` is not allowed. |
- return new StaticAccess.invalid( |
- reportAndCreateErroneousElement( |
- node, 'super', |
- MessageKind.INVALID_USE_OF_SUPER, {}, |
- isError: true)); |
+ ErroneousElement error = reportAndCreateErroneousElement( |
+ node, 'super', |
+ MessageKind.INVALID_USE_OF_SUPER, {}, |
+ isError: true); |
+ registry.registerCompileTimeError(error); |
+ return new StaticAccess.invalid(error); |
} |
if (currentClass.supertype == null) { |
// This is just to guard against internal errors, so no need |
// for a real error message. |
- return new StaticAccess.invalid( |
- reportAndCreateErroneousElement( |
- node, 'super', |
- MessageKind.GENERIC, |
- {'text': "Object has no superclass"}, |
- isError: true)); |
+ ErroneousElement error = reportAndCreateErroneousElement( |
+ node, 'super', |
+ MessageKind.GENERIC, |
+ {'text': "Object has no superclass"}, |
+ isError: true); |
+ registry.registerCompileTimeError(error); |
+ return new StaticAccess.invalid(error); |
} |
registry.registerSuperUse(node); |
return null; |
} |
- /// Check that access to `this` is currently allowed. |
- bool checkThisAccess(Send node) { |
+ /// Check that access to `this` is currently allowed. Returns an |
+ /// [AccessSemantics] in case of an error, `null` otherwise. |
+ AccessSemantics checkThisAccess(Send node) { |
if (!inInstanceContext) { |
- compiler.reportError(node, MessageKind.NO_THIS_AVAILABLE); |
- return false; |
+ ErroneousElement error = reportAndCreateErroneousElement( |
+ node, 'this', |
+ MessageKind.NO_THIS_AVAILABLE, const {}, |
+ isError: true); |
+ registry.registerCompileTimeError(error); |
+ return new StaticAccess.invalid(error); |
} |
- return true; |
+ return null; |
} |
/// Compute the [AccessSemantics] corresponding to a super access of [target]. |
@@ -1564,22 +1572,24 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
/// Handle access on `this`, like `this()` and `this` when it is parsed as a |
/// [Send] node. |
ResolutionResult handleThisAccess(Send node) { |
- AccessSemantics accessSemantics = const DynamicAccess.thisAccess(); |
if (node.isCall) { |
CallStructure callStructure = |
resolveArguments(node.argumentsNode).callStructure; |
Selector selector = callStructure.callSelector; |
// TODO(johnniwinther): Handle invalid this access as an |
// [AccessSemantics]. |
- if (checkThisAccess(node)) { |
+ AccessSemantics accessSemantics = checkThisAccess(node); |
+ if (accessSemantics == null) { |
+ accessSemantics = const DynamicAccess.thisAccess(); |
registry.registerDynamicInvocation( |
new UniverseSelector(selector, null)); |
- registry.registerSendStructure(node, |
- new InvokeStructure(accessSemantics, selector)); |
} |
+ registry.registerSendStructure(node, |
+ new InvokeStructure(accessSemantics, selector)); |
// TODO(23998): Remove this when all information goes through |
// the [SendStructure]. |
registry.setSelector(node, selector); |
+ return const NoneResult(); |
} else { |
// TODO(johnniwinther): Handle get of `this` when it is a [Send] node. |
internalError(node, "Unexpected node '$node'."); |
@@ -1938,6 +1948,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, |
{'typeVariableName': name}, |
isError: true); |
+ registry.registerCompileTimeError(error); |
semantics = new StaticAccess.invalid(error); |
// TODO(johnniwinther): Clean up registration of elements and selectors |
// for this case. |
@@ -1983,6 +1994,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, |
{'typeVariableName': name}, |
isError: true); |
+ registry.registerCompileTimeError(error); |
semantics = new StaticAccess.invalid(error); |
} else { |
ErroneousElement error; |
@@ -2273,6 +2285,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
MessageKind.PREFIX_AS_EXPRESSION, |
{'prefix': name}, |
isError: true); |
+ registry.registerCompileTimeError(error); |
return handleErroneousAccess( |
node, name, new StaticAccess.invalid(error)); |
} |
@@ -2394,6 +2407,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
name.text, |
MessageKind.THIS_PROPERTY, {}, |
isError: true); |
+ registry.registerCompileTimeError(error); |
AccessSemantics accessSemantics = new StaticAccess.invalid(error); |
return handleErroneousAccess(node, name, accessSemantics); |
} |
@@ -2409,12 +2423,14 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
} else if (node.isSuperCall) { |
return handleSuperPropertyAccess(node, name); |
} else if (node.receiver.isThis()) { |
- if (checkThisAccess(node)) { |
+ AccessSemantics semantics = checkThisAccess(node); |
+ if (semantics == null) { |
return handleThisPropertyAccess(node, name); |
+ } else { |
+ // TODO(johnniwinther): Handle invalid this access as an |
+ // [AccessSemantics]. |
+ return handleErroneousAccess(node, name, semantics); |
} |
- // TODO(johnniwinther): Handle invalid this access as an |
- // [AccessSemantics]. |
- return const NoneResult(); |
} |
ResolutionResult result = visitExpressionPrefix(node.receiver); |
if (result.kind == ResultKind.PREFIX) { |
@@ -2440,12 +2456,14 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
if (text == 'this') { |
return handleQualifiedThisAccess(node, name); |
} else if (node.receiver.isThis()) { |
- if (checkThisAccess(node)) { |
+ AccessSemantics semantics = checkThisAccess(node); |
+ if (semantics == null) { |
return handleThisPropertyUpdate(node, name, null); |
+ } else { |
+ // TODO(johnniwinther): Handle invalid this access as an |
+ // [AccessSemantics]. |
+ return handleUpdate(node, name, semantics); |
} |
- // TODO(johnniwinther): Handle invalid this access as an |
- // [AccessSemantics]. |
- return const NoneResult(); |
} |
ResolutionResult result = visitExpressionPrefix(node.receiver); |
if (result.kind == ResultKind.PREFIX) { |
@@ -2545,6 +2563,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> { |
isError: true); |
// TODO(johnniwinther): Support static instance access as an |
// [AccessSemantics]. |
+ registry.registerCompileTimeError(error); |
return new StaticAccess.invalid(error); |
} |