Put reification markers came from super object signature
#KT-44770 Fixed #KT-30696 Open
This commit is contained in:
+30
-4
@@ -11,11 +11,9 @@ import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.MultifileFacadeFileEntry
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.buildAssertionsDisabledField
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.hasAssertionsDisabledField
|
||||
import org.jetbrains.kotlin.codegen.DescriptorAsmUtil
|
||||
import org.jetbrains.kotlin.codegen.VersionIndependentOpcodes
|
||||
import org.jetbrains.kotlin.codegen.addRecordComponent
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.isReifiedTypeParameter
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
import org.jetbrains.kotlin.codegen.inline.*
|
||||
import org.jetbrains.kotlin.codegen.writeKotlinMetadata
|
||||
import org.jetbrains.kotlin.config.JvmAnalysisFlags
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
@@ -31,6 +29,11 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
|
||||
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.IrSimpleType
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.IrTypeProjection
|
||||
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
@@ -44,6 +47,7 @@ import org.jetbrains.kotlin.resolve.jvm.annotations.VOLATILE_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.jvm.checkers.JvmSimpleNameBacktickChecker
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.*
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmClassSignature
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
import org.jetbrains.org.objectweb.asm.*
|
||||
@@ -165,10 +169,32 @@ class ClassCodegen private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
addReifiedParametersFromSignature()
|
||||
|
||||
visitor.done()
|
||||
jvmSignatureClashDetector.reportErrors(classOrigin)
|
||||
}
|
||||
|
||||
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) {
|
||||
reifiedTypeParametersUsages.addUsedReifiedParameter(typeArgument.classifierOrFail.cast<IrTypeParameterSymbol>().owner.name.asString())
|
||||
} else {
|
||||
processTypeParameters(typeArgument)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun generateAssertFieldIfNeeded(generatingClInit: Boolean): IrExpression? {
|
||||
if (irClass.hasAssertionsDisabledField(context))
|
||||
return null
|
||||
|
||||
+2
-1
@@ -65,7 +65,8 @@ class FunctionCodegen(
|
||||
signature.asmMethod.descriptor,
|
||||
signature.genericsSignature
|
||||
.takeIf {
|
||||
!isSynthetic && irFunction.origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
|
||||
(irFunction.isInline && irFunction.origin != IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER) ||
|
||||
!isSynthetic && irFunction.origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
|
||||
},
|
||||
getThrownExceptions(irFunction)?.toTypedArray()
|
||||
)
|
||||
|
||||
+3
-3
@@ -54,14 +54,14 @@ internal val typeOperatorLowering = makeIrFilePhase(
|
||||
description = "Lower IrTypeOperatorCalls to (implicit) casts and instanceof checks"
|
||||
)
|
||||
|
||||
val IrType.isReifiedTypeParameter: Boolean
|
||||
get() = classifierOrNull?.safeAs<IrTypeParameterSymbol>()?.owner?.isReified == true
|
||||
|
||||
private class TypeOperatorLowering(private val context: JvmBackendContext) : FileLoweringPass, IrBuildingTransformer(context) {
|
||||
override fun lower(irFile: IrFile) = irFile.transformChildrenVoid()
|
||||
|
||||
private fun IrExpression.transformVoid() = transform(this@TypeOperatorLowering, null)
|
||||
|
||||
private val IrType.isReifiedTypeParameter: Boolean
|
||||
get() = classifierOrNull?.safeAs<IrTypeParameterSymbol>()?.owner?.isReified == true
|
||||
|
||||
private fun lowerInstanceOf(argument: IrExpression, type: IrType) = with(builder) {
|
||||
when {
|
||||
type.isReifiedTypeParameter ->
|
||||
|
||||
Reference in New Issue
Block a user