K2: Imitate K1 behavior for case of captured types with a raw supertype

See the comments in the code, but mostly the motivation is that once
it was decided to stick with such a legacy thing as raw types,
we are ok with some corner-cases hacks for them
(if there are not too many of them) and they don't break anything
when there are no raw types in the code.

^KT-56616 Fixed
This commit is contained in:
Denis.Zharkov
2023-02-22 13:45:53 +01:00
committed by Space Team
parent eb09a25239
commit 608cb01935
14 changed files with 172 additions and 44 deletions
@@ -312,6 +312,11 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
*/
fun useRefinedBoundsForTypeVariableInFlexiblePosition(): Boolean
/**
* It's only relevant for K2 (and is not expected to be implemented properly in other contexts)
*/
fun KotlinTypeMarker.convertToNonRaw(): KotlinTypeMarker
fun createCapturedStarProjectionForSelfType(
typeVariable: TypeVariableTypeConstructorMarker,
typesForRecursiveTypeParameters: List<KotlinTypeMarker>,
@@ -357,6 +362,7 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
fun FlexibleTypeMarker.asDynamicType(): DynamicTypeMarker?
fun KotlinTypeMarker.isRawType(): Boolean
fun FlexibleTypeMarker.upperBound(): SimpleTypeMarker
fun FlexibleTypeMarker.lowerBound(): SimpleTypeMarker
@@ -158,6 +158,10 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
return this is RawType
}
override fun KotlinTypeMarker.convertToNonRaw(): KotlinTypeMarker {
error("Is not expected to be called in K1")
}
override fun FlexibleTypeMarker.upperBound(): SimpleTypeMarker {
require(this is FlexibleType, this::errorMessage)
return this.upperBound