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

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

Issue 2688223002: If no valid type arguments, instantate function type alias to bounds in resynthesizer. (Closed)
Patch Set: clean up Created 3 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/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 65f879313c6966ecb0e545ce03dfee2dc5aed09f..68c3017d5437bd1e923554e92c047b9a56d0cd5d 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -1289,22 +1289,20 @@ class _ReferenceInfo {
if (numTypeParameters == 0) {
return element.type;
} else if (numTypeArguments == numTypeParameters) {
- typeArguments = new List<DartType>(numTypeParameters);
- for (int i = 0; i < numTypeParameters; i++) {
- typeArguments[i] = getTypeArgument(i);
- }
+ typeArguments = _buildTypeArguments(numTypeArguments, getTypeArgument);
}
InterfaceTypeImpl type =
new InterfaceTypeImpl.elementWithNameAndArgs(element, name, () {
if (typeArguments == null) {
- typeArguments = new List<DartType>.filled(
- element.typeParameters.length, DynamicTypeImpl.instance);
if (libraryResynthesizer.summaryResynthesizer.strongMode &&
instantiateToBoundsAllowed) {
InterfaceType instantiatedToBounds = libraryResynthesizer
.summaryResynthesizer.context.typeSystem
.instantiateToBounds(element.type) as InterfaceType;
return instantiatedToBounds.typeArguments;
+ } else {
+ return new List<DartType>.filled(
+ numTypeParameters, DynamicTypeImpl.instance);
}
}
return typeArguments;
@@ -1317,33 +1315,45 @@ class _ReferenceInfo {
// Done.
return type;
} else if (element is FunctionTypedElement) {
- int numTypeArguments;
- FunctionTypedElementComputer computer;
- if (implicitFunctionTypeIndices.isNotEmpty) {
- numTypeArguments = numTypeParameters;
- computer = () {
- FunctionTypedElement element = this.element;
- for (int index in implicitFunctionTypeIndices) {
- element = element.parameters[index].type.element;
- }
- return element;
- };
- } else if (element is FunctionTypeAliasElementHandle) {
+ if (element is FunctionTypeAliasElementHandle) {
+ List<DartType> typeArguments;
+ if (numTypeArguments == numTypeParameters) {
+ typeArguments =
+ _buildTypeArguments(numTypeArguments, getTypeArgument);
+ } else if (libraryResynthesizer.summaryResynthesizer.strongMode &&
+ instantiateToBoundsAllowed) {
+ FunctionType instantiatedToBounds = libraryResynthesizer
+ .summaryResynthesizer.context.typeSystem
+ .instantiateToBounds(element.type) as FunctionType;
+ typeArguments = instantiatedToBounds.typeArguments;
+ } else {
+ typeArguments = new List<DartType>.filled(
+ numTypeParameters, DynamicTypeImpl.instance);
+ }
return new FunctionTypeImpl.elementWithNameAndArgs(
- element,
- name,
- _buildTypeArguments(numTypeParameters, getTypeArgument),
- numTypeParameters != 0);
+ element, name, typeArguments, numTypeParameters != 0);
} else {
- // For a type that refers to a generic executable, the type arguments are
- // not supposed to include the arguments to the executable itself.
- numTypeArguments = enclosing == null ? 0 : enclosing.numTypeParameters;
- computer = () => this.element as FunctionTypedElement;
+ FunctionTypedElementComputer computer;
+ if (implicitFunctionTypeIndices.isNotEmpty) {
+ numTypeArguments = numTypeParameters;
+ computer = () {
+ FunctionTypedElement element = this.element;
+ for (int index in implicitFunctionTypeIndices) {
+ element = element.parameters[index].type.element;
+ }
+ return element;
+ };
+ } else {
+ // For a type that refers to a generic executable, the type arguments are
+ // not supposed to include the arguments to the executable itself.
+ numTypeArguments = enclosing?.numTypeParameters ?? 0;
+ computer = () => this.element as FunctionTypedElement;
+ }
+ // TODO(paulberry): Is it a bug that we have to pass `false` for
+ // isInstantiated?
+ return new DeferredFunctionTypeImpl(computer, null,
+ _buildTypeArguments(numTypeArguments, getTypeArgument), false);
}
- // TODO(paulberry): Is it a bug that we have to pass `false` for
- // isInstantiated?
- return new DeferredFunctionTypeImpl(computer, null,
- _buildTypeArguments(numTypeArguments, getTypeArgument), false);
} else {
return null;
}
@@ -1357,9 +1367,9 @@ class _ReferenceInfo {
int numTypeArguments, DartType getTypeArgument(int i)) {
List<DartType> typeArguments = const <DartType>[];
if (numTypeArguments != 0) {
- typeArguments = <DartType>[];
+ typeArguments = new List<DartType>(numTypeArguments);
for (int i = 0; i < numTypeArguments; i++) {
- typeArguments.add(getTypeArgument(i));
+ typeArguments[i] = getTypeArgument(i);
}
}
return typeArguments;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698