Thanks to visit codestin.com
Credit goes to github.com

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
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ private static class RestoreNullnessAnnotationsVisitor extends Types.MapVisitor<

@Override
public Type visitMethodType(Type.MethodType t, Type other) {
Type.MethodType otherMethodType = (Type.MethodType) other;
// other can be a ForAll whose qtype is a MethodType; asMethodType() safely unwraps it.
Type.MethodType otherMethodType = other.asMethodType();
List<Type> argtypes = t.argtypes;
Type restype = t.restype;
List<Type> thrown = t.thrown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,31 @@ public void methodInvocationTypeVarReceiver() {
.doTest();
}

/** For issue 1264. Checks that we don't crash when overriding with raw types. */
@Test
public void overrideWithRawTypes() {
makeHelper()
.addSourceLines(
"Test.java",
"import org.jspecify.annotations.NullMarked;",
"@NullMarked",
"public class Test {",
" static class A<T> {}",
" static class B<T> {",
" public <X> X accept(A<X> a) {",
" throw new RuntimeException();",
" }",
" }",
" static class Raw extends B {",
" @Override",
" public Object accept(A a) {",
" throw new RuntimeException();",
" }",
" }",
"}")
.doTest();
}

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