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

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

Issue 2837963002: Fix for indirect recursion in resynthesizing function type aliases. (Closed)
Patch Set: Created 3 years, 8 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 fc1054f97072d868676287603796e11170c4a122..b3f32cda59e956432f621e97ecfe8babf2e68a28 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -1229,6 +1229,9 @@ class _ReferenceInfo {
*/
final int numTypeParameters;
+ bool _isBeingInstantiatedToBounds = false;
+ bool _isRecursiveWhileInstantiateToBounds = false;
+
/**
* Create a new [_ReferenceInfo] object referring to an element called [name]
* via the element handle [element], and having [numTypeParameters] type
@@ -1262,6 +1265,9 @@ class _ReferenceInfo {
return _type;
}
+ List<DartType> get _dynamicTypeArguments =>
+ new List<DartType>.filled(numTypeParameters, DynamicTypeImpl.instance);
+
/**
* Build a [DartType] corresponding to the result of applying some type
* arguments to the entity referred to by this [_ReferenceInfo]. The type
@@ -1322,8 +1328,7 @@ class _ReferenceInfo {
.instantiateToBounds(element.type) as InterfaceType;
return instantiatedToBounds.typeArguments;
} else {
- return new List<DartType>.filled(
- numTypeParameters, DynamicTypeImpl.instance);
+ return _dynamicTypeArguments;
}
}
return typeArguments;
@@ -1348,13 +1353,27 @@ class _ReferenceInfo {
_buildTypeArguments(numTypeArguments, getTypeArgument);
} else if (libraryResynthesizer.summaryResynthesizer.strongMode &&
instantiateToBoundsAllowed) {
- FunctionType instantiatedToBounds = libraryResynthesizer
- .summaryResynthesizer.context.typeSystem
- .instantiateToBounds(element.type) as FunctionType;
- typeArguments = instantiatedToBounds.typeArguments;
+ if (!_isBeingInstantiatedToBounds) {
+ _isBeingInstantiatedToBounds = true;
+ _isRecursiveWhileInstantiateToBounds = false;
+ try {
+ FunctionType instantiatedToBounds = libraryResynthesizer
+ .summaryResynthesizer.context.typeSystem
+ .instantiateToBounds(element.type) as FunctionType;
+ if (!_isRecursiveWhileInstantiateToBounds) {
+ typeArguments = instantiatedToBounds.typeArguments;
+ } else {
+ typeArguments = _dynamicTypeArguments;
+ }
+ } finally {
+ _isBeingInstantiatedToBounds = false;
+ }
+ } else {
+ _isRecursiveWhileInstantiateToBounds = true;
+ typeArguments = _dynamicTypeArguments;
+ }
} else {
- typeArguments = new List<DartType>.filled(
- numTypeParameters, DynamicTypeImpl.instance);
+ typeArguments = _dynamicTypeArguments;
}
return new FunctionTypeImpl.elementWithNameAndArgs(
element, name, typeArguments, numTypeParameters != 0);
« 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