From 5e8fb0a4dcce9ebd229fff07c7c62a1ff2f2b904 Mon Sep 17 00:00:00 2001 From: ghm Date: Mon, 17 Apr 2023 05:51:00 -0700 Subject: [PATCH] Repro for b/227521723 PiperOrigin-RevId: 524823586 --- .../IncompatibleArgumentTypeTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/collectionincompatibletype/IncompatibleArgumentTypeTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/collectionincompatibletype/IncompatibleArgumentTypeTest.java index de3895aed68..55702058118 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/collectionincompatibletype/IncompatibleArgumentTypeTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/collectionincompatibletype/IncompatibleArgumentTypeTest.java @@ -47,4 +47,25 @@ public void multimapIntegration() { public void intersectionTypes() { compilationHelper.addSourceFile("IncompatibleArgumentTypeIntersectionTypes.java").doTest(); } + + @Test + public void typeWithinLambda() { + compilationHelper + .addSourceLines( + "Test.java", + "import com.google.common.collect.ImmutableList;", + "import com.google.errorprone.annotations.CompatibleWith;", + "import java.util.Map;", + "import java.util.Optional;", + "abstract class Test {", + " abstract Optional getOrEmpty(Map map, @CompatibleWith(\"K\") Object" + + " key);", + " void test(Map map, ImmutableList xs) {", + " // BUG: Diagnostic contains:", + " getOrEmpty(map, xs);", + " Optional x = Optional.empty().flatMap(k -> getOrEmpty(map, xs));", + " }", + "}") + .doTest(); + } }