91ef053fbc
Since LocalDeclarationsLowering is a BodyLoweringPass, local functions inside one declaration are handled independently of local functions in the other declaration. This can lead to name clashes, in case a local function with the same name and signature is declared in overloads in the same container, which results in a signature clash error in JVM IR. The issue became more common with the introduction of adapted function references, where psi2ir generates a local adapter-function with a predefined name, which can easily clash with another reference to the same target in an overload. This led to a compilation error when bootstrapping Kotlin with JVM IR, for example in GradleIRBuilder.kt where there are a lot of references to the same function.
54 lines
837 B
Kotlin
Vendored
54 lines
837 B
Kotlin
Vendored
// IGNORE_BACKEND_FIR: JVM_IR
|
|
|
|
var result = ""
|
|
|
|
fun overload() {
|
|
fun local() {
|
|
result += "1"
|
|
}
|
|
local()
|
|
}
|
|
|
|
fun overload(unused: String) {
|
|
fun local() {
|
|
result += "2"
|
|
}
|
|
local()
|
|
if ("".length < 1) {
|
|
fun local() {
|
|
result += "3"
|
|
}
|
|
local()
|
|
}
|
|
}
|
|
|
|
class C {
|
|
fun overload() {
|
|
fun local() {
|
|
result += "4"
|
|
}
|
|
local()
|
|
}
|
|
|
|
fun overload(unused: String) {
|
|
fun local() {
|
|
result += "5"
|
|
}
|
|
local()
|
|
if ("".length < 1) {
|
|
fun local() {
|
|
result += "6"
|
|
}
|
|
local()
|
|
}
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
overload()
|
|
overload("")
|
|
C().overload()
|
|
C().overload("")
|
|
return if (result == "123456") "OK" else "Fail: $result"
|
|
}
|