Chromium Code Reviews| Index: pkg/compiler/lib/src/dart_types.dart |
| diff --git a/pkg/compiler/lib/src/dart_types.dart b/pkg/compiler/lib/src/dart_types.dart |
| index 23e87a814d4d1ac216b31db233908b779508ec0c..16de555fbec67323499b6af799cc4aa325dd32c3 100644 |
| --- a/pkg/compiler/lib/src/dart_types.dart |
| +++ b/pkg/compiler/lib/src/dart_types.dart |
| @@ -12,7 +12,8 @@ import 'compiler.dart' show |
| import 'diagnostics/invariant.dart' show |
| invariant; |
| import 'diagnostics/spannable.dart' show |
| - CURRENT_ELEMENT_SPANNABLE; |
| + CURRENT_ELEMENT_SPANNABLE, |
| + NO_LOCATION_SPANNABLE; |
| import 'elements/modelx.dart' show |
| LibraryElementX, |
| TypeDeclarationElementX, |
| @@ -1663,6 +1664,35 @@ class Types implements DartTypes { |
| } |
| return const DynamicType(); |
| } |
| + |
|
Johnni Winther
2015/09/11 09:19:15
Extracted from typechecker.dart
|
| + /// Computes the unaliased type of the first non type variable bound of |
| + /// [type]. |
| + static DartType computeUnaliasedBound(Compiler compiler, DartType type) { |
| + DartType originalType = type; |
| + while (type.isTypeVariable) { |
| + TypeVariableType variable = type; |
| + type = variable.element.bound; |
| + if (type == originalType) { |
| + type = compiler.objectClass.rawType; |
| + } |
| + } |
| + if (type.isMalformed) { |
| + return const DynamicType(); |
| + } |
| + return type.unalias(compiler); |
| + } |
| + |
| + /// Computes the interface type of [type]. For type variable it is the |
|
sigurdm
2015/09/11 11:43:28
For *a* type variable
Johnni Winther
2015/09/11 12:31:22
Done.
|
| + /// interface type of the bound, for function types and typedefs it is the |
| + /// `Function` type. |
|
sigurdm
2015/09/11 11:43:28
To me it doesn't seem like type-variables are trea
Johnni Winther
2015/09/11 12:31:22
This wrong. The type is assumed not to be a type v
|
| + static InterfaceType computeInterfaceType(Compiler compiler, DartType type) { |
| + if (type.isFunctionType) { |
| + type = compiler.functionClass.rawType; |
|
sigurdm
2015/09/11 11:43:28
Wrong indentation
Johnni Winther
2015/09/11 12:31:22
Done.
|
| + } |
| + assert(invariant(NO_LOCATION_SPANNABLE, type.isInterfaceType, |
| + message: "unexpected type kind ${type.kind}.")); |
| + return type; |
| + } |
| } |
| /** |