KT-55398 Fix nested inline variable not correctly
^KT-55398 Fixed Add nested variable's ReifiedTypeParametersUsages into closureReifiedMarkers for MethodInliner to generate nested inline anonymous class
This commit is contained in:
committed by
teamcity
parent
b6e6ca7c96
commit
22a9b84966
+1
-22
@@ -38,7 +38,6 @@ import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
@@ -209,7 +208,7 @@ class ClassCodegen private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
addReifiedParametersFromSignature()
|
||||
reifiedTypeParametersUsages.mergeAll(irClass.reifiedTypeParameters)
|
||||
|
||||
generateInnerAndOuterClasses()
|
||||
|
||||
@@ -234,26 +233,6 @@ class ClassCodegen private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun addReifiedParametersFromSignature() {
|
||||
for (type in irClass.superTypes) {
|
||||
processTypeParameters(type)
|
||||
}
|
||||
}
|
||||
|
||||
private fun processTypeParameters(type: IrType) {
|
||||
for (supertypeArgument in (type as? IrSimpleType)?.arguments ?: emptyList()) {
|
||||
if (supertypeArgument is IrTypeProjection) {
|
||||
val typeArgument = supertypeArgument.type
|
||||
if (typeArgument.isReifiedTypeParameter) {
|
||||
val typeParameter = typeArgument.classifierOrFail as IrTypeParameterSymbol
|
||||
reifiedTypeParametersUsages.addUsedReifiedParameter(typeParameter.owner.name.asString())
|
||||
} else {
|
||||
processTypeParameters(typeArgument)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun generateAssertFieldIfNeeded(generatingClInit: Boolean): IrExpression? {
|
||||
if (irClass.hasAssertionsDisabledField(context))
|
||||
return null
|
||||
|
||||
+2
-4
@@ -866,7 +866,8 @@ class ExpressionCodegen(
|
||||
}
|
||||
|
||||
private fun putNeedClassReificationMarker(declaration: IrClass) {
|
||||
val reifiedTypeParameters = closureReifiedMarkers[declaration] ?: return
|
||||
// Fix KT-55398, try to get nested irclass type parameters reified info
|
||||
val reifiedTypeParameters = closureReifiedMarkers.getOrPut(declaration) { declaration.reifiedTypeParameters }
|
||||
if (reifiedTypeParameters.wereUsedReifiedParameters()) {
|
||||
putNeedClassReificationMarker(mv)
|
||||
propagateChildReifiedTypeParametersUsages(reifiedTypeParameters)
|
||||
@@ -1501,9 +1502,6 @@ class ExpressionCodegen(
|
||||
val isFinallyMarkerRequired: Boolean
|
||||
get() = irFunction.isInline || irFunction.origin == JvmLoweredDeclarationOrigin.INLINE_LAMBDA
|
||||
|
||||
val IrType.isReifiedTypeParameter: Boolean
|
||||
get() = (classifierOrNull as? IrTypeParameterSymbol)?.owner?.isReified == true
|
||||
|
||||
companion object {
|
||||
internal fun generateClassInstance(v: InstructionAdapter, classType: IrType, typeMapper: IrTypeMapper, wrapPrimitives: Boolean) {
|
||||
val asmType = typeMapper.mapType(classType)
|
||||
|
||||
+28
-7
@@ -8,10 +8,7 @@ package org.jetbrains.kotlin.backend.jvm.codegen
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.MultifileFacadeFileEntry
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.fileParent
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.isInlineOnly
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.isJvmInterface
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.isPrivateInlineSuspend
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.*
|
||||
import org.jetbrains.kotlin.backend.jvm.mapping.IrTypeMapper
|
||||
import org.jetbrains.kotlin.backend.jvm.mapping.mapClass
|
||||
import org.jetbrains.kotlin.backend.jvm.mapping.mapSupertype
|
||||
@@ -21,6 +18,7 @@ import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.codegen.FrameMapBase
|
||||
import org.jetbrains.kotlin.codegen.OwnerKind
|
||||
import org.jetbrains.kotlin.codegen.SourceInfo
|
||||
import org.jetbrains.kotlin.codegen.inline.ReifiedTypeParametersUsages
|
||||
import org.jetbrains.kotlin.codegen.inline.SourceMapper
|
||||
import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
@@ -30,9 +28,8 @@ import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||
import org.jetbrains.kotlin.ir.types.getClass
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -320,3 +317,27 @@ private fun IrFunction.isAccessorForDeprecatedJvmStaticProperty(context: JvmBack
|
||||
val property = callee.correspondingPropertySymbol?.owner ?: return false
|
||||
return property.isDeprecatedCallable(context)
|
||||
}
|
||||
|
||||
val IrClass.reifiedTypeParameters: ReifiedTypeParametersUsages
|
||||
get() {
|
||||
val tempReifiedTypeParametersUsages = ReifiedTypeParametersUsages()
|
||||
fun processTypeParameters(type: IrType) {
|
||||
for (supertypeArgument in (type as? IrSimpleType)?.arguments ?: emptyList()) {
|
||||
if (supertypeArgument is IrTypeProjection) {
|
||||
val typeArgument = supertypeArgument.type
|
||||
if (typeArgument.isReifiedTypeParameter) {
|
||||
val typeParameter = typeArgument.classifierOrFail as IrTypeParameterSymbol
|
||||
tempReifiedTypeParametersUsages.addUsedReifiedParameter(typeParameter.owner.name.asString())
|
||||
} else {
|
||||
processTypeParameters(typeArgument)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (type in superTypes) {
|
||||
processTypeParameters(type)
|
||||
}
|
||||
|
||||
return tempReifiedTypeParametersUsages
|
||||
}
|
||||
|
||||
+1
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.backend.jvm.codegen.BlockInfo
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.MaterialValue
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.materializedAt
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.isReifiedTypeParameter
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.codegen.inline.ReifiedTypeInliner
|
||||
import org.jetbrains.kotlin.codegen.putReifiedOperationMarkerIfTypeIsReifiedParameter
|
||||
|
||||
Reference in New Issue
Block a user