Chromium Code Reviews

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

Issue 2808093004: Fix use of generic function type aliases for fields (issue 29237) (Closed)
Patch Set: restore test Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
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 a6620cc6f5b8f6920815ab98cf92b9ebfb2964e1..fc9cf16b698cd36e199c1010cd03b03a4ada0d18 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -1256,11 +1256,23 @@ class _ReferenceInfo {
*/
DartType buildType(bool instantiateToBoundsAllowed, int numTypeArguments,
DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) {
- DartType result =
- (numTypeParameters == 0 && implicitFunctionTypeIndices.isEmpty)
- ? type
- : _buildType(instantiateToBoundsAllowed, numTypeArguments,
- getTypeArgument, implicitFunctionTypeIndices);
+ DartType result;
+ if (numTypeParameters == 0 && implicitFunctionTypeIndices.isEmpty) {
+ if (element is GenericTypeAliasElementHandle) {
scheglov 2017/04/10 21:37:16 Per offline discussion, this is OK to close the is
+ List<DartType> argumentTypes = <DartType>[];
+ for (int i = 0; i < numTypeArguments; i++) {
+ argumentTypes.add(getTypeArgument(i));
+ }
+ GenericTypeAliasElementImpl actualElement =
+ (element as GenericTypeAliasElementHandle).actualElement;
+ result = actualElement.typeAfterSubstitution(argumentTypes);
+ } else {
+ result = type;
+ }
+ } else {
+ result = _buildType(instantiateToBoundsAllowed, numTypeArguments,
+ getTypeArgument, implicitFunctionTypeIndices);
+ }
if (result == null) {
return DynamicTypeImpl.instance;
}
@@ -1837,6 +1849,11 @@ class _UnitResynthesizer {
case ReferenceKind.typedef:
element = new FunctionTypeAliasElementHandle(
summaryResynthesizer, location);
+ if ((element as ElementHandle).actualElement
scheglov 2017/04/10 21:37:16 Can we put FunctionTypeAliasElementHandle into a s
+ is GenericTypeAliasElement) {
+ element = new GenericTypeAliasElementHandle(
scheglov 2017/04/10 21:37:17 It's a bit scary that we request the actual elemen
+ summaryResynthesizer, location);
+ }
isDeclarableType = true;
break;
case ReferenceKind.variable:
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/non_error_resolver_driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine