Skip to content

Commit 14756c3

Browse files
dzharkovSpace Team
authored andcommitted
FE: Minor. Extract AbstractTypeApproximator.approximateEntryPoint
1 parent fc402cf commit 14756c3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,26 @@ abstract class AbstractTypeApproximator(
8181
conf: TypeApproximatorConfiguration,
8282
caches: TypeApproximatorCachesPerConfiguration? = null,
8383
): KotlinTypeMarker? {
84-
return context(conf, caches?.getOrPut(conf, ::Cache) ?: Cache()) {
85-
approximateToSuperType(type, -type.typeDepthForApproximation())
86-
}
84+
return approximateEntryPoint(type, conf, caches) { type, depth -> approximateToSuperType(type, depth) }
8785
}
8886

8987
// resultType <: type
9088
fun approximateToSubType(
9189
type: KotlinTypeMarker,
9290
conf: TypeApproximatorConfiguration,
9391
caches: TypeApproximatorCachesPerConfiguration? = null,
92+
): KotlinTypeMarker? {
93+
return approximateEntryPoint(type, conf, caches) { type, depth -> approximateToSubType(type, depth) }
94+
}
95+
96+
private inline fun approximateEntryPoint(
97+
type: KotlinTypeMarker,
98+
conf: TypeApproximatorConfiguration,
99+
caches: TypeApproximatorCachesPerConfiguration?,
100+
approximateTo: context(TypeApproximatorConfiguration, Cache) (KotlinTypeMarker, Int) -> KotlinTypeMarker?,
94101
): KotlinTypeMarker? {
95102
return context(conf, caches?.getOrPut(conf, ::Cache) ?: Cache()) {
96-
approximateToSubType(type, -type.typeDepthForApproximation())
103+
approximateTo(type, -type.typeDepthForApproximation())
97104
}
98105
}
99106

0 commit comments

Comments
 (0)