Index: sdk/lib/_internal/compiler/implementation/typechecker.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/typechecker.dart b/sdk/lib/_internal/compiler/implementation/typechecker.dart |
index b192c23b444d7a8ec4862e84256633ca5fcf9365..f3a0dcbfabc50ac940ca173d06f83e43616f2165 100644 |
--- a/sdk/lib/_internal/compiler/implementation/typechecker.dart |
+++ b/sdk/lib/_internal/compiler/implementation/typechecker.dart |
@@ -87,6 +87,11 @@ abstract class DartType { |
bool operator ==(other); |
+ /** |
+ * Is [: true :] if this type has no explict type arguments. |
+ */ |
+ bool get isRaw => true; |
+ |
DartType asRaw() => this; |
} |
@@ -264,7 +269,7 @@ class MalformedType extends DartType { |
} |
class InterfaceType extends DartType { |
- final Element element; |
+ final ClassElement element; |
final Link<DartType> typeArguments; |
InterfaceType(this.element, |
@@ -300,7 +305,7 @@ class InterfaceType extends DartType { |
String toString() { |
StringBuffer sb = new StringBuffer(); |
sb.add(name.slowToString()); |
- if (!typeArguments.isEmpty) { |
+ if (!isRaw) { |
sb.add('<'); |
typeArguments.printOn(sb, ', '); |
sb.add('>'); |
@@ -325,10 +330,9 @@ class InterfaceType extends DartType { |
return typeArguments == other.typeArguments; |
} |
- InterfaceType asRaw() { |
- if (typeArguments.isEmpty) return this; |
- return new InterfaceType(element); |
- } |
+ bool get isRaw => typeArguments.isEmpty || identical(this, element.rawType); |
+ |
+ InterfaceType asRaw() => element.rawType; |
} |
class FunctionType extends DartType { |
@@ -445,7 +449,7 @@ class TypedefType extends DartType { |
String toString() { |
StringBuffer sb = new StringBuffer(); |
sb.add(name.slowToString()); |
- if (!typeArguments.isEmpty) { |
+ if (!isRaw) { |
sb.add('<'); |
typeArguments.printOn(sb, ', '); |
sb.add('>'); |
@@ -460,6 +464,10 @@ class TypedefType extends DartType { |
if (!identical(element, other.element)) return false; |
return typeArguments == other.typeArguments; |
} |
+ |
+ bool get isRaw => typeArguments.isEmpty || identical(this, element.rawType); |
+ |
+ TypedefType asRaw() => element.rawType; |
} |
/** |
@@ -477,7 +485,7 @@ class Types { |
final Compiler compiler; |
// TODO(karlklose): should we have a class Void? |
final VoidType voidType; |
- final InterfaceType dynamicType; |
+ final DynamicType dynamicType; |
Types(Compiler compiler, ClassElement dynamicElement) |
: this.with(compiler, dynamicElement, |
@@ -488,7 +496,7 @@ class Types { |
LibraryElement library) |
: voidType = new VoidType(new VoidElement(library)), |
dynamicType = new DynamicType(dynamicElement) { |
- dynamicElement.type = dynamicType; |
+ dynamicElement.rawType = dynamicElement.thisType = dynamicType; |
} |
/** Returns true if t is a subtype of s */ |
@@ -505,7 +513,9 @@ class Types { |
if (t is VoidType) { |
return false; |
- } else if (t is MalformedType) { |
+ } else if (t is MalformedType || s is MalformedType) { |
+ // TODO(johnniwinther): Malformed types should be treated as dynamic and |
+ // thus return true here. |
return false; |
} else if (t is InterfaceType) { |
if (s is !InterfaceType) return false; |