Skip to content

Commit

Permalink
Don't flag explicit record constructors as missing overrides.
Browse files Browse the repository at this point in the history
Fixes external #4598.

PiperOrigin-RevId: 683102994
  • Loading branch information
graememorgan authored and Error Prone Team committed Oct 7, 2024
1 parent a241d95 commit 81ae61d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public Description matchMethod(MethodTree tree, VisitorState state) {
return NO_MATCH;
}
if (ASTHelpers.isRecord(sym.owner)
&& !sym.isConstructor()
&& sym.getModifiers().contains(Modifier.PUBLIC)
&& sym.getParameters().isEmpty()) {
ImmutableSet<Name> components =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,23 @@ public int y() {
""")
.doTest();
}

@Test
public void explicitRecordAccessor_doesNotFlagConstructors() {
assume().that(Runtime.version().feature()).isAtLeast(16);

compilationHelper
.addSourceLines(
"Test.java",
"""
public record Test(int x) {
public Test() {
this(1);
}
public Test {}
}
""")
.doTest();
}
}

0 comments on commit 81ae61d

Please sign in to comment.