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

Unified Diff: pkg/compiler/lib/src/dart_types.dart

Issue 1338683002: Add related types check to analyze_dart2js_test (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Cleanup. Created 5 years, 3 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
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;
+ }
}
/**
« no previous file with comments | « no previous file | pkg/compiler/lib/src/diagnostics/messages.dart » ('j') | tests/compiler/dart2js/related_types.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698