JVM_IR: remove an unnecessary hack from BridgeLowering
Correct IR is more important than whether some inaccessible members precisely match what was generated by the old backend.
This commit is contained in:
+1
-11
@@ -228,17 +228,6 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass
|
|||||||
for (member in potentialBridgeTargets) {
|
for (member in potentialBridgeTargets) {
|
||||||
val parent = member.parentAsClass
|
val parent = member.parentAsClass
|
||||||
createBridges(parent, member)
|
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()
|
returnType = bridge.overridden.returnType.eraseTypeParameters()
|
||||||
isSuspend = bridge.overridden.isSuspend
|
isSuspend = bridge.overridden.isSuspend
|
||||||
}.apply {
|
}.apply {
|
||||||
|
copyAttributes(target)
|
||||||
copyParametersWithErasure(this@addBridge, bridge.overridden)
|
copyParametersWithErasure(this@addBridge, bridge.overridden)
|
||||||
body = context.createIrBuilder(symbol, startOffset, endOffset).run { irExprBody(delegatingCall(this@apply, target)) }
|
body = context.createIrBuilder(symbol, startOffset, endOffset).run { irExprBody(delegatingCall(this@apply, target)) }
|
||||||
|
|
||||||
|
|||||||
@@ -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 <init>(): 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 <clinit>(): void
|
||||||
|
method <init>(): 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 <init>(): void
|
||||||
|
}
|
||||||
@@ -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 <init>(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 <init>(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 <init>(): 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 <init>(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 <init>(): void
|
||||||
|
}
|
||||||
@@ -3,4 +3,4 @@ fun test() {
|
|||||||
1.fn()
|
1.fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1 invoke \(I\)I
|
// 1 invoke \(Ljava/lang/Object;\)Ljava/lang/Object;
|
||||||
Reference in New Issue
Block a user