Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,16 @@ public void compareGenericTypeParameterNullabilityForCall(
TypeSubstitutionUtils.memberType(state.getTypes(), enclosingType, methodSymbol, config);
}
}

// substitute type arguments for constructor call
if (tree instanceof NewClassTree) {
Type enclosingType = getTreeType(tree, config);
Comment thread
dhruv-agr marked this conversation as resolved.
if (enclosingType != null) {
invokedMethodType =
TypeSubstitutionUtils.memberType(state.getTypes(), enclosingType, methodSymbol, config);
}
}

// substitute type arguments for generic methods with explicit type arguments
if (tree instanceof MethodInvocationTree && methodSymbol.type instanceof Type.ForAll) {
invokedMethodType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2388,6 +2388,36 @@ public void newNullableWithArgAndConstructorType() {
.doTest();
}

@Test
public void lambdaToNewNullable() {
makeHelper()
.addSourceLines(
"Foo.java",
"import org.jspecify.annotations.NullMarked;",
"import org.jspecify.annotations.Nullable;",
"@NullMarked",
"class Foo {",
" interface Supplier<T extends @Nullable Object> {",
" T get();",
" }",
" static class SupplierImpl<T2 extends @Nullable Object> implements Supplier<T2> {",
" Supplier<T2> impl;",
" SupplierImpl(Supplier<T2> delegate) {",
" impl = delegate;",
" }",
" @Override",
" public T2 get() {",
" return impl.get();",
" }",
" }",
" static void main() {",
" Supplier<@Nullable Foo> sup = () -> null;",
" new SupplierImpl<@Nullable Foo>(sup);",
" }",
"}")
.doTest();
}

@Test
public void issue1156() {
makeHelper()
Expand Down