Skip to content

Commit 602a316

Browse files
authored
Display potentially applicable extensions on nullable types (#3908)
1 parent dd226fe commit 602a316

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/src/model/extension.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Extension extends Container {
4545
if (extendedType is DynamicType || extendedType is VoidType) {
4646
return true;
4747
}
48+
extendedType = library.element.typeSystem.promoteToNonNull(extendedType);
4849
var otherType = container.modelType.type;
4950
if (otherType is InterfaceType) {
5051
otherType = library.element.typeSystem.instantiateInterfaceToBounds(

test/templates/class_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,25 @@ extension E on C {
314314
]);
315315
}
316316

317+
void test_instancePropertyAccessor_fromExtension_onNullableType() async {
318+
await createPackageWithLibrary('''
319+
class C {}
320+
321+
extension E on C? {
322+
/// An instance getter.
323+
int get f => 1;
324+
}
325+
''');
326+
var htmlLines = readLines(['lib', 'C-class.html']);
327+
328+
htmlLines.expectMainContentContainsAllInOrder([
329+
matches('<h2>Properties</h2>'),
330+
matches('<dt id="f" class="property">'),
331+
matches('<a href="../lib/E/f.html">f</a>'),
332+
matches('An instance getter.'),
333+
]);
334+
}
335+
317336
void test_instancePropertyAccessor_fromExtensionOfSupertype() async {
318337
await createPackageWithLibrary('''
319338
class C<T> {}

0 commit comments

Comments
 (0)