mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
[java-inspections] JavaReferenceAdjuster: avoid removing generic outer class qualifier in pattern instanceof
Fixes IDEA-296310 "Replace 'that' with pattern variable" generates uncompilable code for nested class GitOrigin-RevId: 0ac45ba97fdfe08e0d4a74b433b9770a82969406
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8df93af88f
commit
25842d7354
+1
-1
@@ -266,7 +266,7 @@ public class JavaReferenceAdjuster implements ReferenceAdjuster {
|
||||
if (parent instanceof PsiTypeElement) {
|
||||
final PsiClass containingClass = refClass.getContainingClass();
|
||||
if (containingClass != null && containingClass.hasTypeParameters()) {
|
||||
if (parent.getParent() instanceof PsiInstanceOfExpression) {
|
||||
if (parent.getParent() instanceof PsiInstanceOfExpression || parent.getParent() instanceof PsiPatternVariable) {
|
||||
return false;
|
||||
}
|
||||
if (!refClass.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Replace 'that' with pattern variable" "true"
|
||||
class PatternInner<T> {
|
||||
|
||||
class Basis {
|
||||
String key;
|
||||
|
||||
private PatternInner<T> outer() {
|
||||
return PatternInner.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof @SuppressWarnings("rawtypes")PatternInner.Basis that)) {
|
||||
return false;
|
||||
}
|
||||
return this.outer() == that.outer() && this.key.equals(that.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// "Replace 'that' with pattern variable" "true"
|
||||
class PatternInner<T> {
|
||||
|
||||
class Basis {
|
||||
String key;
|
||||
|
||||
private PatternInner<T> outer() {
|
||||
return PatternInner.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof PatternInner.Basis)) {
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
PatternInner.Basis <caret>that = (PatternInner.Basis) obj;
|
||||
return this.outer() == that.outer() && this.key.equals(that.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user