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); |
} |
} |