Files
kotlin/compiler/testData/codegen/box/callableReference/adaptedReferences/noNameClashForReferencesToSameFunction.kt
Alexander Udalov 91ef053fbc IR: keep local scope with counter maps across LDL invocations
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.
2020-05-08 14:33:34 +02:00

27 lines
368 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
var result = ""
class C(val token: String) {
fun target(): Int {
result += token
return 42
}
}
fun adapt(f: () -> Unit): Unit = f()
fun overload() {
adapt(C("O")::target)
}
fun overload(unused: String) {
adapt(C("K")::target)
}
fun box(): String {
overload()
overload("")
return result
}