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

Unified Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 2640143007: Issue 28100. Implement new strong mode instantiate to bound rules in analyzer. (Closed)
Patch Set: Created 3 years, 11 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/summary/resynthesize.dart
diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart
index aca28526b5f2ac55bccfeb526becc1b1cdf60882..c4f6caa80ac4ce5a58d4058c88f9e58119a9366c 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -1297,7 +1297,7 @@ class _ReferenceInfo {
/**
* If this reference refers to a type, build a [DartType]. Otherwise return
* `null`. If [numTypeArguments] is the same as the [numTypeParameters],
- * the type in instantiated with type arguments returned by [getTypeArgument],
+ * the type is instantiated with type arguments returned by [getTypeArgument],
* otherwise it is instantiated with type parameter bounds (if strong mode),
* or with `dynamic` type arguments.
*
@@ -1324,22 +1324,14 @@ class _ReferenceInfo {
InterfaceTypeImpl type =
new InterfaceTypeImpl.elementWithNameAndArgs(element, name, () {
if (typeArguments == null) {
- typeArguments = element.typeParameters
- .map/*<DartType>*/((_) => DynamicTypeImpl.instance)
- .toList();
+ typeArguments = new List<DartType>.filled(
+ element.typeParameters.length, DynamicTypeImpl.instance);
if (libraryResynthesizer.summaryResynthesizer.strongMode &&
instantiateToBoundsAllowed) {
- List<DartType> typeParameterTypes;
- for (int i = 0; i < typeArguments.length; i++) {
- DartType bound = element.typeParameters[i].bound;
- if (bound != null) {
- typeParameterTypes ??= element.typeParameters
- .map/*<DartType>*/((TypeParameterElement e) => e.type)
- .toList();
- typeArguments[i] =
- bound.substitute2(typeArguments, typeParameterTypes);
- }
- }
+ InterfaceType instantiatedToBounds = libraryResynthesizer
+ .summaryResynthesizer.context.typeSystem
+ .instantiateToBounds(element.type) as InterfaceType;
+ return instantiatedToBounds.typeArguments;
}
}
return typeArguments;

Powered by Google App Engine
This is Rietveld 408576698