Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Sep 29, 2023
1 parent af6ca1f commit 16eb9c2
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.errorprone.CompilationTestHelper;
import java.util.Arrays;
import org.junit.Ignore;
import org.junit.Test;

public class NullAwayJSpecifyGenericsTests extends NullAwayTestsBase {
Expand Down Expand Up @@ -1004,6 +1005,46 @@ public void overrideExplicitlyTypedAnonymousClass() {
" public String apply(@Nullable String s) { return \"hello\"; }",
" };",
" }",
" static void anonymousClassesFullName() {",
" Test.Fn<@Nullable String, String> fn1 = new Test.Fn<@Nullable String, String>() {",
" // BUG: Diagnostic contains: parameter s is @NonNull, but parameter in superclass method",
" public String apply(String s) { return s; }",
" };",
" Test.FnClass<String, String> fn2 = new Test.FnClass<String, String>() {",
" // BUG: Diagnostic contains: method returns @Nullable, but superclass method",
" public @Nullable String apply(String s) { return null; }",
" };",
" Test.Fn<String, @Nullable String> fn3 = new Test.Fn<String, @Nullable String>() {",
" public @Nullable String apply(String s) { return null; }",
" };",
" Test.FnClass<@Nullable String, String> fn4 = new Test.FnClass<@Nullable String, String>() {",
" public String apply(@Nullable String s) { return \"hello\"; }",
" };",
" }",
"}")
.doTest();
}

@Ignore("Need to add support for this case")
@Test
public void overrideAnonymousNestedClass() {
makeHelper()
.addSourceLines(
"Test.java",
"package com.uber;",
"import org.jspecify.annotations.Nullable;",
"class Test {",
" class Wrapper<P extends @Nullable Object> {",
" abstract class Fn<R extends @Nullable Object> {",
" abstract R apply(P p);",
" }",
" }",
" void anonymousNestedClasses() {",
" Wrapper<@Nullable String>.Fn<String> fn1 = (this.new Wrapper<@Nullable String>()).new Fn<String>() {",
" // BUG: Diagnostic contains: parameter s is @NonNull, but parameter in superclass method",
" public String apply(String s) { return s; }",
" };",
" }",
"}")
.doTest();
}
Expand Down

0 comments on commit 16eb9c2

Please sign in to comment.