Skip to content
Open
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
18 changes: 18 additions & 0 deletions checker/tests/nullness/Test6872.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import java.util.*;
import org.checkerframework.checker.nullness.qual.*;

public class Test6872 {
public static Integer compare(Object x, Object y) {
return 0;
}

public static <T> void test(Collection<List<T>> p1, Comparator<Object> defaultComparator)
throws Exception {
Collections.min(
p1,
switch (1) {
case 1 -> Test6872::compare;
default -> defaultComparator;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,28 @@ private void lubPrimaryOnBoundedType(
TypeMirror typeMirror2 = type2.getUnderlyingType();

for (AnnotationMirror lower1 : type1LowerBoundAnnos) {
if (lower1 == null) {
// Defensive: AnnotationMirrorSet may (incorrectly) contain null entries. Skip them to
// avoid passing null to QualifierHierarchy/AnnotationUtils which expect non-null
// AnnotationMirrors.
continue;
}
AnnotationMirror top = qualHierarchy.getTopAnnotation(lower1);

// Can't just call isSubtype because it will return false if bounds have
// different annotations on component types
AnnotationMirror lower2 = qualHierarchy.findAnnotationInHierarchy(type2LowerBoundAnnos, top);
if (lower2 == null) {
// No matching annotation in the same hierarchy for type2; skip this hierarchy.
continue;
}
AnnotationMirror upper1 = type1.getEffectiveAnnotationInHierarchy(lower1);
AnnotationMirror upper2 = type2.getEffectiveAnnotationInHierarchy(lower1);
if (upper1 == null || upper2 == null) {
// If effective annotations are missing for either side, skip this hierarchy to avoid
// passing null into QualifierHierarchy methods which assume non-null AnnotationMirrors.
continue;
}

if (qualHierarchy.isSubtypeShallow(upper2, typeMirror2, upper1, typeMirror1)
&& qualHierarchy.isSubtypeShallow(upper1, typeMirror1, upper2, typeMirror2)
Expand Down
Loading