[FIR Native] Don't add Cloneable supertype when it's not present

^KT-58549 Fixed
This commit is contained in:
Nikolay Lunyak
2023-06-07 12:06:30 +03:00
committed by Space Team
parent a80d6a7b74
commit 97adb01600
4 changed files with 6 additions and 8 deletions
@@ -211,7 +211,7 @@ internal fun deserializeClassToSymbol(
)
}
addCloneForArrayIfNeeded(classId, context.dispatchReceiver)
addCloneForArrayIfNeeded(classId, context.dispatchReceiver, session)
session.deserializedClassConfigurator?.run {
configure(classId)
}
@@ -13,12 +13,13 @@ import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.builder.*
import org.jetbrains.kotlin.fir.declarations.comparators.FirMemberDeclarationComparator
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl
import org.jetbrains.kotlin.fir.declarations.utils.addDeclarations
import org.jetbrains.kotlin.fir.declarations.utils.isCompanion
import org.jetbrains.kotlin.fir.declarations.utils.moduleName
import org.jetbrains.kotlin.fir.declarations.utils.sourceElement
import org.jetbrains.kotlin.fir.resolve.providers.getRegularClassSymbolByClassId
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
import org.jetbrains.kotlin.fir.symbols.impl.FirEnumEntrySymbol
@@ -199,7 +200,7 @@ fun deserializeClassToSymbol(
generateEntriesGetter(moduleData, classId.packageFqName, classId.relativeClassName)
}
addCloneForArrayIfNeeded(classId, context.dispatchReceiver)
addCloneForArrayIfNeeded(classId, context.dispatchReceiver, session)
session.deserializedClassConfigurator?.run {
configure(classId)
}
@@ -270,9 +271,10 @@ private fun FirRegularClassBuilder.addSerializableIfNeeded(classId: ClassId) {
}
}
fun FirRegularClassBuilder.addCloneForArrayIfNeeded(classId: ClassId, dispatchReceiver: ConeClassLikeType?) {
fun FirRegularClassBuilder.addCloneForArrayIfNeeded(classId: ClassId, dispatchReceiver: ConeClassLikeType?, session: FirSession) {
if (classId.packageFqName != StandardClassIds.BASE_KOTLIN_PACKAGE) return
if (classId.shortClassName !in ARRAY_CLASSES) return
if (session.symbolProvider.getRegularClassSymbolByClassId(StandardClassIds.Cloneable) == null) return
superTypeRefs += buildResolvedTypeRef {
type = ConeClassLikeTypeImpl(
StandardClassIds.Cloneable.toLookupTag(),
@@ -1,6 +1,4 @@
// IGNORE_BACKEND_K2: JS_IR
// KT-58549
// IGNORE_BACKEND_K2: NATIVE
//test [], get and iterator calls
fun test(createIntNotLong: Boolean): String {
-2
View File
@@ -1,6 +1,4 @@
// IGNORE_BACKEND_K2: JS_IR
// KT-58549
// IGNORE_BACKEND_K2: NATIVE
fun test(b: Boolean): String {
val a = if (b) IntArray(5) else LongArray(5)