[FE] Reuse result of approximate calls in approximation of captured type
#KTIJ-28549 Fixed
This commit is contained in:
committed by
Space Team
parent
8fcf91d8ef
commit
45f5672b50
+5
-6
@@ -319,6 +319,9 @@ abstract class AbstractTypeApproximator(
|
|||||||
}
|
}
|
||||||
val baseSubType = type.lowerType() ?: nothingType()
|
val baseSubType = type.lowerType() ?: nothingType()
|
||||||
|
|
||||||
|
val approximatedSuperType by lazy(LazyThreadSafetyMode.NONE) { approximateToSuperType(baseSuperType, conf, depth) }
|
||||||
|
val approximatedSubType by lazy(LazyThreadSafetyMode.NONE) { approximateToSubType(baseSubType, conf, depth) }
|
||||||
|
|
||||||
if (!conf.capturedType(ctx, type)) {
|
if (!conf.capturedType(ctx, type)) {
|
||||||
/**
|
/**
|
||||||
* Here everything is ok if bounds for this captured type should not be approximated.
|
* Here everything is ok if bounds for this captured type should not be approximated.
|
||||||
@@ -328,15 +331,11 @@ abstract class AbstractTypeApproximator(
|
|||||||
*
|
*
|
||||||
* todo handle flexible types
|
* todo handle flexible types
|
||||||
*/
|
*/
|
||||||
if (approximateToSuperType(baseSuperType, conf, depth) == null && approximateToSubType(baseSubType, conf, depth) == null) {
|
if (approximatedSuperType == null && approximatedSubType == null) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val baseResult = if (toSuper) approximateToSuperType(baseSuperType, conf, depth) ?: baseSuperType else approximateToSubType(
|
val baseResult = if (toSuper) approximatedSuperType ?: baseSuperType else approximatedSubType ?: baseSubType
|
||||||
baseSubType,
|
|
||||||
conf,
|
|
||||||
depth
|
|
||||||
) ?: baseSubType
|
|
||||||
|
|
||||||
// C = in Int, Int <: C => Int? <: C?
|
// C = in Int, Int <: C => Int? <: C?
|
||||||
// C = out Number, C <: Number => C? <: Number?
|
// C = out Number, C <: Number => C? <: Number?
|
||||||
|
|||||||
Reference in New Issue
Block a user