mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
LocalsOrMyInstanceFieldsControlFlowPolicy: allow parentheses
See also IDEA-156926, JDK-8156180
This commit is contained in:
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.intellij.psi.controlFlow;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -55,7 +56,7 @@ public class LocalsOrMyInstanceFieldsControlFlowPolicy implements ControlFlowPol
|
||||
* the reference actually resolves to variable.
|
||||
*/
|
||||
public static boolean isLocalOrMyInstanceReference(PsiReferenceExpression variableReference) {
|
||||
PsiExpression qualifierExpression = variableReference.getQualifierExpression();
|
||||
PsiExpression qualifierExpression = PsiUtil.skipParenthesizedExprDown(variableReference.getQualifierExpression());
|
||||
// JLS 16: "Such an assignment is defined to occur if and only if either the simple name of the variable
|
||||
// (or, for a field, its simple name qualified by this) occurs on the left hand side of an assignment operator"
|
||||
// Qualified this is not allowed by spec
|
||||
|
||||
+3
-3
@@ -255,10 +255,10 @@ class QualifiedThis {
|
||||
|
||||
class ParenthesizedThis {
|
||||
final int x;
|
||||
final int y = (this).x + 1; // allowed as qualifier is not naked 'this'!
|
||||
final int y = <error descr="Variable '(this).x' might not have been initialized">(this).x</error> + 1; // javac allows this?
|
||||
|
||||
ParenthesizedThis() {
|
||||
<error descr="Cannot assign a value to final variable 'x'">(this).x</error> = 5;
|
||||
this.x = 6;
|
||||
(this).x = 5;
|
||||
<error descr="Variable 'x' might already have been assigned to">this.x</error> = 6;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user