Skip to content

Commit

Permalink
Fix problem with GLB
Browse files Browse the repository at this point in the history
  • Loading branch information
smillst authored Oct 10, 2024
1 parent b9dd1af commit 15cb814
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,17 @@ public static AnnotatedTypeMirror annotatedGLB(
TypeMirror tm1 = type1.getUnderlyingType();
TypeMirror tm2 = type2.getUnderlyingType();
TypeMirror glbJava = TypesUtils.greatestLowerBound(tm1, tm2, atypeFactory.getProcessingEnv());
if (glbJava.getKind() == TypeKind.ERROR) {
if (type1.getKind() == TypeKind.TYPEVAR) {
return type1;
}
if (type2.getKind() == TypeKind.TYPEVAR) {
return type2;
}
// I think the only way error happens is when one of the types is a typevarible, but just in
// case, just return type1.
return type1;
}
Types types = atypeFactory.types;
QualifierHierarchy qualHierarchy = atypeFactory.getQualifierHierarchy();
if (types.isSubtype(tm1, tm2)) {
Expand Down
11 changes: 11 additions & 0 deletions framework/tests/all-systems/Issue6810.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import java.util.Set;

public class Issue6810 {
static class Box<T extends Box<T>> {}

abstract static class BoxSet<T extends Box<T>> implements Set<T> {}

static <E extends Box<E>> void intersect2(BoxSet<? extends E> intersect, Set<E> set2) {
intersect.retainAll(set2);
}
}

0 comments on commit 15cb814

Please sign in to comment.