Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Unified Diff: lib/compiler/implementation/resolution/members.dart

Issue 10942028: Support class and typedef literals as expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add a test for literals. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..4e943b5e9254937cb2d5e9e70ba7591dc30a7eed 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,33 @@ 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) {
+ 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);
+ if (node.isOperator) {
+ // In operator expressions like 'Class + 1', the operator call goes the
+ // instance of [Type] that is the result of the expression 'Class'.
ngeoffray 2012/10/31 10:33:03 The comment is not helping me understand what's ha
karlklose 2012/10/31 13:01:18 Rephrased. Is it better to understand now?
+ resolvedReceiver = null;
+ }
+ }
+
Element target;
SourceString name = node.selector.asIdentifier().source;
if (identical(name.stringValue, 'this')) {
@@ -1570,6 +1589,10 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
[prefix.name, name]);
}
}
+ if (target != null && target.kind == ElementKind.CLASS) {
ngeoffray 2012/10/31 10:33:03 Should that check be in the prefix check?
karlklose 2012/10/31 13:01:18 Where exactly do you mean this should be?
ngeoffray 2012/10/31 14:32:43 line 1590
karlklose 2012/10/31 16:32:17 Yes, makes sense.
+ ClassElement classElement = target;
+ classElement.ensureResolved(compiler);
+ }
return target;
}
@@ -1707,7 +1730,8 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
// with the same arguments.
Selector call = new Selector.callClosureFrom(selector);
world.registerDynamicInvocation(call.name, call);
- } else if (!selector.applies(target, compiler)) {
+ } else if (target is FunctionElement
ngeoffray 2012/10/31 10:33:03 target.isFunction() ? Or have selector.applies do
karlklose 2012/10/31 13:01:18 I added a case for targets that imply a type.
+ && !selector.applies(target, compiler)) {
warnArgumentMismatch(node, target);
}
}

Powered by Google App Engine
This is Rietveld 408576698