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

Unified Diff: pkg/analyzer/lib/src/generated/type_system.dart

Issue 2376213003: Instantiate parameterized types of type parameters with 'dynamic' type arguments. (Closed)
Patch Set: Add TypeSystem.instantiateToDynamic(type) and use it. Created 4 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/analyzer/lib/src/generated/type_system.dart
diff --git a/pkg/analyzer/lib/src/generated/type_system.dart b/pkg/analyzer/lib/src/generated/type_system.dart
index 5574aed89f2b09b3e9abf83af23f13bfb8b2f982..27a61642d23e6257d0d2875222263b4552c4564e 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -851,7 +851,7 @@ class StrongTypeSystemImpl extends TypeSystem {
if (identical(i1, i2)) {
return true;
}
-
+
// Guard recursive calls
_GuardedSubtypeChecker<InterfaceType> guardedInterfaceSubtype = _guard(
(DartType i1, DartType i2, Set<Element> visited) =>
@@ -1143,6 +1143,21 @@ abstract class TypeSystem {
DartType instantiateToBounds(DartType type);
/**
+ * Instantiate a parameterized type using `dynamic` for all generic
+ * parameters. Returns the type unchanged if there are no parameters.
+ */
+ DartType instantiateToDynamic(DartType type) {
+ List<DartType> typeFormals = typeFormalsAsTypes(type);
+ int count = typeFormals.length;
+ if (count > 0) {
+ List<DartType> typeArguments =
+ new List<DartType>.filled(count, DynamicTypeImpl.instance);
+ return instantiateType(type, typeArguments);
+ }
+ return type;
+ }
+
+ /**
* Given a [DartType] [type] and a list of types
* [typeArguments], instantiate the type formals with the
* provided actuals. If [type] is not a parameterized type,
@@ -1439,14 +1454,7 @@ class TypeSystemImpl extends TypeSystem {
* parameters. Returns the type unchanged if there are no parameters.
*/
DartType instantiateToBounds(DartType type) {
- List<DartType> typeFormals = typeFormalsAsTypes(type);
- int count = typeFormals.length;
- if (count > 0) {
- List<DartType> typeArguments =
- new List<DartType>.filled(count, DynamicTypeImpl.instance);
- return instantiateType(type, typeArguments);
- }
- return type;
+ return instantiateToDynamic(type);
}
@override

Powered by Google App Engine
This is Rietveld 408576698