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

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

Issue 11230007: Resolve redirecting factories. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Handle unresolved elements. 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
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/typechecker.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 baba22dab3a4100d960383a38a0637d4a47b57be..19a167587efeecb9cf4aee23c7ffb4370046bdee 100644
--- a/dart/lib/compiler/implementation/resolution/members.dart
+++ b/dart/lib/compiler/implementation/resolution/members.dart
@@ -1832,7 +1832,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
visitReturn(Return node) {
if (node.isRedirectingFactoryBody) {
- unimplemented(node, 'redirecting constructors');
+ return resolveRedirectingFactory(node);
}
visit(node.expression);
}
@@ -1908,6 +1908,10 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
return node.accept(new ConstructorResolver(compiler, this));
}
+ FunctionElement resolveRedirectingFactory(Return node) {
+ return node.accept(new ConstructorResolver(compiler, this));
+ }
+
DartType resolveTypeRequired(TypeAnnotation node) {
bool old = typeRequired;
typeRequired = true;
@@ -2875,18 +2879,27 @@ class ConstructorResolver extends CommonResolverVisitor<Element> {
inConstContext = node.isConst();
Node selector = node.send.selector;
Element e = visit(selector);
+ e = finishConstructorReference(e, node.send.selector);
+ resolver.mapping.setType(node, type);
Johnni Winther 2012/10/22 09:47:34 I don't like the implicit handling of [type]. Coul
+ return e;
+ }
+
+ FunctionElement finishConstructorReference(Element e, Node node) {
if (!Elements.isUnresolved(e) && identical(e.kind, ElementKind.CLASS)) {
ClassElement cls = e;
cls.ensureResolved(compiler);
if (cls.isInterface() && (cls.defaultClass == null)) {
- error(selector, MessageKind.CANNOT_INSTANTIATE_INTERFACE, [cls.name]);
+ error(node, MessageKind.CANNOT_INSTANTIATE_INTERFACE, [cls.name]);
}
- e = lookupConstructor(cls, selector, const SourceString(''));
+ e = lookupConstructor(cls, node, const SourceString(''));
}
if (type == null) {
- type = e.getEnclosingClass().computeType(compiler);
+ if (Elements.isUnresolved(e)) {
+ type = compiler.dynamicClass.computeType(compiler);
+ } else {
+ type = e.getEnclosingClass().computeType(compiler).asRaw();
Johnni Winther 2012/10/22 09:47:34 This is the right type!
+ }
}
- resolver.mapping.setType(node, type);
return e;
}
@@ -2944,6 +2957,16 @@ class ConstructorResolver extends CommonResolverVisitor<Element> {
}
return e;
}
+
+ /// Assumed to be called by [resolveRedirectingFactory].
+ Element visitReturn(Return node) {
+ Element e = visit(node.expression);
+ e = finishConstructorReference(e, node.expression);
+ resolver.mapping.setType(node, type);
+ // TODO(ahe): Remove this debug warning when this is fully implemented.
+ warning(node.expression, MessageKind.GENERIC, ['e = $e; type = $type']);
+ return e;
+ }
}
abstract class Scope {
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698