Use correct class file version when copying anonymous objects in inliner
Generally, using state.classFileVersion would be enough because we report an error when inlining bytecode into a class file with a lower target version (see INLINE_FROM_HIGHER_PLATFORM). However, we take maxOf with the original version of the class file, _just in case_ the user has suppressed this error (for example, to workaround some other corner case in the compiler). #KT-30744 Fixed
This commit is contained in:
+1
-1
@@ -59,7 +59,7 @@ class AnonymousObjectTransformer(
|
||||
|
||||
createClassReader().accept(object : ClassVisitor(Opcodes.API_VERSION, classBuilder.visitor) {
|
||||
override fun visit(version: Int, access: Int, name: String, signature: String?, superName: String, interfaces: Array<String>) {
|
||||
classBuilder.defineClass(null, version, access, name, signature, superName, interfaces)
|
||||
classBuilder.defineClass(null, maxOf(version, state.classFileVersion), access, name, signature, superName, interfaces)
|
||||
if (languageVersionSettings.isCoroutineSuperClass(superName)) {
|
||||
inliningContext.isContinuation = true
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class WhenMappingTransformer(
|
||||
val fieldNode = transformationInfo.fieldNode
|
||||
classReader.accept(object : ClassVisitor(Opcodes.API_VERSION, classBuilder.visitor) {
|
||||
override fun visit(version: Int, access: Int, name: String, signature: String?, superName: String, interfaces: Array<String>) {
|
||||
classBuilder.defineClass(null, version, access, name, signature, superName, interfaces)
|
||||
classBuilder.defineClass(null, maxOf(version, state.classFileVersion), access, name, signature, superName, interfaces)
|
||||
}
|
||||
|
||||
override fun visitField(access: Int, name: String, desc: String, signature: String?, value: Any?): FieldVisitor? {
|
||||
|
||||
@@ -61,7 +61,7 @@ class SamWrapperTransformer(transformationInfo: SamWrapperTransformationInfo, pr
|
||||
|
||||
classReader.accept(object : ClassVisitor(Opcodes.API_VERSION, classBuilder.visitor) {
|
||||
override fun visit(version: Int, access: Int, name: String, signature: String?, superName: String, interfaces: Array<String>) {
|
||||
classBuilder.defineClass(null, version, access, name, signature, superName, interfaces)
|
||||
classBuilder.defineClass(null, maxOf(version, state.classFileVersion), access, name, signature, superName, interfaces)
|
||||
}
|
||||
|
||||
}, ClassReader.SKIP_FRAMES)
|
||||
@@ -69,4 +69,4 @@ class SamWrapperTransformer(transformationInfo: SamWrapperTransformationInfo, pr
|
||||
|
||||
return transformationResult
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user