| Index: lib/compiler/implementation/resolver.dart
|
| diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
|
| index d9fde2468d86e0429f93c1ff3365cc7208d162d2..743eb612c44d405e5c9dd8956ad7d2da7f7e405e 100644
|
| --- a/lib/compiler/implementation/resolver.dart
|
| +++ b/lib/compiler/implementation/resolver.dart
|
| @@ -945,6 +945,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
| final Element enclosingElement;
|
| final TypeResolver typeResolver;
|
| bool inInstanceContext;
|
| + bool inCheckContext;
|
| Scope scope;
|
| ClassElement currentClass;
|
| bool typeRequired = false;
|
| @@ -959,12 +960,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) {
|
| }
|
|
|
| @@ -990,6 +991,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;
|
| @@ -1030,7 +1039,12 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
|
|
| Element visitTypeAnnotation(TypeAnnotation node) {
|
| Type type = resolveTypeAnnotation(node);
|
| - if (type !== null) return type.element;
|
| + if (type !== null) {
|
| + if (inCheckContext) {
|
| + compiler.enqueuer.resolution.registerIsCheck(type);
|
| + }
|
| + return type.element;
|
| + }
|
| return null;
|
| }
|
|
|
| @@ -1336,7 +1350,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);
|
| + Type type = resolveTypeTest(node.arguments.head);
|
| + if (type != null) {
|
| + compiler.enqueuer.resolution.registerIsCheck(type);
|
| + }
|
| resolvedArguments = true;
|
| }
|
| }
|
| @@ -1595,9 +1612,13 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
|
|
| Type resolveTypeAnnotation(TypeAnnotation node) {
|
| Function report = typeRequired ? error : warning;
|
| - return typeResolver.resolveTypeAnnotation(node, inScope: scope,
|
| - onFailure: report,
|
| - whenResolved: useType);
|
| + Type type = typeResolver.resolveTypeAnnotation(node, inScope: scope,
|
| + onFailure: report,
|
| + whenResolved: useType);
|
| + if (compiler.enableTypeAssertions) {
|
| + compiler.enqueuer.resolution.registerIsCheck(type);
|
| + }
|
| + return type;
|
| }
|
|
|
| visitModifiers(Modifiers node) {
|
| @@ -1848,8 +1869,16 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
| error(extra, MessageKind.EXTRA_CATCH_DECLARATION);
|
| }
|
| }
|
| - visitIn(node.type, blockScope);
|
| - visitIn(node.formals, blockScope);
|
| + if (node.type != null) {
|
| + doInCheckContext(() => visitIn(node.type, blockScope));
|
| + visitIn(node.formals, blockScope);
|
| + } else {
|
| + // The type annotation for the exception type is on the first formal.
|
| + doInCheckContext(() => visitIn(node.formals.nodes.head, blockScope));
|
| + if (!node.formals.nodes.tail.isEmpty()) {
|
| + visitIn(node.formals.nodes.tail.head, blockScope);
|
| + }
|
| + }
|
| visitIn(node.block, blockScope);
|
| }
|
|
|
|
|