Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/src/model/type_parameter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ class TypeParameter extends ModelElement {

@override
Map<String, CommentReferable> get referenceChildren {
return _referenceChildren ??= {
boundType.name: boundType,
};
if (_referenceChildren == null) {
_referenceChildren = {};
if (boundType != null) {
_referenceChildren[boundType.name] = boundType;
}
}
return _referenceChildren;
}

@override
Expand Down
13 changes: 12 additions & 1 deletion test/end2end/model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2257,13 +2257,19 @@ void main() {
Class TypeParameterThings,
TypeParameterThingsExtended,
TypeParameterThingsExtendedQ;
Field aName, aThing;
Extension UnboundTypeTargetExtension;
Field aName, aThing, doesNotCrash;
TypeParameter ATypeParam, BTypeParam, CTypeParam, DTypeParam, QTypeParam;
Method aMethod, aMethodExtended, aMethodExtendedQ;
Parameter aParam, anotherParam, typedParam;
ModelFunction aTopLevelTypeParameterFunction;

setUpAll(() {
UnboundTypeTargetExtension = fakeLibrary.extensions
.firstWhere((f) => f.name == 'UnboundTypeTargetExtension');
doesNotCrash = UnboundTypeTargetExtension.instanceFields
.firstWhere((f) => f.name == 'doesNotCrash');

aTopLevelTypeParameterFunction = fakeLibrary.functions
.firstWhere((f) => f.name == 'aTopLevelTypeParameterFunction');
// TODO(jcollins-g): dart-lang/dartdoc#2704, HTML and type parameters
Expand Down Expand Up @@ -2306,6 +2312,11 @@ void main() {
.firstWhere((p) => p.name == 'QTypeParam');
});

test('on extension targeting an unbound type', () {
expect(newLookup(UnboundTypeTargetExtension, 'doesNotCrash'),
equals(MatchingLinkResult(doesNotCrash)));
});

test('on inherited documentation', () {
expect(newLookup(aMethodExtended, 'ATypeParam'),
equals(MatchingLinkResult(ATypeParam)));
Expand Down
6 changes: 6 additions & 0 deletions testing/test_package/lib/fake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,12 @@ extension Leg on Megatron<String> {
bool get hasRightLeg => true;
}

/// Refer to [doesNotCrash] here.
extension UnboundTypeTargetExtension<T> on T {
/// We hope so!
bool get doesNotCrash => true;
}

class Megatron<T> {}

class SuperMegaTron<T extends String> extends Megatron<String> {}
Expand Down