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

Unified Diff: compiler/java/com/google/dart/compiler/backend/js/Normalizer.java

Issue 8728001: Support for 'abstract' modifier for class and spec recommended warnings, issue 375 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge. Warning for factory constructor of abstract class. Created 9 years 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/backend/js/Normalizer.java
diff --git a/compiler/java/com/google/dart/compiler/backend/js/Normalizer.java b/compiler/java/com/google/dart/compiler/backend/js/Normalizer.java
index 36d35a4dabfe09b330650f36f52d021fa7fa980b..9eebb568483317bacd0a6e5d80b61377f973e6f3 100644
--- a/compiler/java/com/google/dart/compiler/backend/js/Normalizer.java
+++ b/compiler/java/com/google/dart/compiler/backend/js/Normalizer.java
@@ -61,10 +61,9 @@ import com.google.dart.compiler.resolver.EnclosingElement;
import com.google.dart.compiler.resolver.FieldElement;
import com.google.dart.compiler.resolver.LabelElement;
import com.google.dart.compiler.resolver.MethodElement;
+import com.google.dart.compiler.resolver.SyntheticDefaultConstructorElement;
import com.google.dart.compiler.resolver.VariableElement;
-import com.google.dart.compiler.type.FunctionType;
import com.google.dart.compiler.type.InterfaceType;
-import com.google.dart.compiler.type.Type;
import com.google.dart.compiler.type.Types;
import java.util.ArrayList;
@@ -591,123 +590,14 @@ public class Normalizer {
@Override
public DartNode visitClass(DartClass node) {
final ClassElement classElement = node.getSymbol();
+ // Ensure implicit default constructor with method.
if (Elements.needsImplicitDefaultConstructor(classElement)) {
DartMethodDefinition method = createImplicitDefaultConstructor(classElement);
-
// TODO - We should really normalize the class itself.
node.getMembers().add(method);
}
return super.visitClass(node);
}
-
- static class SyntheticDefaultConstructorElement implements ConstructorElement {
- private final DartMethodDefinition method;
- private final ClassElement enclosingClass;
-
- SyntheticDefaultConstructorElement(DartMethodDefinition method, ClassElement enclosingClass) {
- this.method = method;
- this.enclosingClass = enclosingClass;
- }
-
- @Override
- public String getOriginalSymbolName() {
- return getName();
- }
-
- @Override
- public DartNode getNode() {
- return method;
- }
-
- @Override
- public void setNode(DartLabel node) {
- }
-
- @Override
- public boolean isDynamic() {
- return false;
- }
-
- @Override
- public Type getType() {
- return null;
- }
-
- @Override
- public String getName() {
- return "";
- }
-
- @Override
- public Modifiers getModifiers() {
- return Modifiers.NONE;
- }
-
- @Override
- public ElementKind getKind() {
- return ElementKind.CONSTRUCTOR;
- }
-
- @Override
- public EnclosingElement getEnclosingElement() {
- return enclosingClass;
- }
-
- @Override
- public boolean isStatic() {
- return false;
- }
-
- @Override
- public boolean isConstructor() {
- return true;
- }
-
- @Override
- public ConstructorElement getDefaultConstructor() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setDefaultConstructor(ConstructorElement defaultConstructor) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Type getReturnType() {
- return null;
- }
-
- @Override
- public List<VariableElement> getParameters() {
- return Collections.emptyList();
- }
-
- @Override
- public FunctionType getFunctionType() {
- return null;
- }
-
- @Override
- public ClassElement getConstructorType() {
- return enclosingClass;
- }
-
- @Override
- public boolean isInterface() {
- return false;
- }
-
- @Override
- public Iterable<Element> getMembers() {
- return Collections.emptyList();
- }
-
- @Override
- public Element lookupLocalElement(String name) {
- return null;
- }
- }
private DartMethodDefinition createImplicitDefaultConstructor(final ClassElement classElement) {
assert (Elements.needsImplicitDefaultConstructor(classElement));
@@ -715,7 +605,7 @@ public class Normalizer {
new DartBlock(Collections.<DartStatement>emptyList()), null);
final DartMethodDefinition method =
DartMethodDefinition.create(new DartIdentifier(""), function, Modifiers.NONE, null, null);
- method.setSymbol(new SyntheticDefaultConstructorElement(method, classElement));
+ method.setSymbol(new SyntheticDefaultConstructorElement(method, classElement, null));
return method;
}
@@ -848,7 +738,7 @@ public class Normalizer {
DartSuperConstructorInvocation superInvocation = new DartSuperConstructorInvocation(
new DartIdentifier(""), Collections.<DartExpression>emptyList());
superInvocation.setSymbol(new SyntheticDefaultConstructorElement(null,
- classElement.getSupertype().getElement()));
+ classElement.getSupertype().getElement(), null));
nInit.add(new DartInitializer(null, superInvocation));
}
}

Powered by Google App Engine
This is Rietveld 408576698