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(); + } }