mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: avoid false positive in broken code with cyclic inheritance
for "Subclass field hides superclass field" inspection GitOrigin-RevId: 2da814fb51c92618cf528260c0ee585b894ca65a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2a24d241f8
commit
f48cea56e1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2019 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2025 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -97,6 +97,7 @@ public final class FieldHidesSuperclassFieldInspection extends BaseInspection {
|
||||
}
|
||||
PsiClass ancestorClass = aClass.getSuperClass();
|
||||
final Set<PsiClass> visitedClasses = new HashSet<>();
|
||||
visitedClasses.add(aClass);
|
||||
while (ancestorClass != null) {
|
||||
if (!visitedClasses.add(ancestorClass)) {
|
||||
return;
|
||||
|
||||
+9
@@ -10,4 +10,13 @@ class Sub extends FieldHidesSuperclassField {
|
||||
class Sub2 extends FieldHidesSuperclassField {
|
||||
String a;
|
||||
String <warning descr="Field 's' hides field in superclass">s</warning>;
|
||||
}
|
||||
<error descr="Cyclic inheritance involving 'A'">class A extends B</error> {
|
||||
String s = "";
|
||||
|
||||
void f() { }
|
||||
}
|
||||
|
||||
<error descr="Cyclic inheritance involving 'B'">class B extends A</error> {
|
||||
void f() { }
|
||||
}
|
||||
Reference in New Issue
Block a user