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

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

Issue 1756673002: Instantiate interface types to bounds. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 491d3911fbc0f7e018a289b79cb339835d9db822..d106ca3c4ce804d3798e7d8bcd10456e15f53beb 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -11283,6 +11283,11 @@ class TypeResolverVisitor extends ScopedVisitor {
bool _strongMode;
/**
+ * Type type system in use for this resolver pass.
+ */
+ TypeSystem _typeSystem;
+
+ /**
* Initialize a newly created visitor to resolve the nodes in an AST node.
*
* [definingLibrary] is the element for the library containing the node being
@@ -11305,6 +11310,7 @@ class TypeResolverVisitor extends ScopedVisitor {
_dynamicType = typeProvider.dynamicType;
_undefinedType = typeProvider.undefinedType;
_strongMode = definingLibrary.context.analysisOptions.strongMode;
+ _typeSystem = TypeSystem.create(definingLibrary.context);
}
@override
@@ -11853,7 +11859,7 @@ class TypeResolverVisitor extends ScopedVisitor {
if (argumentList != null) {
NodeList<TypeName> arguments = argumentList.arguments;
int argumentCount = arguments.length;
- List<DartType> parameters = _getTypeParameters(type);
+ List<DartType> parameters = _typeSystem.typeFormalsAsTypes(type);
int parameterCount = parameters.length;
List<DartType> typeArguments = new List<DartType>(parameterCount);
if (argumentCount == parameterCount) {
@@ -11872,22 +11878,9 @@ class TypeResolverVisitor extends ScopedVisitor {
typeArguments[i] = _dynamicType;
}
}
- type = _instantiateType(type, typeArguments);
+ type = _typeSystem.instantiateType(type, typeArguments);
} else {
- //
- // Check for the case where there are no type arguments given for a
- // parameterized type.
- //
- List<DartType> parameters = _getTypeParameters(type);
- int parameterCount = parameters.length;
- if (parameterCount > 0) {
- DynamicTypeImpl dynamicType = DynamicTypeImpl.instance;
- List<DartType> arguments = new List<DartType>(parameterCount);
- for (int i = 0; i < parameterCount; i++) {
- arguments[i] = dynamicType;
- }
- type = _instantiateType(type, arguments);
- }
+ type = _typeSystem.instantiateToBounds(type);
}
typeName.staticType = type;
node.type = type;
@@ -12066,21 +12059,6 @@ class TypeResolverVisitor extends ScopedVisitor {
}
/**
- * Return the type arguments associated with the given type.
- *
- * @param type the type whole type arguments are to be returned
- * @return the type arguments associated with the given type
- */
- List<DartType> _getTypeParameters(DartType type) {
- if (type is InterfaceType) {
- return type.typeArguments;
- } else if (type is FunctionType) {
- return TypeParameterTypeImpl.getTypes(type.typeFormals);
- }
- return DartType.EMPTY_LIST;
- }
-
- /**
* Returns the simple identifier of the given (may be qualified) type name.
*
* @param typeName the (may be qualified) qualified type name
@@ -12128,21 +12106,6 @@ class TypeResolverVisitor extends ScopedVisitor {
}
}
- DartType _instantiateType(DartType type, List<DartType> typeArguments) {
- // TODO(jmesserly): this should use TypeSystem.instantiateToBounds,
- // from calling methods when they know they're just trying to fill in
- // "dynamic" for the case of missing type arguments.
-
- if (type is InterfaceTypeImpl) {
- return type.substitute4(typeArguments);
- } else if (type is FunctionTypeImpl) {
- return type.instantiate(typeArguments);
- } else {
- // TODO(brianwilkerson) Report this internal error.
- return type;
- }
- }
-
/**
* Checks if the given type name is used as the type in an as expression.
*
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698