[JVM_IR] Limit inner class attributes to types in class file (#5081)
* [JVM_IR] Limit inner class attributes to types in class file Inner class attributes should only be recorded for types that are materialized in the result class file. In particular, we should not emit inner classes attributes for types that appear only in fake overrides. We do map these types to track the fake overrides for JVM signature clashes but they are not materialized in the class file. ^KT-56104 Fixed * [JVM_IR] Consistently pass around materialized boolean in mapType.
This commit is contained in:
+6
-3
@@ -86,13 +86,16 @@ class ClassCodegen private constructor(
|
||||
if (context.state.oldInnerClassesLogic)
|
||||
context.defaultTypeMapper
|
||||
else object : IrTypeMapper(context) {
|
||||
override fun mapType(type: IrType, mode: TypeMappingMode, sw: JvmSignatureWriter?): Type {
|
||||
override fun mapType(type: IrType, mode: TypeMappingMode, sw: JvmSignatureWriter?, materialized: Boolean): Type {
|
||||
var t = type
|
||||
while (t.isArray()) {
|
||||
t = t.getArrayElementType(context.irBuiltIns)
|
||||
}
|
||||
t.classOrNull?.owner?.let(::addInnerClassInfo)
|
||||
return super.mapType(type, mode, sw)
|
||||
// Only record inner class info for types that are materialized in the class file.
|
||||
if (materialized) {
|
||||
t.classOrNull?.owner?.let(::addInnerClassInfo)
|
||||
}
|
||||
return super.mapType(type, mode, sw, materialized)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ class JvmSignatureClashDetector(
|
||||
}
|
||||
|
||||
private fun mapRawSignature(irFunction: IrFunction): RawSignature {
|
||||
val jvmSignature = classCodegen.methodSignatureMapper.mapSignatureSkipGeneric(irFunction)
|
||||
val jvmSignature = classCodegen.methodSignatureMapper.mapFakeOverrideSignatureSkipGeneric(irFunction)
|
||||
return RawSignature(jvmSignature.asmMethod.name, jvmSignature.asmMethod.descriptor, MemberKind.METHOD)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user