Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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 @@ -1626,6 +1626,15 @@ public AnnotatedTypeMirror getAnnotatedTypeLhsNoTypeVarDefault(Tree lhsTree) {
return type;
}

@Override
public AnnotatedTypeMirror getAnnotatedType(Tree tree) {
boolean oldUseFlow = useFlow;
useFlow = everUseFlow;
AnnotatedTypeMirror res = super.getAnnotatedType(tree);
useFlow = oldUseFlow;
return res;
}

/**
* Returns the type of a left-hand side of an assignment.
*
Expand All @@ -1648,7 +1657,8 @@ public AnnotatedTypeMirror getAnnotatedTypeLhs(Tree lhsTree) {
case IDENTIFIER:
case MEMBER_SELECT:
case ARRAY_ACCESS:
res = getAnnotatedType(lhsTree);
// For member-select tree, we want the receiver to have the refinement
res = super.getAnnotatedType(lhsTree);
break;
case PARENTHESIZED:
res = getAnnotatedTypeLhs(TreeUtils.withoutParens((ExpressionTree) lhsTree));
Expand All @@ -1657,7 +1667,7 @@ public AnnotatedTypeMirror getAnnotatedTypeLhs(Tree lhsTree) {
if (TreeUtils.isTypeTree(lhsTree)) {
// lhsTree is a type tree at the pseudo assignment of a returned expression to
// declared return type.
res = getAnnotatedType(lhsTree);
res = super.getAnnotatedType(lhsTree);
} else {
throw new BugInCF(
"GenericAnnotatedTypeFactory: Unexpected tree passed to"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests;
package org.checkerframework.framework.test.junit;
Comment thread
AndrewShf marked this conversation as resolved.

import org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest;
import org.junit.runners.Parameterized;
Expand Down
28 changes: 28 additions & 0 deletions framework/tests/viewpointtest/TestGetAnnotatedLhs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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
Test() {
this.f = new @ReceiverDependentQual Object();
}

@SuppressWarnings({"cast.unsafe.constructor.invocation"})
void test1() {
Test a = new @A Test();
Test top = new @Top Test();
top = a;
// :: error: (assignment.type.incompatible)
top.f = new @B Object();
Comment thread
AndrewShf marked this conversation as resolved.
}
}