From 5fa727a5e4e6a368a92c6f36224dbe9716ed5659 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Wed, 27 Dec 2023 17:07:00 -0800 Subject: [PATCH] Actually test that `hasExtraParameterForEnclosingInstance` works. It does, but I got confused in https://github.com/google/error-prone/issues/4225. PiperOrigin-RevId: 594123682 --- .../NullArgumentForNonNullParameterTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameterTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameterTest.java index 8718f94aeae..cb2567e683e 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameterTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/nullness/NullArgumentForNonNullParameterTest.java @@ -218,4 +218,22 @@ public void negativeNullMarkedTypeVariable() { "}") .doTest(); } + + @Test + public void negativePrimitiveButEnclosingClass() { + conservativeHelper + .addSourceLines( + "Foo.java", + "import java.util.Optional;", + "class Foo {", + " class Bar {", + " Bar(int i) {}", + " }", + " void foo(Optional o) {", + // It would be nice to catch this, but for now, at least, we don't. + " new Bar(o.orElse(null));", + " }", + "}") + .doTest(); + } }