Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing override to RestoreNullnessAnnotationsVisitor #1154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ public Type visitTypeVar(Type.TypeVar t, Type other) {
return updated != null ? updated : t;
}

@Override
public Type visitForAll(Type.ForAll t, Type other) {
Type methodType = t.qtype;
Type otherMethodType = ((Type.ForAll) other).qtype;
Type newMethodType = visit(methodType, otherMethodType);
if (methodType == newMethodType) {
return t;
} else {
return new Type.ForAll(t.tvars, newMethodType);
}
}

/**
* Updates the nullability annotations on a type {@code t} based on the nullability annotations
* on a type variable {@code other}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2258,6 +2258,26 @@ public void issue1126() {
.doTest();
}

@Test
public void issue1129() {
makeHelper()
.addSourceLines(
"Test.java",
"package com.uber;",
"import org.jspecify.annotations.Nullable;",
"import java.util.function.Consumer;",
"class Test {",
" interface BodySpec<B, S extends BodySpec<B, S>> {",
" <T extends S> T value(Consumer<@Nullable B> consumer);",
" }",
" abstract class DefaultBodySpec<B, S extends BodySpec<B, S>> implements BodySpec<B, S> {",
" @Override",
" public abstract <T extends S> T value(Consumer<@Nullable B> consumer);",
" }",
"}")
.doTest();
}

private CompilationTestHelper makeHelper() {
return makeTestHelperWithArgs(
Arrays.asList(
Expand Down