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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/Resolver.java

Issue 10116032: Issue 2639. Resolve implicit super() constructor invocation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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: compiler/java/com/google/dart/compiler/resolver/Resolver.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/Resolver.java b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
index c32f7cd679f5babaf556b34167ba7f80fa33600c..6723886ed26823572aa2cc15210654a3d58ec17e 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -927,8 +927,17 @@ public class Resolver {
visit(x.getArguments());
String name = x.getName() == null ? "" : x.getName().getName();
InterfaceType supertype = ((ClassElement) currentHolder).getSupertype();
- ConstructorElement element = (supertype == null) ?
- null : Elements.lookupConstructor(supertype.getElement(), name);
+ ConstructorElement element;
+ if (supertype == null) {
+ element = null;
+ } else {
+ ClassElement classElement = supertype.getElement();
+ element = Elements.lookupConstructor(classElement, name);
+ if (element == null && "".equals(name) && x.getArguments().isEmpty()
+ && Elements.needsImplicitDefaultConstructor(classElement)) {
+ element = new SyntheticDefaultConstructorElement(null, classElement, typeProvider);
+ }
+ }
if (element == null) {
onError(x, ResolverErrorCode.CANNOT_RESOLVE_SUPER_CONSTRUCTOR, name);
}
@@ -1163,6 +1172,9 @@ public class Resolver {
}
case SUPER: {
+ if (x.getParent() instanceof DartInitializer) {
+ onError(x, ResolverErrorCode.SUPER_METHOD_INVOCATION_IN_CONSTRUCTOR_INITIALIZER);
+ }
// Must be a superclass' method or field.
ClassElement classElement = ((SuperElement) target).getClassElement();
InterfaceType type = classElement.getType();

Powered by Google App Engine
This is Rietveld 408576698