Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1657,9 +1657,7 @@ public AnnotatedTypeMirror getAnnotatedTypeLhsNoTypeVarDefault(Tree lhsTree) {
*/
public AnnotatedTypeMirror getAnnotatedTypeLhs(Tree lhsTree) {
AnnotatedTypeMirror res;
boolean oldUseFlow = useFlow;
boolean oldShouldCache = shouldCache;
useFlow = false;
// Don't cache the result because getAnnotatedType(lhsTree) could
// be called from elsewhere and would expect flow-sensitive type refinements.
shouldCache = false;
Expand All @@ -1668,6 +1666,7 @@ public AnnotatedTypeMirror getAnnotatedTypeLhs(Tree lhsTree) {
case IDENTIFIER:
case MEMBER_SELECT:
case ARRAY_ACCESS:
// For member-select tree, we want the receiver to have the refinement
res = getAnnotatedType(lhsTree);
break;
case PARENTHESIZED:
Expand All @@ -1687,7 +1686,6 @@ public AnnotatedTypeMirror getAnnotatedTypeLhs(Tree lhsTree) {
+ lhsTree.getKind());
}
}
useFlow = oldUseFlow;
shouldCache = oldShouldCache;
return res;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests;
package org.checkerframework.framework.test.junit;

import org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest;
import org.junit.runners.Parameterized;
Expand Down
35 changes: 35 additions & 0 deletions framework/tests/viewpointtest/TestGetAnnotatedLhs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import viewpointtest.quals.A;
import viewpointtest.quals.B;
import viewpointtest.quals.ReceiverDependentQual;
import viewpointtest.quals.Top;

@ReceiverDependentQual
class TestGetAnnotatedLhs {
@ReceiverDependentQual Object f;

@SuppressWarnings({
"inconsistent.constructor.type",
"super.invocation.invalid",
"cast.unsafe.constructor.invocation"
})
@ReceiverDependentQual
TestGetAnnotatedLhs() {
this.f = new @ReceiverDependentQual Object();
}

@SuppressWarnings({"cast.unsafe.constructor.invocation"})
void topWithRefinement() {
TestGetAnnotatedLhs a = new @A TestGetAnnotatedLhs();
TestGetAnnotatedLhs top = new @Top TestGetAnnotatedLhs();
top = a;
// :: error: (assignment.type.incompatible)
top.f = new @B Object();
top.f = new @A Object(); // no error here
}

@SuppressWarnings({"cast.unsafe.constructor.invocation"})
void topWithoutRefinement() {
TestGetAnnotatedLhs top = new @Top TestGetAnnotatedLhs();
top.f = new @A Object();
}
}