diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt index bca8f12e450..9b787f95642 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt @@ -228,17 +228,6 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass for (member in potentialBridgeTargets) { val parent = member.parentAsClass createBridges(parent, member) - - // For lambda classes, we move overrides from the `invoke` function to its bridge. This will allow us to avoid boxing - // the return type of `invoke` in codegen for lambdas with primitive return type. This does not apply to lambdas returning - // inline class types erasing to Any, which we need to box. - if (member.name == OperatorNameConventions.INVOKE - && (parent.origin == JvmLoweredDeclarationOrigin.LAMBDA_IMPL || - parent.origin == JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL) - && !member.returnType.isInlineClassErasingToAny - ) { - member.overriddenSymbols = emptyList() - } } } @@ -436,6 +425,7 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass returnType = bridge.overridden.returnType.eraseTypeParameters() isSuspend = bridge.overridden.isSuspend }.apply { + copyAttributes(target) copyParametersWithErasure(this@addBridge, bridge.overridden) body = context.createIrBuilder(symbol, startOffset, endOffset).run { irExprBody(delegatingCall(this@apply, target)) } diff --git a/compiler/testData/codegen/bytecodeListing/annotations/kt9320_ir.txt b/compiler/testData/codegen/bytecodeListing/annotations/kt9320_ir.txt new file mode 100644 index 00000000000..a5b9dc7a183 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/annotations/kt9320_ir.txt @@ -0,0 +1,50 @@ +@java.lang.annotation.Retention +@kotlin.Metadata +public annotation class Ann { + // source: 'kt9320.kt' +} + +@kotlin.annotation.Target +@kotlin.annotation.Retention +@java.lang.annotation.Retention +@java.lang.annotation.Target +@kotlin.Metadata +public annotation class AnnExpr { + // source: 'kt9320.kt' +} + +@Ann +@kotlin.Metadata +public final class Kt9320Kt$foo$v$1 { + // source: 'kt9320.kt' + enclosing method Kt9320Kt.foo()V + inner (anonymous) class Kt9320Kt$foo$v$1 + method (): void +} + +@kotlin.Metadata +final class Kt9320Kt$foo$w$1 { + // source: 'kt9320.kt' + enclosing method Kt9320Kt.foo()V + public final static field INSTANCE: Kt9320Kt$foo$w$1 + inner (anonymous) class Kt9320Kt$foo$w$1 + static method (): void + method (): void + public final @Ann @org.jetbrains.annotations.NotNull method invoke(@org.jetbrains.annotations.NotNull p0: My): java.lang.Integer + public synthetic bridge method invoke(p0: java.lang.Object): java.lang.Object +} + +@kotlin.Metadata +public final class Kt9320Kt { + // source: 'kt9320.kt' + inner (anonymous) class Kt9320Kt$foo$v$1 + inner (anonymous) class Kt9320Kt$foo$w$1 + public final static method foo(): void +} + +@Ann +@kotlin.Metadata +public class My { + // source: 'kt9320.kt' + public method (): void +} diff --git a/compiler/testData/codegen/bytecodeListing/annotations/literals_ir.txt b/compiler/testData/codegen/bytecodeListing/annotations/literals_ir.txt new file mode 100644 index 00000000000..9aa40b0e915 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/annotations/literals_ir.txt @@ -0,0 +1,83 @@ +@kotlin.annotation.Target +@java.lang.annotation.Retention +@java.lang.annotation.Target +@kotlin.Metadata +public annotation class ClsAnn { + // source: 'literals.kt' +} + +@kotlin.annotation.Target +@kotlin.annotation.Retention +@java.lang.annotation.Retention +@java.lang.annotation.Target +@kotlin.Metadata +public annotation class ExprAnn { + // source: 'literals.kt' +} + +@kotlin.annotation.Target +@java.lang.annotation.Retention +@java.lang.annotation.Target +@kotlin.Metadata +public annotation class FunAnn { + // source: 'literals.kt' +} + +@kotlin.Metadata +final class LiteralsKt$foo$1 { + // source: 'literals.kt' + enclosing method LiteralsKt.foo(I)LMy; + synthetic final field $arg: int + inner (anonymous) class LiteralsKt$foo$1 + method (p0: int): void + public final @FunAnn @org.jetbrains.annotations.NotNull method invoke(): java.lang.Integer + public synthetic bridge method invoke(): java.lang.Object +} + +@kotlin.Metadata +final class LiteralsKt$foo$2 { + // source: 'literals.kt' + enclosing method LiteralsKt.foo(I)LMy; + synthetic final field $arg: int + inner (anonymous) class LiteralsKt$foo$2 + method (p0: int): void + public final @org.jetbrains.annotations.NotNull method invoke(): java.lang.Integer + public synthetic bridge method invoke(): java.lang.Object +} + +@ClsAnn +@kotlin.Metadata +public final class LiteralsKt$foo$3 { + // source: 'literals.kt' + enclosing method LiteralsKt.foo(I)LMy; + inner (anonymous) class LiteralsKt$foo$3 + method (): void +} + +@kotlin.Metadata +final class LiteralsKt$foo$x$1 { + // source: 'literals.kt' + enclosing method LiteralsKt.foo(I)LMy; + synthetic final field $arg: int + inner (anonymous) class LiteralsKt$foo$x$1 + method (p0: int): void + public final @FunAnn @org.jetbrains.annotations.NotNull method invoke(): java.lang.Integer + public synthetic bridge method invoke(): java.lang.Object +} + +@kotlin.Metadata +public final class LiteralsKt { + // source: 'literals.kt' + inner (anonymous) class LiteralsKt$foo$1 + inner (anonymous) class LiteralsKt$foo$2 + inner (anonymous) class LiteralsKt$foo$3 + inner (anonymous) class LiteralsKt$foo$x$1 + public final static method bar(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): int + public final static @org.jetbrains.annotations.NotNull method foo(p0: int): My +} + +@kotlin.Metadata +public class My { + // source: 'literals.kt' + public method (): void +} diff --git a/compiler/testData/codegen/bytecodeText/directInvoke/inplaceClosure.kt b/compiler/testData/codegen/bytecodeText/directInvoke/inplaceClosure.kt index 47cd5c5cac7..2e8a7ce4328 100644 --- a/compiler/testData/codegen/bytecodeText/directInvoke/inplaceClosure.kt +++ b/compiler/testData/codegen/bytecodeText/directInvoke/inplaceClosure.kt @@ -3,4 +3,4 @@ fun test() { 1.fn() } -// 1 invoke \(I\)I \ No newline at end of file +// 1 invoke \(Ljava/lang/Object;\)Ljava/lang/Object; \ No newline at end of file