Optimize ConeInferenceContext.typeDepth a bit
This commit is contained in:
@@ -121,6 +121,13 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
|||||||
require(this is ConeKotlinType)
|
require(this is ConeKotlinType)
|
||||||
// if (this is TypeUtils.SpecialType) return 0 // TODO: WTF?
|
// if (this is TypeUtils.SpecialType) return 0 // TODO: WTF?
|
||||||
|
|
||||||
|
if (this is ConeClassLikeType) {
|
||||||
|
val fullyExpanded = fullyExpandedType(session)
|
||||||
|
if (this !== fullyExpanded) {
|
||||||
|
return fullyExpanded.typeDepth()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var maxArgumentDepth = 0
|
var maxArgumentDepth = 0
|
||||||
for (arg in typeArguments) {
|
for (arg in typeArguments) {
|
||||||
val current = if (arg is ConeStarProjection) 1 else (arg as ConeKotlinTypeProjection).type.typeDepth()
|
val current = if (arg is ConeStarProjection) 1 else (arg as ConeKotlinTypeProjection).type.typeDepth()
|
||||||
@@ -129,19 +136,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = maxArgumentDepth + 1
|
return maxArgumentDepth + 1
|
||||||
|
|
||||||
if (this is ConeClassLikeType) {
|
|
||||||
val fullyExpanded = fullyExpandedType(session)
|
|
||||||
if (this !== fullyExpanded) {
|
|
||||||
val fullyExpandedTypeDepth = fullyExpanded.typeDepth()
|
|
||||||
if (fullyExpandedTypeDepth > result) {
|
|
||||||
result = fullyExpandedTypeDepth
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun KotlinTypeMarker.contains(predicate: (KotlinTypeMarker) -> Boolean): Boolean {
|
override fun KotlinTypeMarker.contains(predicate: (KotlinTypeMarker) -> Boolean): Boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user