Skip to content

Commit c9621b9

Browse files
authored
Parameterized type hierarchy change (dart-lang#2714)
* This fixes the problem but there is still a missing test * Add tests * the override was unnecessary altogether
1 parent b86cddc commit c9621b9

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

lib/src/element_type.dart

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,6 @@ mixin Aliased implements ElementType {
234234
_aliasArguments ??= type.aliasArguments
235235
.map((f) => ElementType.from(f, library, packageGraph))
236236
.toList(growable: false);
237-
238-
Iterable<ElementType> _typeArguments;
239-
@override
240-
Iterable<ElementType> get typeArguments =>
241-
_typeArguments ??= (type as ParameterizedType)
242-
.typeArguments
243-
.map((f) => ElementType.from(f, library, packageGraph))
244-
.toList(growable: false);
245237
}
246238

247239
class AliasedElementType extends ParameterizedElementType with Aliased {
@@ -251,6 +243,9 @@ class AliasedElementType extends ParameterizedElementType with Aliased {
251243
assert(type.aliasElement != null);
252244
}
253245

246+
@override
247+
ParameterizedType get type;
248+
254249
/// Parameters, if available, for the underlying typedef.
255250
List<Parameter> get aliasedParameters =>
256251
modelElement.isCallable ? modelElement.parameters : [];

test/end2end/model_test.dart

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4068,6 +4068,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
40684068
TopLevelVariable nodocGetter, nodocSetter;
40694069
TopLevelVariable complicatedReturn;
40704070
TopLevelVariable meaningOfLife, importantComputations;
4071+
TopLevelVariable genericTypedefCombo;
40714072

40724073
setUpAll(() {
40734074
v = exLibrary.properties.firstWhere((p) => p.name == 'number');
@@ -4090,6 +4091,19 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
40904091
fakeLibrary.properties.firstWhere((p) => p.name == 'setAndGet');
40914092
mapWithDynamicKeys = fakeLibrary.properties
40924093
.firstWhere((p) => p.name == 'mapWithDynamicKeys');
4094+
genericTypedefCombo = fakeLibrary.properties
4095+
.firstWhere((p) => p.name == 'genericTypedefCombo');
4096+
});
4097+
4098+
test(
4099+
'Verify that combos with a generic typedef modelType can render correctly',
4100+
() {
4101+
// TODO(jcollins-g): After analyzer 2.0.0, this can be `isEmpty`.
4102+
expect(genericTypedefCombo.modelType.typeArguments, isNotNull);
4103+
expect(
4104+
genericTypedefCombo.modelType.linkedName,
4105+
equals(
4106+
'<a href=\"%%__HTMLBASE_dartdoc_internal__%%fake/NewGenericTypedef.html\">NewGenericTypedef</a>'));
40934107
});
40944108

40954109
test('Verify that final and late show up (or not) appropriately', () {
@@ -4554,9 +4568,9 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
45544568
expect(
45554569
oldgeneric.modelType.linkedName,
45564570
isIn([
4571+
'T Function<span class="signature">(<span class="parameter" id="GenericTypedef-param-input"><span class="type-annotation">T</span> <span class="parameter-name">input</span></span>)</span>',
4572+
// Remove following after analyzer 2.0.0
45574573
'T Function<span class="signature">(<span class="parameter" id="param-input"><span class="type-annotation">T</span> <span class="parameter-name">input</span></span>)</span>',
4558-
// Remove below option after analyzer 1.6.0.
4559-
'Function(<span class=\"parameter\" id=\"GenericTypedef-param-input\"><span class=\"type-annotation\">T</span></span>) → T'
45604574
]));
45614575
expect(
45624576
generic.modelType.linkedName,

testing/test_package/lib/fake.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ typedef T GenericTypedef<T>(T input);
301301
/// A typedef with the new style generic function syntax.
302302
typedef NewGenericTypedef<T> = List<S> Function<S>(T, int, bool);
303303

304+
/// A top level variable with a generic typedef type.
305+
NewGenericTypedef genericTypedefCombo;
306+
304307
/// A complicated type parameter to ATypeTakingClass.
305308
ATypeTakingClass<String Function(int)> get complicatedReturn => null;
306309

0 commit comments

Comments
 (0)