Skip to content

Commit

Permalink
Handle SuperReference (typetools#6910)
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Dec 10, 2024
1 parent 04b413d commit 7f96184
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.checkerframework.dataflow.expression.JavaExpression;
import org.checkerframework.dataflow.expression.LocalVariable;
import org.checkerframework.dataflow.expression.MethodCall;
import org.checkerframework.dataflow.expression.SuperReference;
import org.checkerframework.dataflow.expression.ThisReference;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.framework.qual.MonotonicQualifier;
Expand Down Expand Up @@ -494,6 +495,7 @@ protected void insertOrRefine(
public static boolean canInsertJavaExpression(JavaExpression expr) {
if (expr instanceof FieldAccess
|| expr instanceof ThisReference
|| expr instanceof SuperReference
|| expr instanceof LocalVariable
|| expr instanceof MethodCall
|| expr instanceof ArrayAccess
Expand Down Expand Up @@ -660,9 +662,8 @@ protected void computeNewValueAndInsert(
arrayValues.put(arrayAccess, newValue);
}
}
} else if (expr instanceof ThisReference) {
ThisReference thisRef = (ThisReference) expr;
if (sequentialSemantics || !thisRef.isAssignableByOtherCode()) {
} else if (expr instanceof ThisReference || expr instanceof SuperReference) {
if (sequentialSemantics || !expr.isAssignableByOtherCode()) {
V oldValue = thisValue;
V newValue = merger.apply(oldValue, value);
if (newValue != null) {
Expand Down Expand Up @@ -790,7 +791,7 @@ public void clearValue(JavaExpression expr) {
if (expr instanceof LocalVariable) {
LocalVariable localVar = (LocalVariable) expr;
return localVariableValues.get(localVar);
} else if (expr instanceof ThisReference) {
} else if (expr instanceof ThisReference || expr instanceof SuperReference) {
return thisValue;
} else if (expr instanceof FieldAccess) {
FieldAccess fieldAcc = (FieldAccess) expr;
Expand Down Expand Up @@ -823,7 +824,7 @@ public void clearValue(JavaExpression expr) {
return fieldValues.get((FieldAccess) je);
} else if (je instanceof ClassName) {
return classValues.get((ClassName) je);
} else if (je instanceof ThisReference) {
} else if (je instanceof ThisReference || je instanceof SuperReference) {
// "return thisValue" is wrong, because the node refers to an outer this.
// So, return null for now. TODO: improve.
return null;
Expand Down

0 comments on commit 7f96184

Please sign in to comment.