FIR: Implement fast path for classes subtyping

This commit is contained in:
Denis Zharkov
2019-06-20 12:50:50 +03:00
parent cafe92639b
commit bf0781d790
8 changed files with 138 additions and 12 deletions
@@ -17,7 +17,7 @@ import java.util.*
abstract class AbstractTypeCheckerContext : TypeSystemContext {
abstract fun substitutionSupertypePolicy(type: SimpleTypeMarker): SupertypesPolicy.DoCustomTransform
abstract fun substitutionSupertypePolicy(type: SimpleTypeMarker): SupertypesPolicy
abstract fun areEqualTypeConstructors(a: TypeConstructorMarker, b: TypeConstructorMarker): Boolean
@@ -379,6 +379,10 @@ object AbstractTypeChecker {
baseType: SimpleTypeMarker,
constructor: TypeConstructorMarker
): List<SimpleTypeMarker> {
baseType.fastCorrespondingSupertypes(constructor)?.let {
return it
}
if (constructor.isCommonFinalClassConstructor()) {
return if (areEqualTypeConstructors(baseType.typeConstructor(), constructor))
listOf(captureFromArguments(baseType, CaptureStatus.FOR_SUBTYPING) ?: baseType)
@@ -219,6 +219,8 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
fun SimpleTypeMarker.isClassType(): Boolean = typeConstructor().isClassTypeConstructor()
fun SimpleTypeMarker.fastCorrespondingSupertypes(constructor: TypeConstructorMarker): List<SimpleTypeMarker>? = null
fun SimpleTypeMarker.isIntegerLiteralType(): Boolean = typeConstructor().isIntegerLiteralTypeConstructor()
fun SimpleTypeMarker.possibleIntegerTypes(): Collection<KotlinTypeMarker>
@@ -290,4 +292,4 @@ inline fun TypeArgumentListMarker.all(
if (!predicate(get(index))) return false
}
return true
}
}