Index: sdk/lib/_internal/compiler/implementation/dart_types.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/dart_types.dart b/sdk/lib/_internal/compiler/implementation/dart_types.dart |
index c134d831f13dabc1d3bed161d96e142763388bf8..7fc88b3f517b6481c0a8652781bd7505fd6eded3 100644 |
--- a/sdk/lib/_internal/compiler/implementation/dart_types.dart |
+++ b/sdk/lib/_internal/compiler/implementation/dart_types.dart |
@@ -1042,6 +1042,7 @@ class Types { |
final VoidType voidType; |
final DynamicType dynamicType; |
final SubtypeVisitor subtypeVisitor; |
+ final PotentialSubtypeVisitor potentialSubtypeVisitor; |
factory Types(Compiler compiler, ClassElement dynamicElement) { |
LibraryElement library = new LibraryElementX(new Script(null, null)); |
@@ -1050,11 +1051,15 @@ class Types { |
dynamicElement.rawType = dynamicElement.thisType = dynamicType; |
SubtypeVisitor subtypeVisitor = |
new SubtypeVisitor(compiler, dynamicType, voidType); |
- return new Types.internal(compiler, voidType, dynamicType, subtypeVisitor); |
+ PotentialSubtypeVisitor potentialSubtypeVisitor = |
+ new PotentialSubtypeVisitor(compiler, dynamicType, voidType); |
+ |
+ return new Types.internal(compiler, voidType, dynamicType, |
+ subtypeVisitor, potentialSubtypeVisitor); |
} |
Types.internal(this.compiler, this.voidType, this.dynamicType, |
- this.subtypeVisitor); |
+ this.subtypeVisitor, this.potentialSubtypeVisitor); |
/** Returns true if t is a subtype of s */ |
bool isSubtype(DartType t, DartType s) { |
@@ -1065,6 +1070,11 @@ class Types { |
return subtypeVisitor.isAssignable(r, s); |
} |
+ bool isPotentialSubtype(DartType t, DartType s) { |
+ // TODO(johnniwinther): Return a set of variable points in the positive |
+ // cases. |
+ return potentialSubtypeVisitor.isSubtype(t, s); |
+ } |
/** |
* Helper method for performing substitution of a linked list of types. |
@@ -1119,3 +1129,18 @@ class Types { |
return typeVariable.element.enclosingElement; |
} |
} |
+ |
+class PotentialSubtypeVisitor extends SubtypeVisitor { |
+ PotentialSubtypeVisitor(Compiler compiler, |
+ DynamicType dynamicType, |
+ VoidType voidType) |
+ : super(compiler, dynamicType, voidType); |
+ |
+ |
+ bool isSubtype(DartType t, DartType s) { |
+ if (t is TypeVariableType || s is TypeVariableType) { |
+ return true; |
+ } |
+ return super.isSubtype(t, s); |
+ } |
+} |