Skip to content

Commit 137224c

Browse files
committed
fix 6990
1 parent 751f087 commit 137224c

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

checker/src/main/java/org/checkerframework/checker/resourceleak/MustCallConsistencyAnalyzer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public boolean derivedFromMustCallAlias() {
353353
}
354354

355355
/**
356-
* Gets the must-call type associated with the given resource alias, falling on back on the
356+
* Gets the must-call type associated with the given resource alias, falling back on the
357357
* declared type if there is no refined type for the alias in the store.
358358
*
359359
* @param alias a resource alias
@@ -367,7 +367,9 @@ private static AnnotationMirror getMustCallValue(
367367
CFValue value = mcStore == null ? null : mcStore.getValue(reference);
368368
if (value != null) {
369369
AnnotationMirror result =
370-
AnnotationUtils.getAnnotationByClass(value.getAnnotations(), MustCall.class);
370+
mcAtf
371+
.getQualifierHierarchy()
372+
.findAnnotationInHierarchy(value.getAnnotations(), mcAtf.TOP);
371373
if (result != null) {
372374
return result;
373375
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// test case for https://github.com/typetools/checker-framework/issues/6990
2+
3+
import java.io.Closeable;
4+
import org.checkerframework.checker.mustcall.qual.MustCallUnknown;
5+
import org.checkerframework.checker.mustcall.qual.Owning;
6+
7+
public class DropOwning {
8+
9+
public void f(@Owning Closeable resource) {
10+
drop(resource);
11+
}
12+
13+
// :: error: required.method.not.known
14+
private void drop(@Owning @MustCallUnknown Object resourceCF6990) {}
15+
}

0 commit comments

Comments
 (0)