@@ -81,19 +81,26 @@ abstract class AbstractTypeApproximator(
81
81
conf : TypeApproximatorConfiguration ,
82
82
caches : TypeApproximatorCachesPerConfiguration ? = null,
83
83
): 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) }
87
85
}
88
86
89
87
// resultType <: type
90
88
fun approximateToSubType (
91
89
type : KotlinTypeMarker ,
92
90
conf : TypeApproximatorConfiguration ,
93
91
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 ? ,
94
101
): KotlinTypeMarker ? {
95
102
return context(conf, caches?.getOrPut(conf, ::Cache ) ? : Cache ()) {
96
- approximateToSubType (type, - type.typeDepthForApproximation())
103
+ approximateTo (type, - type.typeDepthForApproximation())
97
104
}
98
105
}
99
106
0 commit comments