[java-highlighting] Report static fields that collide with record components

Fixes IDEA-246454 bad code is green: record component already defined

GitOrigin-RevId: 1b2a48c0eb0b543ec9d60d7ed3cf2b3aabc3330c
This commit is contained in:
Tagir Valeev
2020-07-24 10:52:51 +00:00
committed by intellij-monorepo-bot
parent 4dfb7b9999
commit 874d090e21
2 changed files with 5 additions and 0 deletions
@@ -651,6 +651,8 @@ public final class HighlightUtil {
PsiField fieldByName = aClass.findFieldByName(variable.getName(), false);
if (fieldByName != null && fieldByName != field) {
oldVariable = fieldByName;
} else {
oldVariable = ContainerUtil.find(aClass.getRecordComponents(), c -> c.getName().equals(field.getName()));
}
}
else {
@@ -66,4 +66,7 @@ record ProhibitedMembers() {
System.out.println("initializer");
}</error>
<error descr="Modifier 'native' not allowed here">native</error> void test();
}
record StaticFieldCollides(int i) {
static int <error descr="Variable 'i' is already defined in the scope">i</error>;
}