[kotlin compiler] 1.2.50-dev-321
- Fix code after type argument refactoring in Kotlin (cherry picked from commit e6b9131910d5440272e6613856365a8277b1f58d)
This commit is contained in:
committed by
Vasily Levchenko
parent
21079ae644
commit
063ccf07f3
+1
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.backend.konan.irasdescriptors.referenceAllTypeExtern
|
||||
import org.jetbrains.kotlin.backend.konan.lower.*
|
||||
import org.jetbrains.kotlin.backend.konan.lower.DefaultArgumentStubGenerator
|
||||
import org.jetbrains.kotlin.backend.konan.lower.DefaultParameterInjector
|
||||
import org.jetbrains.kotlin.backend.konan.lower.InitializersLowering
|
||||
import org.jetbrains.kotlin.backend.konan.lower.LateinitLowering
|
||||
import org.jetbrains.kotlin.backend.konan.lower.LocalDeclarationsLowering
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
|
||||
+8
-3
@@ -196,12 +196,17 @@ internal class IrPrivateFunctionCallImpl(startOffset: Int,
|
||||
type: KotlinType,
|
||||
override val symbol: IrFunctionSymbol,
|
||||
override val descriptor: FunctionDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
typeArgumentsCount: Int,
|
||||
override val moduleDescriptor: ModuleDescriptor,
|
||||
override val totalFunctions: Int,
|
||||
override val functionIndex: Int
|
||||
) : IrPrivateFunctionCall,
|
||||
IrCallWithIndexedArgumentsBase(startOffset, endOffset, type, symbol.descriptor.valueParameters.size, typeArguments) {
|
||||
) : IrPrivateFunctionCall, IrCallWithIndexedArgumentsBase(
|
||||
startOffset,
|
||||
endOffset,
|
||||
type,
|
||||
typeArgumentsCount = typeArgumentsCount,
|
||||
valueArgumentsCount = symbol.descriptor.valueParameters.size
|
||||
) {
|
||||
|
||||
override val superQualifierSymbol: IrClassSymbol?
|
||||
get() = null
|
||||
|
||||
+14
-15
@@ -487,11 +487,14 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr
|
||||
startOffset = expression.startOffset,
|
||||
endOffset = expression.endOffset,
|
||||
type = newDescriptor.returnType!!,
|
||||
calleeDescriptor = newDescriptor,
|
||||
typeArguments = substituteTypeArguments(expression.transformTypeArguments(newDescriptor)),
|
||||
descriptor = newDescriptor,
|
||||
typeArgumentsCount = expression.typeArgumentsCount,
|
||||
origin = expression.origin,
|
||||
superQualifierDescriptor = mapSuperQualifier(expression.superQualifier)
|
||||
).transformValueArguments(expression)
|
||||
).apply {
|
||||
transformValueArguments(expression)
|
||||
substituteTypeArguments(expression)
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------//
|
||||
@@ -622,18 +625,12 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun substituteTypeArguments(oldTypeArguments: Map <TypeParameterDescriptor, KotlinType>?): Map <TypeParameterDescriptor, KotlinType>? {
|
||||
|
||||
if (oldTypeArguments == null) return null
|
||||
if (typeSubstitutor == null) return oldTypeArguments
|
||||
|
||||
val newTypeArguments = oldTypeArguments.entries.associate {
|
||||
val typeParameterDescriptor = it.key
|
||||
val oldTypeArgument = it.value
|
||||
val newTypeArgument = substituteType(oldTypeArgument)!!
|
||||
typeParameterDescriptor to newTypeArgument
|
||||
private fun IrMemberAccessExpression.substituteTypeArguments(original: IrMemberAccessExpression) {
|
||||
for (index in 0 until original.typeArgumentsCount) {
|
||||
val originalTypeArgument = original.getTypeArgument(index)
|
||||
val newTypeArgument = substituteType(originalTypeArgument)!!
|
||||
this.putTypeArgument(index, newTypeArgument)
|
||||
}
|
||||
return newTypeArguments
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
@@ -745,10 +742,12 @@ class DescriptorSubstitutorForExternalScope(val globalSubstituteMap: MutableMap<
|
||||
type = newDescriptor.returnType!!,
|
||||
symbol = createFunctionSymbol(newDescriptor),
|
||||
descriptor = newDescriptor,
|
||||
typeArguments = oldExpression.typeArguments,
|
||||
typeArgumentsCount = oldExpression.typeArgumentsCount,
|
||||
origin = oldExpression.origin,
|
||||
superQualifierSymbol = createClassSymbolOrNull(oldExpression.superQualifier)
|
||||
).apply {
|
||||
copyTypeArgumentsFrom(oldExpression)
|
||||
|
||||
oldExpression.descriptor.valueParameters.forEach {
|
||||
val valueArgument = oldExpression.getValueArgument(it)
|
||||
putValueArgument(it.index, valueArgument)
|
||||
|
||||
+7
-4
@@ -47,6 +47,8 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.calls.components.hasDefaultValue
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||
import org.jetbrains.kotlin.types.TypeConstructor
|
||||
import org.jetbrains.kotlin.types.TypeProjection
|
||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
|
||||
@@ -241,12 +243,13 @@ private class Inliner(val globalSubstituteMap: MutableMap<DeclarationDescriptor,
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun createTypeSubstitutor(irCall: IrCall): TypeSubstitutor? {
|
||||
val typeArgumentsMap = (irCall as IrMemberAccessExpressionBase).typeArguments
|
||||
if (typeArgumentsMap == null) return null
|
||||
if (irCall.typeArgumentsCount == 0) return null
|
||||
val descriptor = irCall.descriptor.resolveFakeOverride().original
|
||||
val typeParameters = descriptor.propertyIfAccessor.typeParameters
|
||||
val substitutionContext = typeArgumentsMap.entries.associate { (typeParameter, typeArgument) ->
|
||||
typeParameters[typeParameter.index].typeConstructor to TypeProjectionImpl(typeArgument)
|
||||
val substitutionContext = mutableMapOf<TypeConstructor, TypeProjection>()
|
||||
for (index in 0 until irCall.typeArgumentsCount) {
|
||||
val typeArgument = irCall.getTypeArgument(index) ?: continue
|
||||
substitutionContext[typeParameters[index].typeConstructor] = TypeProjectionImpl(typeArgument)
|
||||
}
|
||||
return TypeSubstitutor.create(substitutionContext)
|
||||
}
|
||||
|
||||
+5
-2
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.copyTypeArgumentsFrom
|
||||
import org.jetbrains.kotlin.ir.expressions.getValueArgument
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBranchImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||
@@ -1025,11 +1026,13 @@ internal object Devirtualization {
|
||||
type = actualType,
|
||||
symbol = callee.symbol,
|
||||
descriptor = callee.descriptor,
|
||||
typeArguments = (callee as? IrCallImpl)?.typeArguments,
|
||||
typeArgumentsCount = callee.typeArgumentsCount,
|
||||
moduleDescriptor = devirtualizedCallee.module.descriptor,
|
||||
totalFunctions = devirtualizedCallee.module.numberOfFunctions,
|
||||
functionIndex = devirtualizedCallee.symbolTableIndex
|
||||
)
|
||||
).apply {
|
||||
copyTypeArgumentsFrom(callee)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ remoteRoot=konan_tests
|
||||
#kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-SNAPSHOT
|
||||
# Download artifacts of https://teamcity.jetbrains.com/viewType.html?buildTypeId=Kotlin_120_Compiler
|
||||
testDataVersion=1226829:id
|
||||
kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_CompilerAllPlugins),number:1.2.50-dev-139,tag:kotlin-native,pinned:true/artifacts/content/maven
|
||||
kotlinVersion=1.2.50-dev-139
|
||||
kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_dev_CompilerAllPlugins),number:1.2.50-dev-321,tag:kotlin-native,pinned:true/artifacts/content/maven
|
||||
kotlinVersion=1.2.50-dev-321
|
||||
konanVersion=0.6.2
|
||||
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user