| Index: lib/compiler/implementation/resolver.dart
|
| diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
|
| index 4b6a8f49fdbe5ed61d7e91227689569694408830..7207b165559a76b8199247111649b2590d98d002 100644
|
| --- a/lib/compiler/implementation/resolver.dart
|
| +++ b/lib/compiler/implementation/resolver.dart
|
| @@ -952,6 +952,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
| final Element enclosingElement;
|
| final TypeResolver typeResolver;
|
| bool inInstanceContext;
|
| + bool inCheckContext;
|
| Scope scope;
|
| ClassElement currentClass;
|
| bool typeRequired = false;
|
| @@ -966,12 +967,12 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
| // fields.
|
| inInstanceContext = (element.isInstanceMember() && !element.isField())
|
| || element.isGenerativeConstructor(),
|
| - this.currentClass = element.isMember() ?
|
| - element.getEnclosingClass() :
|
| - null,
|
| + this.currentClass = element.isMember() ? element.getEnclosingClass()
|
| + : null,
|
| this.statementScope = new StatementScope(),
|
| typeResolver = new TypeResolver(compiler),
|
| scope = element.buildEnclosingScope(),
|
| + inCheckContext = compiler.enableTypeAssertions,
|
| super(compiler) {
|
| }
|
|
|
| @@ -997,6 +998,14 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
| return element;
|
| }
|
|
|
| + doInCheckContext(action()) {
|
| + bool wasInCheckContext = inCheckContext;
|
| + inCheckContext = true;
|
| + var result = action();
|
| + inCheckContext = wasInCheckContext;
|
| + return result;
|
| + }
|
| +
|
| inStaticContext(action()) {
|
| bool wasInstanceContext = inInstanceContext;
|
| inInstanceContext = false;
|
| @@ -1037,7 +1046,12 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
|
|
| Element visitTypeAnnotation(TypeAnnotation node) {
|
| DartType type = resolveTypeAnnotation(node);
|
| - if (type !== null) return type.element;
|
| + if (type !== null) {
|
| + if (inCheckContext) {
|
| + compiler.enqueuer.resolution.registerIsCheck(type);
|
| + }
|
| + return type.element;
|
| + }
|
| return null;
|
| }
|
|
|
| @@ -1347,7 +1361,10 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
| String operatorString = node.selector.asOperator().source.stringValue;
|
| if (operatorString === 'is' || operatorString === 'as') {
|
| assert(node.arguments.tail.isEmpty());
|
| - resolveTypeTest(node.arguments.head);
|
| + DartType type = resolveTypeTest(node.arguments.head);
|
| + if (type != null) {
|
| + compiler.enqueuer.resolution.registerIsCheck(type);
|
| + }
|
| resolvedArguments = true;
|
| } else if (operatorString === '?') {
|
| Element parameter = mapping[node.receiver];
|
| @@ -1608,9 +1625,13 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
|
|
| DartType resolveTypeAnnotation(TypeAnnotation node) {
|
| Function report = typeRequired ? error : warning;
|
| - return typeResolver.resolveTypeAnnotation(node, inScope: scope,
|
| - onFailure: report,
|
| - whenResolved: useType);
|
| + DartType type = typeResolver.resolveTypeAnnotation(node, inScope: scope,
|
| + onFailure: report,
|
| + whenResolved: useType);
|
| + if (inCheckContext && type != null) {
|
| + compiler.enqueuer.resolution.registerIsCheck(type);
|
| + }
|
| + return type;
|
| }
|
|
|
| visitModifiers(Modifiers node) {
|
| @@ -1885,7 +1906,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
| }
|
|
|
| Scope blockScope = new BlockScope(scope);
|
| - visitIn(node.type, blockScope);
|
| + doInCheckContext(() => visitIn(node.type, blockScope));
|
| visitIn(node.formals, blockScope);
|
| visitIn(node.block, blockScope);
|
| }
|
|
|