mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DFA control flow: do not leak this for nested class constructor
GitOrigin-RevId: a5c8e571dac99819b9f058db753f3a41e1025aac
This commit is contained in:
committed by
intellij-monorepo-bot
parent
71e46b99bc
commit
23063d2a84
+1
-1
@@ -1852,7 +1852,7 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
qualifier.accept(this);
|
||||
} else {
|
||||
PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(expression.getType());
|
||||
if (aClass != null) {
|
||||
if (aClass != null && !aClass.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
PsiClass outerClass = aClass.getContainingClass();
|
||||
if (outerClass != null && InheritanceUtil.hasEnclosingInstanceInScope(outerClass, expression, true, false)) {
|
||||
qualifierValue = myFactory.getVarFactory().createThisValue(outerClass);
|
||||
|
||||
@@ -27,6 +27,16 @@ class Tester
|
||||
System.err.println("Is false");
|
||||
}
|
||||
|
||||
private Tester(int i)
|
||||
{
|
||||
// nested class: should not drop locality ('this' is not leaked)
|
||||
new Nested();
|
||||
if (<warning descr="Condition 'flag' is always 'false'">flag</warning>)
|
||||
System.err.println("Is true.");
|
||||
else
|
||||
System.err.println("Is false");
|
||||
}
|
||||
|
||||
class Inner
|
||||
{
|
||||
Inner()
|
||||
@@ -34,4 +44,12 @@ class Tester
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
static class Nested
|
||||
{
|
||||
Nested()
|
||||
{
|
||||
<error descr="Non-static field 'flag' cannot be referenced from a static context">flag</error> = true; // cannot access flag
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user