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

Unified Diff: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java

Issue 8948001: Updates dartc to recognize 'default' keyword on interface and updated factory method syntax (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Got rid of some problems. 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/type/TypeAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
index e8e541346ae429ebf37d89d6edc5a83f4cd17ffb..fd6e898bb8646018147b8d4dd3b8b256b103c144 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -724,7 +724,10 @@ public class TypeAnalyzer implements DartCompilationPhase {
}
}
if (node.getDefaultClass() != null) {
- validateTypeNode(node.getDefaultClass(), true);
+ // TODO(zundel) validate the factory type (and parameters) exactly match the default class,
+ // and that the type bounds are assignable to the interface type bounds.
+ // For now, we rely on the logic in the Resovler that has paired the
+ // typeargs between this interface and the default class.
}
visit(node.getMembers());
checkInterfaceConstructors(element);
@@ -771,7 +774,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
&& !interfaceTypes.equals(defaultTypes)) {
onError(
interfaceConstructor.getNode(),
- TypeErrorCode.FACTORY_CONSTRUCTOR_TYPES,
+ TypeErrorCode.DEFAULT_CONSTRUCTOR_TYPES,
Elements.getRawMethodName(interfaceConstructor),
interfaceClassName,
Joiner.on(",").join(interfaceTypes),
@@ -997,13 +1000,8 @@ public class TypeAnalyzer implements DartCompilationPhase {
@Override
public Type visitMethodDefinition(DartMethodDefinition node) {
MethodElement methodElement = node.getSymbol();
- FunctionType type = methodElement.getFunctionType();
if (methodElement.getModifiers().isFactory()) {
analyzeFactory(node.getName(), (ConstructorElement) methodElement);
- } else {
- if (!type.getTypeVariables().isEmpty()) {
- internalError(node, "generic methods are not supported");
- }
}
return typeAsVoid(node);
}
@@ -1022,16 +1020,8 @@ public class TypeAnalyzer implements DartCompilationPhase {
if (!ElementKind.of(e).equals(ElementKind.CLASS)) {
return null;
}
- ClassElement cls = (ClassElement) e;
- InterfaceType type = cls.getType();
List<DartTypeParameter> parameterNodes = node.getTypeParameters();
- List<? extends Type> arguments = type.getArguments();
- if (parameterNodes.size() == 0) {
- return null;
- }
- Analyzer.this.visit(parameterNodes);
- List<TypeVariable> typeVariables = methodElement.getFunctionType().getTypeVariables();
- validateBounds(parameterNodes, arguments, typeVariables, true);
+ assert (parameterNodes.size() == 0);
return null;
}
};
@@ -1069,14 +1059,19 @@ public class TypeAnalyzer implements DartCompilationPhase {
}
// Check type arguments.
FunctionType ftype = (FunctionType) constructorElement.getType();
+
if (ftype != null && TypeKind.of(type).equals(TypeKind.INTERFACE)) {
InterfaceType ifaceType = (InterfaceType) type;
- List<? extends Type> arguments = ifaceType.getArguments();
- ftype = (FunctionType) ftype.subst(arguments, ifaceType.getElement().getTypeParameters());
- List<TypeVariable> typeVariables = ftype.getTypeVariables();
- if (arguments.size() == typeVariables.size()) {
- ftype = (FunctionType) ftype.subst(arguments, typeVariables);
+
+ List<? extends Type> substParams;
+ if (ifaceType.getElement().isInterface()) {
+ // Type parameters are specified for the concrete class.
+ substParams = ((ClassElement)constructorElement.getEnclosingElement()).getType().getArguments();
+ } else {
+ substParams = ifaceType.getElement().getTypeParameters();
}
+ List<? extends Type> arguments = ifaceType.getArguments();
+ ftype = (FunctionType) ftype.subst(arguments, substParams);
checkInvocation(node, node, null, ftype);
}
}

Powered by Google App Engine
This is Rietveld 408576698