Index: compiler/java/com/google/dart/compiler/resolver/ResolveVisitor.java |
=================================================================== |
--- compiler/java/com/google/dart/compiler/resolver/ResolveVisitor.java (revision 8249) |
+++ compiler/java/com/google/dart/compiler/resolver/ResolveVisitor.java (working copy) |
@@ -12,12 +12,14 @@ |
import com.google.dart.compiler.ast.DartNode; |
import com.google.dart.compiler.ast.DartParameter; |
import com.google.dart.compiler.ast.DartTypeNode; |
+import com.google.dart.compiler.ast.DartTypeParameter; |
import com.google.dart.compiler.type.DynamicType; |
import com.google.dart.compiler.type.FunctionType; |
import com.google.dart.compiler.type.Type; |
import com.google.dart.compiler.type.Types; |
import java.util.ArrayList; |
+import java.util.HashSet; |
import java.util.List; |
/** |
@@ -50,10 +52,16 @@ |
} |
final FunctionAliasElement resolveFunctionAlias(DartFunctionTypeAlias node) { |
- FunctionAliasElement funcAlias = node.getElement(); |
- for (Type type : funcAlias.getTypeParameters()) { |
- TypeVariableElement typeVar = (TypeVariableElement) type.getElement(); |
- getContext().getScope().declareElement(typeVar.getName(), typeVar); |
+ HashSet<String> parameterNames = new HashSet<String>(); |
+ for (DartTypeParameter parameter : node.getTypeParameters()) { |
+ TypeVariableElement typeVar = (TypeVariableElement) parameter.getElement(); |
+ String parameterName = typeVar.getName(); |
+ if (parameterNames.contains(parameterName)) { |
+ getContext().onError(parameter, ResolverErrorCode.DUPLICATE_TYPE_VARIABLE, parameterName); |
+ } else { |
+ parameterNames.add(parameterName); |
+ } |
+ getContext().getScope().declareElement(parameterName, typeVar); |
} |
return null; |
} |