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

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 comment. 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 0213cf35287fc6a6ecdbefc95fd337a3b32eb7e7..c70b5313add94d65b18df1c94e83954dfced258a 100644
--- a/lib/compiler/implementation/resolution/members.dart
+++ b/lib/compiler/implementation/resolution/members.dart
@@ -1481,6 +1481,13 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
Element resolveSend(Send node) {
ahe 2012/10/23 11:54:26 Karl, this is getting too horrible. Let's take a l
+ void withAdditionalCategories(int categories, void f()) {
+ var oldCategory = allowedCategory;
+ allowedCategory |= categories;
+ f();
+ allowedCategory = oldCategory;
+ }
+
Selector selector = resolveSelector(node);
if (node.receiver == null) {
@@ -1498,14 +1505,33 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
return compiler.assertMethod;
}
- return node.selector.accept(this);
+
+ Element result;
+ withAdditionalCategories(ElementCategory.CLASS, () {
+ result = node.selector.accept(this);
+ });
+ if (result != null && result.kind == ElementKind.CLASS) {
+ ClassElement classElement = result;
+ classElement.ensureResolved(compiler);
+ }
+ return result;
}
- var oldCategory = allowedCategory;
- allowedCategory |=
- ElementCategory.CLASS | ElementCategory.PREFIX | ElementCategory.SUPER;
- Element resolvedReceiver = visit(node.receiver);
- allowedCategory = oldCategory;
+ Element resolvedReceiver;
+ withAdditionalCategories(
+ ElementCategory.CLASS | ElementCategory.PREFIX | ElementCategory.SUPER,
+ () { resolvedReceiver = visit(node.receiver); });
+
+ 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'.
+ resolvedReceiver = null;
+ }
+ }
Element target;
SourceString name = node.selector.asIdentifier().source;
@@ -1560,6 +1586,10 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
error(node, MessageKind.NO_SUCH_LIBRARY_MEMBER, [prefix.name, name]);
}
}
+ if (target != null && target.kind == ElementKind.CLASS) {
+ ClassElement classElement = target;
+ classElement.ensureResolved(compiler);
+ }
return target;
}
« no previous file with comments | « lib/compiler/implementation/dart_backend/placeholder_collector.dart ('k') | lib/compiler/implementation/resolved_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698