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

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

Issue 10543089: Issue 3344. Support for 'U extends T' type variables (Closed) Base URL: https://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
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/type/Types.java
diff --git a/compiler/java/com/google/dart/compiler/type/Types.java b/compiler/java/com/google/dart/compiler/type/Types.java
index 83dfd691dab34e7ab91ba02de0aabe727d143eed..241bc48d1a19f0c0a1ea2218c8c412ecf77bd831 100644
--- a/compiler/java/com/google/dart/compiler/type/Types.java
+++ b/compiler/java/com/google/dart/compiler/type/Types.java
@@ -177,7 +177,25 @@ public class Types {
}
private boolean isSubtypeOfTypeVariable(Type t, TypeVariable sv) {
- return sv.equals(t);
+ // May be same type variable.
+ if (sv.equals(t)) {
+ return true;
+ }
+ // May be "T extends S".
+ if (t.getKind() == TypeKind.VARIABLE) {
+ TypeVariable tv = (TypeVariable) t;
+ Type tBound = tv.getTypeVariableElement().getBound();
+ if (tBound != null && tBound.getKind() == TypeKind.VARIABLE) {
+ // Prevent cycle.
+ if (tBound.equals(t)) {
+ return false;
+ }
+ // Check bound.
+ return isSubtype(tBound, sv);
+ }
+ }
+ // no
+ return false;
}
private boolean isSubtypeOfInterface(Type t, InterfaceType s) {
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698