Fix #5167 - issue with type projection
This commit is contained in:
@@ -1170,6 +1170,13 @@ public final class TypeOps {
|
||||
} else if (!upwards) {
|
||||
// If Ai is a type that mentions a restricted type variable, then Ai' is undefined.
|
||||
return NO_DOWN_PROJECTION;
|
||||
} else if (u instanceof JWildcardType) {
|
||||
// The rest of this function, below, treats u as the bound of a wildcard,
|
||||
// but if u is already a wildcard (and therefore ai was a wildcard), we
|
||||
// are already done.
|
||||
newTargs.add(u);
|
||||
change = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
change = true;
|
||||
|
@@ -95,7 +95,44 @@ class TypeOpsTest : FunSpec({
|
||||
|
||||
|
||||
}
|
||||
test("#5167 problem in projection") {
|
||||
val (acu, spy) = javaParser.parseWithTypeInferenceSpy(
|
||||
"""
|
||||
import java.lang.annotation.Annotation;
|
||||
interface Bar<T> {
|
||||
Baz<T> getBaz();
|
||||
}
|
||||
|
||||
interface Predicate<T> {
|
||||
boolean check(T t);
|
||||
}
|
||||
interface Stream<T>{
|
||||
T findSome();
|
||||
}
|
||||
interface Baz<T>{
|
||||
Stream<Bar<? super T>> filterMethods(Predicate<? super T> p);
|
||||
}
|
||||
|
||||
class Foo {
|
||||
|
||||
private static Bar<?> foo(
|
||||
Bar<?> type, Class<? extends Annotation> annotation, boolean required) {
|
||||
var method = type.getBaz().filterMethods(m -> true).findSome();
|
||||
return method;
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
val (barT) = acu.declaredTypeSignatures()
|
||||
val methodId = acu.varId("method")
|
||||
|
||||
spy.shouldBeOk {
|
||||
methodId shouldHaveType barT[`?`]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
Reference in New Issue
Block a user