diff --git a/checker/tests/resourceleak/Issue7217.java b/checker/tests/resourceleak/Issue7217.java new file mode 100644 index 000000000000..23ab5ddee39a --- /dev/null +++ b/checker/tests/resourceleak/Issue7217.java @@ -0,0 +1,9 @@ +import java.util.Collection; + +// Test case to show fix for https://github.com/typetools/checker-framework/issues/7217 +class Issue7217> { + + void test(boolean b, Collection c1, Collection c2) { + Object x = b ? c1 : c2; + } +} diff --git a/docs/manual/contributors.tex b/docs/manual/contributors.tex index fc5a6d8872f5..2eb88be2fa3b 100644 --- a/docs/manual/contributors.tex +++ b/docs/manual/contributors.tex @@ -141,6 +141,7 @@ Steph Dietzel, Stephan Schroevers, Stuart Pernsteiner, +Suvrat Acharya, Suzanne Millstein, Thomas Schweizer, Thomas Wei\ss schuh, diff --git a/framework/src/main/java/org/checkerframework/framework/flow/CFAbstractValue.java b/framework/src/main/java/org/checkerframework/framework/flow/CFAbstractValue.java index f8b221440ccf..7181879fbcbf 100644 --- a/framework/src/main/java/org/checkerframework/framework/flow/CFAbstractValue.java +++ b/framework/src/main/java/org/checkerframework/framework/flow/CFAbstractValue.java @@ -404,6 +404,9 @@ private final AnnotationMirror lowestQualifier(AnnotationMirror qual1, Annotatio AnnotatedTypeVariable typeVar, AnnotationMirror top, boolean canCombinedSetBeMissingAnnos) { + if (typeVar == null) { + return annotation; + } AnnotationMirror upperBound = typeVar.getAnnotationInHierarchy(top); TypeMirror upperBoundTM = typeVar.getUpperBound().getUnderlyingType(); @@ -590,6 +593,9 @@ public ValueLub(boolean shouldWiden) { AnnotatedTypeVariable typeVar, AnnotationMirror top, boolean canCombinedSetBeMissingAnnos) { + if (typeVar == null) { + return annotation; + } TypeMirror typeVarTM = typeVar.getUnderlyingType(); if (canCombinedSetBeMissingAnnos) { // anno is the primary annotation on the use of a type variable. typeVar is a use of @@ -695,6 +701,9 @@ protected class ValueGlb extends AnnotationSetCombiner { AnnotatedTypeVariable typeVar, AnnotationMirror top, boolean canCombinedSetBeMissingAnnos) { + if (typeVar == null) { + return annotation; + } TypeMirror typeVarTM = typeVar.getUnderlyingType(); if (canCombinedSetBeMissingAnnos) { // anno is the primary annotation on the use of a type variable. typeVar is a use of