Chromium Code Reviews| 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..6facbb71df6e959a4307942dfc33e1771e3b9ed8 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,7 @@ class Types { |
| if (t is VoidType) { |
| return false; |
| - } else if (t is MalformedType) { |
| + } else if (t is MalformedType || s is MalformedType) { |
| return false; |
|
karlklose
2012/11/28 12:28:50
Please add a TODO here.
Johnni Winther
2012/11/28 12:36:32
Done.
|
| } else if (t is InterfaceType) { |
| if (s is !InterfaceType) return false; |