Skip to content

Commit

Permalink
Double-check that the ImmutableChecker covers records
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 696147096
  • Loading branch information
cushon authored and Error Prone Team committed Nov 13, 2024
1 parent 5cd4330 commit d4e5a5f
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3556,4 +3556,35 @@ public void enumBound() {
""")
.doTest();
}

@Test
public void mutableRecord() {
compilationHelper
.addSourceLines(
"Test.java",
"""
import java.util.List;
import com.google.errorprone.annotations.Immutable;
@Immutable
// BUG: Diagnostic contains: 'R' has field 'xs'
record R(List<String> xs) {}
""")
.doTest();
}

@Test
public void immutableRecord() {
compilationHelper
.addSourceLines(
"Test.java",
"""
import com.google.common.collect.ImmutableList;
import com.google.errorprone.annotations.Immutable;
@Immutable
record R(ImmutableList<String> xs) {}
""")
.doTest();
}
}

0 comments on commit d4e5a5f

Please sign in to comment.