[K/N] Get rid of ArrayAsList class, use .asList() instead
^KT-57137
This commit is contained in:
committed by
Space Team
parent
967ddb8bb0
commit
8f4c6eae2f
-3
@@ -406,9 +406,6 @@ internal abstract class KonanSymbols(
|
||||
val kTypeImplForTypeParametersWithRecursiveBounds = internalClass("KTypeImplForTypeParametersWithRecursiveBounds")
|
||||
val kTypeProjectionList = internalClass("KTypeProjectionList")
|
||||
|
||||
|
||||
val arrayAsList = internalClass("ArrayAsList")
|
||||
|
||||
val threadLocal = topLevelClass(KonanFqNames.threadLocal)
|
||||
|
||||
val sharedImmutable = topLevelClass(KonanFqNames.sharedImmutable)
|
||||
|
||||
+3
-6
@@ -108,7 +108,7 @@ internal class KTypeGenerator(
|
||||
val result = irConstantObject(symbols.kTypeParameterImpl.owner, mapOf(
|
||||
"name" to irConstantString(typeParameter.name.asString()),
|
||||
"containerFqName" to irConstantString(typeParameter.parentUniqueName),
|
||||
"upperBounds" to irKTypeList(typeParameter.superTypes, leaveReifiedForLater, seenTypeParameters),
|
||||
"upperBoundsArray" to irKTypeArray(typeParameter.superTypes, leaveReifiedForLater, seenTypeParameters),
|
||||
"varianceId" to irConstantInt(mapVariance(typeParameter.variance)),
|
||||
"isReified" to irConstantBoolean(typeParameter.isReified),
|
||||
))
|
||||
@@ -122,18 +122,15 @@ internal class KTypeGenerator(
|
||||
else -> parent.fqNameForIrSerialization.asString()
|
||||
}
|
||||
|
||||
private fun IrBuilderWithScope.irKTypeList(
|
||||
private fun IrBuilderWithScope.irKTypeArray(
|
||||
types: List<IrType>,
|
||||
leaveReifiedForLater: Boolean,
|
||||
seenTypeParameters: MutableSet<IrTypeParameter>
|
||||
): IrConstantValue {
|
||||
val itemType = symbols.kType.defaultType
|
||||
val elements = irConstantArray(symbols.array.typeWith(itemType),
|
||||
return irConstantArray(symbols.array.typeWith(itemType),
|
||||
types.map { irKType(it, leaveReifiedForLater, seenTypeParameters) }
|
||||
)
|
||||
return irConstantObject(symbols.arrayAsList.owner, mapOf(
|
||||
"array" to elements
|
||||
))
|
||||
}
|
||||
|
||||
// this constants are copypasted from KVarianceMapper.Companion in KTypeImpl.kt
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin.native.internal
|
||||
|
||||
class ArrayAsList<T>(val array: Array<T>) : AbstractList<T>(), RandomAccess {
|
||||
override val size: Int get() = array.size
|
||||
override fun isEmpty(): Boolean = array.isEmpty()
|
||||
override fun contains(element: T): Boolean = array.contains(element)
|
||||
override fun get(index: Int): T = array[index]
|
||||
override fun indexOf(element: T): Int = array.indexOf(element)
|
||||
override fun lastIndexOf(element: T): Int = array.lastIndexOf(element)
|
||||
}
|
||||
@@ -10,16 +10,15 @@ import kotlin.reflect.*
|
||||
internal class KTypeParameterImpl(
|
||||
override val name: String,
|
||||
private val containerFqName: String,
|
||||
override val upperBounds: List<KType>,
|
||||
private val upperBoundsArray: Array<KType>,
|
||||
val varianceId: Int, // mapping is used to make static initialization possible
|
||||
override val isReified: Boolean
|
||||
) : KTypeParameter {
|
||||
override val upperBounds: List<KType>
|
||||
get() = upperBoundsArray.asList()
|
||||
override val variance: KVariance
|
||||
get() = KVarianceMapper.varianceById(varianceId)!!
|
||||
|
||||
constructor(name: String, containerFqName: String, upperBounds: List<KType>, variance: KVariance, isReified: Boolean) :
|
||||
this(name, containerFqName, upperBounds, KVarianceMapper.idByVariance(variance), isReified)
|
||||
|
||||
override fun toString(): String = when (variance) {
|
||||
KVariance.INVARIANT -> ""
|
||||
KVariance.IN -> "in "
|
||||
|
||||
Reference in New Issue
Block a user