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

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

Issue 10515012: Fix for issues 2380 and 2381 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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/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;
}

Powered by Google App Engine
This is Rietveld 408576698