Skip to content

Commit 60ea845

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Issue 190731. Support for aliasElement/aliasArguments in TypeParameterType.
Bug: #45291 Change-Id: Ia0378722f0e7c48e7a3042c0ef14d6833c7bf2b9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190734 Reviewed-by: Janice Collins <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent f54a76f commit 60ea845

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7152,6 +7152,13 @@ class TypeAliasElementImpl extends _ExistingElementImpl
71527152
aliasElement: this,
71537153
aliasArguments: typeArguments,
71547154
);
7155+
} else if (type is TypeParameterType) {
7156+
return TypeParameterTypeImpl(
7157+
element: type.element,
7158+
nullabilitySuffix: resultNullability,
7159+
aliasElement: this,
7160+
aliasArguments: typeArguments,
7161+
);
71557162
} else {
71567163
return (type as TypeImpl).withNullability(resultNullability);
71577164
}

pkg/analyzer/lib/src/dart/element/replacement_visitor.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ class ReplacementVisitor
135135
element: type.element,
136136
nullabilitySuffix: newNullability ?? type.nullabilitySuffix,
137137
promotedBound: newPromotedBound ?? promotedBound,
138+
aliasElement: type.aliasElement,
139+
aliasArguments: type.aliasArguments,
138140
);
139141
}
140142

@@ -149,6 +151,8 @@ class ReplacementVisitor
149151
return TypeParameterTypeImpl(
150152
element: type.element,
151153
nullabilitySuffix: newNullability,
154+
aliasElement: type.aliasElement,
155+
aliasArguments: type.aliasArguments,
152156
);
153157
}
154158

pkg/analyzer/lib/src/dart/element/type.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,13 @@ class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType {
18011801
required TypeParameterElement element,
18021802
required this.nullabilitySuffix,
18031803
this.promotedBound,
1804-
}) : super(element);
1804+
TypeAliasElement? aliasElement,
1805+
List<DartType>? aliasArguments,
1806+
}) : super(
1807+
element,
1808+
aliasElement: aliasElement,
1809+
aliasArguments: aliasArguments,
1810+
);
18051811

18061812
@override
18071813
DartType get bound =>

pkg/analyzer/lib/src/dart/element/type_demotion.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class DemotionNonNullificationVisitor extends ReplacementVisitor {
3838
return TypeParameterTypeImpl(
3939
element: type.element,
4040
nullabilitySuffix: newNullability ?? type.nullabilitySuffix,
41+
aliasElement: type.aliasElement,
42+
aliasArguments: type.aliasArguments,
4143
);
4244
}
4345
}

pkg/analyzer/lib/src/summary2/bundle_reader.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,13 @@ class LinkedResolutionReader {
744744
aliasElement: aliasElement,
745745
aliasArguments: aliasArguments,
746746
);
747+
} else if (type is TypeParameterType) {
748+
return TypeParameterTypeImpl(
749+
element: type.element,
750+
nullabilitySuffix: type.nullabilitySuffix,
751+
aliasElement: aliasElement,
752+
aliasArguments: aliasArguments,
753+
);
747754
} else if (type is VoidType) {
748755
// TODO(scheglov) add support for `void` aliasing
749756
return type;

pkg/analyzer/test/src/summary/resynthesize_common.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12509,10 +12509,6 @@ void f2(Never?<aliasElement: self::@typeAlias::A2, aliasArguments: [int]> a) {}
1250912509
withAliasElementArguments: true);
1251012510
}
1251112511

12512-
@FailingTest(
12513-
issue: 'https://github.com/dart-lang/sdk/issues/45291',
12514-
reason: 'Must be implemented',
12515-
)
1251612512
test_typedef_nonFunction_aliasElement_typeParameterType() async {
1251712513
featureSet = FeatureSets.nonFunctionTypeAliases;
1251812514
var library = await checkLibrary(r'''

0 commit comments

Comments
 (0)