JVM IR: support mutability-flexible types

This commit is contained in:
Alexander Udalov
2021-06-02 20:02:07 +02:00
parent 0cb905a4b1
commit 7306256127
21 changed files with 149 additions and 87 deletions
@@ -174,12 +174,11 @@ object FlexibleTypeBoundsChecker {
return possiblePairBound == b.constructor.declarationDescriptor?.fqNameSafe
}
// We consider base bounds as not mutable collections
fun getBaseBoundFqNameByMutability(a: KotlinType): FqName? {
val fqName = a.constructor.declarationDescriptor?.fqNameSafe ?: return null
// We consider base bounds as readonly collection interfaces (e.g. kotlin.collections.Iterable).
fun getBaseBoundFqNameByMutability(type: KotlinType): FqName? =
type.constructor.declarationDescriptor?.fqNameSafe?.let(::getBaseBoundFqNameByMutability)
if (fqName in baseTypesToMutableEquivalent) return fqName
return mutableToBaseMap[fqName]
}
fun getBaseBoundFqNameByMutability(fqName: FqName): FqName? =
if (fqName in baseTypesToMutableEquivalent) fqName
else mutableToBaseMap[fqName]
}