Chromium Code Reviews| Index: dart/lib/compiler/implementation/resolution/members.dart |
| diff --git a/dart/lib/compiler/implementation/resolution/members.dart b/dart/lib/compiler/implementation/resolution/members.dart |
| index d62146da0dd7cba79e9ca326d0d93ba794854a31..baba22dab3a4100d960383a38a0637d4a47b57be 100644 |
| --- a/dart/lib/compiler/implementation/resolution/members.dart |
| +++ b/dart/lib/compiler/implementation/resolution/members.dart |
| @@ -1905,31 +1905,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
| * [null], if there is no corresponding constructor, class or library. |
| */ |
| FunctionElement resolveConstructor(NewExpression node) { |
| - // Resolve the constructor that [node] refers to. |
| - ConstructorResolver visitor = |
| - new ConstructorResolver(compiler, this, node.isConst()); |
| - FunctionElement constructor = node.accept(visitor); |
| - // Try to resolve the type that the new-expression constructs. |
| - TypeAnnotation annotation = node.send.getTypeAnnotation(); |
| - if (Elements.isUnresolved(constructor)) { |
| - // Resolve the type arguments. We cannot create a type and check the |
| - // number of type arguments for this annotation, because we do not know |
| - // the element. |
| - Link arguments = const Link<Node>(); |
| - if (annotation.typeArguments != null) { |
| - arguments = annotation.typeArguments.nodes; |
| - } |
| - for (Node argument in arguments) { |
| - resolveTypeRequired(argument); |
| - } |
| - } else { |
| - // Resolve and store the type this annotation resolves to. The type |
| - // is used in the backend, e.g., for creating runtime type information. |
| - // TODO(karlklose): This will resolve the class element again. Refactor |
| - // so we can use the TypeResolver. |
| - resolveTypeRequired(annotation); |
| - } |
| - return constructor; |
| + return node.accept(new ConstructorResolver(compiler, this)); |
| } |
| DartType resolveTypeRequired(TypeAnnotation node) { |
| @@ -2840,13 +2816,10 @@ class SignatureResolver extends CommonResolverVisitor<Element> { |
| class ConstructorResolver extends CommonResolverVisitor<Element> { |
| final ResolverVisitor resolver; |
| - // TODO(ngeoffray): have this context at the call site. |
| - final bool inConstContext; |
| + bool inConstContext = false; |
| + DartType type; |
|
Johnni Winther
2012/10/22 09:41:38
Document the semantics and usage of [isConstContex
|
| - ConstructorResolver(Compiler compiler, |
| - this.resolver, |
| - this.inConstContext) |
| - : super(compiler); |
| + ConstructorResolver(Compiler compiler, this.resolver) : super(compiler); |
| visitNode(Node node) { |
| throw 'not supported'; |
| @@ -2899,6 +2872,7 @@ class ConstructorResolver extends CommonResolverVisitor<Element> { |
| } |
| visitNewExpression(NewExpression node) { |
| + inConstContext = node.isConst(); |
| Node selector = node.send.selector; |
| Element e = visit(selector); |
| if (!Elements.isUnresolved(e) && identical(e.kind, ElementKind.CLASS)) { |
| @@ -2909,11 +2883,17 @@ class ConstructorResolver extends CommonResolverVisitor<Element> { |
| } |
| e = lookupConstructor(cls, selector, const SourceString('')); |
| } |
| + if (type == null) { |
|
Johnni Winther
2012/10/22 09:30:31
Document where [type] has been set.
|
| + type = e.getEnclosingClass().computeType(compiler); |
|
Johnni Winther
2012/10/22 09:41:38
I don't think this is the right type. For 'new Obj
|
| + } |
| + resolver.mapping.setType(node, type); |
| return e; |
| } |
| visitTypeAnnotation(TypeAnnotation node) { |
| - return visit(node.typeName); |
| + assert(invariant(node, type == null)); |
| + type = resolver.resolveTypeRequired(node); |
| + return resolver.mapping[node]; |
| } |
| visitSend(Send node) { |