[FIR] Implement canBeNull for captured type by checking its supertypes
#KT-62959
This commit is contained in:
committed by
Space Team
parent
7b0c4e5bf6
commit
00491a78f1
@@ -256,6 +256,9 @@ class Fir2IrImplicitCastInserter(
|
||||
}
|
||||
|
||||
private fun ConeKotlinType.acceptsNullValues(): Boolean {
|
||||
if (this is ConeCapturedType && this.constructor.projection.kind == ProjectionKind.IN) {
|
||||
return constructor.projection.type!!.canBeNull(session)
|
||||
}
|
||||
return canBeNull(session) || hasEnhancedNullability
|
||||
}
|
||||
|
||||
|
||||
@@ -821,6 +821,7 @@ fun ConeKotlinType.canBeNull(session: FirSession): Boolean {
|
||||
it.coneType.fullyExpandedType(session).canBeNull(session)
|
||||
}
|
||||
is ConeIntersectionType -> intersectedTypes.all { it.canBeNull(session) }
|
||||
is ConeCapturedType -> constructor.supertypes?.all { it.canBeNull(session) } == true
|
||||
else -> fullyExpandedType(session).isNullable
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user