Chromium Code Reviews| Index: lib/compiler/implementation/resolution/members.dart |
| diff --git a/lib/compiler/implementation/resolution/members.dart b/lib/compiler/implementation/resolution/members.dart |
| index f96bf11e786cad256e730dae6ca0b7deb1a6d68f..122e97062861b36a4e1f1aae282eca93c6bfea77 100644 |
| --- a/lib/compiler/implementation/resolution/members.dart |
| +++ b/lib/compiler/implementation/resolution/members.dart |
| @@ -1176,7 +1176,8 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
| ExpressionStatement currentExpressionStatement; |
| bool typeRequired = false; |
| StatementScope statementScope; |
| - int allowedCategory = ElementCategory.VARIABLE | ElementCategory.FUNCTION; |
| + int allowedCategory = ElementCategory.VARIABLE | ElementCategory.FUNCTION |
| + | ElementCategory.IMPLIES_TYPE; |
| ResolverVisitor(Compiler compiler, Element element, this.mapping) |
| : this.enclosingElement = element, |
| @@ -1506,15 +1507,37 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
| } |
| return compiler.assertMethod; |
| } |
| - return node.selector.accept(this); |
| + |
| + Element result = node.selector.accept(this); |
| + if (result != null) { |
| + if (result.kind == ElementKind.CLASS) { |
|
ahe
2012/11/01 13:55:27
I think this belongs in visitIdentifier.
karlklose
2012/11/01 14:34:20
Done.
|
| + ClassElement classElement = result; |
| + classElement.ensureResolved(compiler); |
| + } |
| + } |
| + return result; |
| } |
| var oldCategory = allowedCategory; |
| - allowedCategory |= |
| - ElementCategory.CLASS | ElementCategory.PREFIX | ElementCategory.SUPER; |
| + allowedCategory |= ElementCategory.PREFIX | ElementCategory.SUPER; |
| Element resolvedReceiver = visit(node.receiver); |
| allowedCategory = oldCategory; |
| + if (resolvedReceiver != null |
| + && resolvedReceiver.kind == ElementKind.CLASS) { |
| + ClassElement classElement = resolvedReceiver; |
| + classElement.ensureResolved(compiler); |
|
ahe
2012/11/01 13:55:27
Couldn't this code be merged with lines 1569-1571?
karlklose
2012/11/01 14:34:20
Done.
|
| + if (node.isOperator) { |
| + // When the resolved receiver is a class, we can have two cases: |
| + // 1) a static send: C.foo, or |
| + // 2) an operator send, where the receiver is a class literal: 'C + 1'. |
| + // The following code that looks up the selector on the resolved |
| + // receiver will treat the second as the invocation of a static operator |
| + // if the resolved receiver is not null. |
| + resolvedReceiver = null; |
| + } |
| + } |
| + |
| Element target; |
| SourceString name = node.selector.asIdentifier().source; |
| if (identical(name.stringValue, 'this')) { |
| @@ -1568,6 +1591,9 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
| return warnAndCreateErroneousElement( |
| node, name, MessageKind.NO_SUCH_LIBRARY_MEMBER, |
| [prefix.name, name]); |
| + } else if (target.kind == ElementKind.CLASS) { |
| + ClassElement classElement = target; |
| + classElement.ensureResolved(compiler); |
| } |
| } |
| return target; |
| @@ -1707,6 +1733,10 @@ class ResolverVisitor extends CommonResolverVisitor<Element> { |
| // with the same arguments. |
| Selector call = new Selector.callClosureFrom(selector); |
| world.registerDynamicInvocation(call.name, call); |
| + } else if (target.impliesType()) { |
| + // We call 'call()' on a Type instance returned from the reference to a |
| + // class or typedef literal. We do not need to register this call as a |
| + // dynamic invocation, because we statically know what the target is. |
| } else if (!selector.applies(target, compiler)) { |
| warnArgumentMismatch(node, target); |
| } |