eb804709da
The issue is the type checker doesn't consider P? a subtype of CapturedType<in P>?, whereas P a subtype of CapturedType<in P>?. In AbstractTypeCheckerContext::checkSubtypeForSpecialCases, it checks if P? is a subtype of the lower type of the captured type, which is P, and returns false. This fix uses nullable version of the lower type when the captured type is marked nullable. To check if P? is a subtype of Captured<in P>?, we check the LHS, P?, against the nullable lower type of RHS, P?. ^KT-42825 Fixed
23 lines
487 B
Kotlin
Vendored
23 lines
487 B
Kotlin
Vendored
// FILE: Processor.java
|
|
|
|
public interface Processor<T> {
|
|
boolean process(T t);
|
|
}
|
|
|
|
// FILE: test.kt
|
|
|
|
interface PsiModifierListOwner
|
|
interface KtClassOrObject {
|
|
fun toLightClass(): PsiModifierListOwner?
|
|
}
|
|
|
|
fun execute(declaration: Any, consumer: Processor<in PsiModifierListOwner>) {
|
|
when (declaration) {
|
|
is KtClassOrObject -> {
|
|
val lightClass = declaration.toLightClass()
|
|
consumer.process(lightClass)
|
|
}
|
|
}
|
|
}
|
|
|
|
fun box(): String = "OK" |