Fix inlining of functions with matching JVM signatures in same package
When two functions with matching JVM signatures in the same package were inlined sequentially, inliner could take a wrong method body from the cache due to MethodId clash. This manifested with inline classes, but also was possible with some legal Kotlin overloads with matching erasure. Use internal name of the corresponding implementation owner class instead of FQN of the containing declaration. Such MethodIds can't match accidentally, because corresponding JVM method signatures would clash.
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
package lib
|
||||
|
||||
inline fun Int.toString(ignored: Int) = toString()
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package lib
|
||||
|
||||
inline class J(val value: Int)
|
||||
|
||||
inline fun J.toString(ignored: Int) = "J$value"
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
warning: ATTENTION!
|
||||
This build uses unsafe internal compiler arguments:
|
||||
|
||||
-XXLanguage:+InlineClasses
|
||||
|
||||
This mode is not recommended for production use,
|
||||
as no stability/compatibility guarantees are given on
|
||||
compiler or generated code. Use it at your own risk!
|
||||
|
||||
warning: following manually enabled features will force generation of pre-release binaries: InlineClasses
|
||||
OK
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import lib.*
|
||||
|
||||
fun run() {
|
||||
val test1 = 42.toString(10)
|
||||
val test2 = J(42).toString(10)
|
||||
if (test1 != "42") throw AssertionError(test1)
|
||||
if (test2 != "J42") throw AssertionError(test2)
|
||||
}
|
||||
Reference in New Issue
Block a user