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

Unified Diff: sdk/lib/_internal/compiler/implementation/dart_types.dart

Issue 12210142: Implement is-checks against type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 10 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: 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 b9bdbd73d903a7da25e4aeba8708a7654d02ec14..c79571b1a23723c948510527c839eeb8e7e82d00 100644
--- a/sdk/lib/_internal/compiler/implementation/dart_types.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart_types.dart
@@ -75,6 +75,7 @@ abstract class DartType {
*/
bool get isMalformed => false;
+ bool get containsTypeVariable => false;
/**
* Calls [f] with each [MalformedType] within this type.
*
@@ -126,6 +127,8 @@ class TypeVariableType extends DartType {
SourceString get name => element.name;
+ bool get containsTypeVariable => true;
+
DartType subst(Link<DartType> arguments, Link<DartType> parameters) {
if (parameters.isEmpty) {
assert(arguments.isEmpty);
@@ -299,6 +302,15 @@ abstract class GenericType extends DartType {
GenericType(Link<DartType> this.typeArguments, bool this.isMalformed);
+ bool get containsTypeVariable {
+ for (Link<DartType> arguments = typeArguments;
+ !arguments.isEmpty;
+ arguments = arguments.tail) {
+ if (arguments.head.containsTypeVariable) return true;
+ }
+ return false;
+ }
+
TypeDeclarationElement get element;
/// Creates a new instance of this type using the provided type arguments.

Powered by Google App Engine
This is Rietveld 408576698