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

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

Issue 9049016: in dartc, generics in Typedef not working as expected, when extending generic type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged up to r3100 Created 8 years, 11 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/SupertypeResolver.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/SupertypeResolver.java b/compiler/java/com/google/dart/compiler/resolver/SupertypeResolver.java
index 0037be543d17bfefc94822b13fd52d9c382bc4a6..8ca5d484533e0f7ca4d80f6789b5a5e0bfd1f9cd 100644
--- a/compiler/java/com/google/dart/compiler/resolver/SupertypeResolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/SupertypeResolver.java
@@ -14,6 +14,8 @@ import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.type.InterfaceType;
import com.google.dart.compiler.type.Type;
+import java.util.List;
+
/**
* Resolves the super class, interfaces, default implementation and
* bounds type parameters of classes in a DartUnit.
@@ -79,33 +81,38 @@ public class SupertypeResolver {
Elements.addInterface(classElement, classContext.resolveInterface(cls, false, false));
}
}
-
- for (Type typeParameter : classElement.getTypeParameters()) {
- TypeVariableElement variable = (TypeVariableElement) typeParameter.getElement();
- DartTypeParameter typeParameterNode = (DartTypeParameter) variable.getNode();
- DartTypeNode boundNode = typeParameterNode.getBound();
- Type bound;
- if (boundNode != null) {
- bound =
- classContext.resolveType(
- boundNode,
- false,
- false,
- ResolverErrorCode.NO_SUCH_TYPE);
- boundNode.setType(bound);
- } else {
- bound = typeProvider.getObjectType();
- }
- variable.setBound(bound);
- }
-
+ setBoundsOnTypeParameters(classElement.getTypeParameters(), classContext);
return null;
}
@Override
public Void visitFunctionTypeAlias(DartFunctionTypeAlias node) {
+ ResolutionContext resolutionContext = topLevelContext.extend(node.getSymbol());
Elements.addInterface(node.getSymbol(), typeProvider.getFunctionType());
+ setBoundsOnTypeParameters(node.getSymbol().getTypeParameters(), resolutionContext);
return null;
}
}
+
+ private void setBoundsOnTypeParameters(List<? extends Type> typeParameters,
+ ResolutionContext resolutionContext) {
+ for (Type typeParameter : typeParameters) {
+ TypeVariableElement variable = (TypeVariableElement) typeParameter.getElement();
+ DartTypeParameter typeParameterNode = (DartTypeParameter) variable.getNode();
+ DartTypeNode boundNode = typeParameterNode.getBound();
+ Type bound;
+ if (boundNode != null) {
+ bound =
+ resolutionContext.resolveType(
+ boundNode,
+ false,
+ false,
+ ResolverErrorCode.NO_SUCH_TYPE);
+ boundNode.setType(bound);
+ } else {
+ bound = typeProvider.getObjectType();
+ }
+ variable.setBound(bound);
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698