From d9ee5d50b6c552fb8c0d2d0fc356ad2355e5e166 Mon Sep 17 00:00:00 2001 From: Kurt Alfred Kluever Date: Wed, 8 Jan 2025 09:01:01 -0800 Subject: [PATCH] Add a MCVE for `NonApiType` and a `record`. PiperOrigin-RevId: 713309496 --- .../bugpatterns/NonApiTypeTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/NonApiTypeTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/NonApiTypeTest.java index 75fb4d7f943..7db66ba27bb 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/NonApiTypeTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/NonApiTypeTest.java @@ -345,4 +345,24 @@ public Record(ArrayList a) { """) .doTest(); } + + @Test + public void recordCompactConstructor_notFlagged() { + helper + .addSourceLines( + "Test.java", + """ + import static com.google.common.base.Preconditions.checkArgument; + import com.google.common.collect.ImmutableSet; + + public class Test { + public record RecordWithImmutableSet(ImmutableSet ids) { + public RecordWithImmutableSet { + ids.forEach(id -> checkArgument(!id.isBlank())); + } + } + } + """) + .doTest(); + } }