Skip to content

Commit d5276b8

Browse files
graememorganError Prone Team
authored andcommitted
A bug has been fixed in jdkhead, and broken our tests! Allow it.
PiperOrigin-RevId: 762357520
1 parent 651588d commit d5276b8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

core/src/test/java/com/google/errorprone/bugpatterns/collectionincompatibletype/IncompatibleArgumentTypeTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.errorprone.bugpatterns.collectionincompatibletype;
1818

19+
import static com.google.common.truth.TruthJUnit.assume;
20+
1921
import com.google.errorprone.CompilationTestHelper;
2022
import org.junit.Test;
2123
import org.junit.runner.RunWith;
@@ -303,6 +305,8 @@ void testArraySpecialization(
303305

304306
@Test
305307
public void typeWithinLambda() {
308+
assume().that(Runtime.version().feature()).isAtMost(21);
309+
306310
compilationHelper
307311
.addSourceLines(
308312
"Test.java",
@@ -321,6 +325,33 @@ void test(Map<Long, String> map, ImmutableList<Long> xs) {
321325
Optional<String> x = Optional.empty().flatMap(k -> getOrEmpty(map, xs));
322326
}
323327
}
328+
""")
329+
.doTest();
330+
}
331+
332+
@Test
333+
public void typeWithinLambda_jdkhead() {
334+
assume().that(Runtime.version().feature()).isAtLeast(25);
335+
336+
compilationHelper
337+
.addSourceLines(
338+
"Test.java",
339+
"""
340+
import com.google.common.collect.ImmutableList;
341+
import com.google.errorprone.annotations.CompatibleWith;
342+
import java.util.Map;
343+
import java.util.Optional;
344+
345+
abstract class Test {
346+
abstract <K, V> Optional<V> getOrEmpty(Map<K, V> map, @CompatibleWith("K") Object key);
347+
348+
void test(Map<Long, String> map, ImmutableList<Long> xs) {
349+
// BUG: Diagnostic contains:
350+
getOrEmpty(map, xs);
351+
// BUG: Diagnostic contains:
352+
Optional<String> x = Optional.empty().flatMap(k -> getOrEmpty(map, xs));
353+
}
354+
}
324355
""")
325356
.doTest();
326357
}

0 commit comments

Comments
 (0)