Fix JVM_IR backend crashes when compiling for Android
^KT-23963 Fixed ^KT-23968 FIxed ^KT-23972 Fixed
This commit is contained in:
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.ir.util.ReferenceSymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.referenceFunction
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.components.isVararg
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
|
||||
@@ -109,7 +110,10 @@ abstract class Symbols<out T : CommonBackendContext>(val context: T, private val
|
||||
val arrayOf = symbolTable.referenceSimpleFunction(
|
||||
builtInsPackage("kotlin").getContributedFunctions(
|
||||
Name.identifier("arrayOf"), NoLookupLocation.FROM_BACKEND
|
||||
).single()
|
||||
).first {
|
||||
it.extensionReceiverParameter == null && it.dispatchReceiverParameter == null && it.valueParameters.size == 1 &&
|
||||
it.valueParameters[0].isVararg
|
||||
}
|
||||
)
|
||||
|
||||
val array = symbolTable.referenceClass(builtIns.array)
|
||||
@@ -142,7 +146,7 @@ abstract class Symbols<out T : CommonBackendContext>(val context: T, private val
|
||||
protected fun arrayExtensionFun(type: KotlinType, name: String): IrSimpleFunctionSymbol {
|
||||
val descriptor = builtInsPackage("kotlin")
|
||||
.getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_BACKEND)
|
||||
.singleOrNull {
|
||||
.firstOrNull {
|
||||
it.valueParameters.isEmpty()
|
||||
&& (it.extensionReceiverParameter?.type?.constructor?.declarationDescriptor as? ClassDescriptor)?.defaultType == type
|
||||
}
|
||||
@@ -152,20 +156,6 @@ abstract class Symbols<out T : CommonBackendContext>(val context: T, private val
|
||||
|
||||
abstract val copyRangeTo: Map<ClassDescriptor, IrSimpleFunctionSymbol>
|
||||
|
||||
val intAnd = symbolTable.referenceSimpleFunction(
|
||||
builtIns.intType.memberScope
|
||||
.getContributedFunctions(OperatorNameConventions.AND, NoLookupLocation.FROM_BACKEND)
|
||||
.single()
|
||||
)
|
||||
|
||||
val intPlusInt = symbolTable.referenceSimpleFunction(
|
||||
builtIns.intType.memberScope
|
||||
.getContributedFunctions(OperatorNameConventions.PLUS, NoLookupLocation.FROM_BACKEND)
|
||||
.single {
|
||||
it.valueParameters.single().type == builtIns.intType
|
||||
}
|
||||
)
|
||||
|
||||
// val valuesForEnum = symbolTable.referenceSimpleFunction(
|
||||
// context.getInternalFunctions("valuesForEnum").single())
|
||||
//
|
||||
@@ -179,22 +169,11 @@ abstract class Symbols<out T : CommonBackendContext>(val context: T, private val
|
||||
|
||||
abstract val coroutineSuspendedGetter: IrSimpleFunctionSymbol
|
||||
|
||||
val kFunctionImpl = calc { symbolTable.referenceClass(context.reflectionTypes.kFunctionImpl) }
|
||||
|
||||
val functionReference = calc { symbolTable.referenceClass(context.getInternalClass("FunctionReference")) }
|
||||
|
||||
val kProperty0Impl = calc { symbolTable.referenceClass(context.reflectionTypes.kProperty0Impl) }
|
||||
val kProperty1Impl = calc { symbolTable.referenceClass(context.reflectionTypes.kProperty1Impl) }
|
||||
val kProperty2Impl = calc { symbolTable.referenceClass(context.reflectionTypes.kProperty2Impl) }
|
||||
val kMutableProperty0Impl = calc { symbolTable.referenceClass(context.reflectionTypes.kMutableProperty0Impl) }
|
||||
val kMutableProperty1Impl = calc { symbolTable.referenceClass(context.reflectionTypes.kMutableProperty1Impl) }
|
||||
val kMutableProperty2Impl = calc { symbolTable.referenceClass(context.reflectionTypes.kMutableProperty2Impl) }
|
||||
// val kLocalDelegatedPropertyImpl = symbolTable.referenceClass(context.reflectionTypes.kLocalDelegatedPropertyImpl)
|
||||
// val kLocalDelegatedMutablePropertyImpl = symbolTable.referenceClass(context.reflectionTypes.kLocalDelegatedMutablePropertyImpl)
|
||||
|
||||
fun getFunction(name: Name, receiverType: KotlinType, vararg argTypes: KotlinType) =
|
||||
symbolTable.referenceFunction(receiverType.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_BACKEND)
|
||||
.single {
|
||||
.first {
|
||||
var i = 0
|
||||
it.valueParameters.size == argTypes.size && it.valueParameters.all { type -> type == argTypes[i++] }
|
||||
}
|
||||
@@ -206,7 +185,7 @@ abstract class Symbols<out T : CommonBackendContext>(val context: T, private val
|
||||
var result = binaryOperatorCache[key]
|
||||
if (result == null) {
|
||||
result = symbolTable.referenceFunction(lhsType.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_BACKEND)
|
||||
.single { it.valueParameters.size == 1 && it.valueParameters[0].type == rhsType }
|
||||
.first { it.valueParameters.size == 1 && it.valueParameters[0].type == rhsType }
|
||||
)
|
||||
binaryOperatorCache[key] = result
|
||||
}
|
||||
@@ -219,10 +198,13 @@ abstract class Symbols<out T : CommonBackendContext>(val context: T, private val
|
||||
var result = unaryOperatorCache[key]
|
||||
if (result == null) {
|
||||
result = symbolTable.referenceFunction(receiverType.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_BACKEND)
|
||||
.single { it.valueParameters.isEmpty() }
|
||||
.first { it.valueParameters.isEmpty() }
|
||||
)
|
||||
unaryOperatorCache[key] = result
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
val intAnd = getBinaryOperator(OperatorNameConventions.AND, builtIns.intType, builtIns.intType)
|
||||
val intPlusInt = getBinaryOperator(OperatorNameConventions.PLUS, builtIns.intType, builtIns.intType)
|
||||
}
|
||||
+1
-1
@@ -45,7 +45,7 @@ class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
||||
fun transform(delegatingConstructorCall: IrDelegatingConstructorCall): IrExpression
|
||||
}
|
||||
|
||||
private val unsubstitutedArrayOfFun = context.builtIns.findSingleFunction(Name.identifier("arrayOf"))
|
||||
private val unsubstitutedArrayOfFun = context.ir.symbols.arrayOf.descriptor
|
||||
|
||||
private fun createArrayOfExpression(arrayElementType: KotlinType, arrayElements: List<IrExpression>): IrExpression {
|
||||
val typeParameter0 = unsubstitutedArrayOfFun.typeParameters[0]
|
||||
|
||||
Reference in New Issue
Block a user