Skip to content

Commit

Permalink
JVM IR: Resolve fake overrides during inline class mangling
Browse files Browse the repository at this point in the history
This is necessary to determine which mangling scheme to use (KT-51672).

(cherry picked from commit 1134dc3)
  • Loading branch information
Steven Schäfer authored and Space committed Apr 14, 2022
1 parent 0c80614 commit 368465e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,11 @@ class MemoizedInlineClassReplacements(
val replacement = buildReplacementInner(function, replacementOrigin, noFakeOverride, useOldManglingScheme, body)
// When using the new mangling scheme we might run into dependencies using the old scheme
// for which we will fall back to the old mangling scheme as well.
if (
!useOldManglingScheme &&
replacement.name.asString().contains("-") &&
function.parentClassId?.let { classFileContainsMethod(it, replacement, context) } == false
) {
return buildReplacementInner(function, replacementOrigin, noFakeOverride, true, body)
if (!useOldManglingScheme && replacement.name.asString().contains('-') && function.parentClassId != null) {
val resolved = (function as? IrSimpleFunction)?.resolveFakeOverride(true)
if (resolved?.parentClassId?.let { classFileContainsMethod(it, replacement, context) } == false) {
return buildReplacementInner(function, replacementOrigin, noFakeOverride, true, body)
}
}
return replacement
}
Expand Down
20 changes: 20 additions & 0 deletions compiler/testData/codegen/box/inlineClasses/kt51672.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// MODULE: lib
// WITH_STDLIB
// TARGET_BACKEND: JVM
// FILE: lib.kt
@JvmInline
value class S(val value: String)

interface A {
fun f(s: S): S = s
}

interface B : A

// MODULE: main(lib)
// FILE: main.kt
interface C : B

fun box(): String {
return object : C {}.f(S("OK")).value
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 368465e

Please sign in to comment.