Count in interfaces/classes/packages when resolving name clashes with "_" suffix mangling
^KT-41904 Fixed Merge-request: KT-MR-6862 Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
TestInterface constructor(Int): 153.0
|
||||
TestInterface constructor(Double): 42.0
|
||||
InnerInterface constructor(Int): 153.0
|
||||
InnerInterface constructor(Double): 42.0
|
||||
TestInterface initialized from inner package: 19.0
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// FILE: outerPackage.kt
|
||||
|
||||
interface TestInterface {
|
||||
fun doSomething(): Double
|
||||
}
|
||||
|
||||
// These functions have name clashes with an interface, so their names should be mangled with repetitive "_" suffixes
|
||||
fun TestInterface(double: Double): TestInterface = object : TestInterface {
|
||||
override fun doSomething(): Double {
|
||||
return double
|
||||
}
|
||||
}
|
||||
fun TestInterface(int: Int): TestInterface = object : TestInterface {
|
||||
override fun doSomething(): Double {
|
||||
return int.toDouble()
|
||||
}
|
||||
}
|
||||
|
||||
class ContainingClass {
|
||||
interface InnerInterface {
|
||||
fun doSomething(): Double
|
||||
}
|
||||
|
||||
// These functions have name clashes with an interface, so their names should be mangled with repetitive "_" suffixes
|
||||
fun InnerInterface(double: Double): InnerInterface = object : InnerInterface {
|
||||
override fun doSomething(): Double {
|
||||
return double
|
||||
}
|
||||
}
|
||||
fun InnerInterface(int: Int): InnerInterface = object : InnerInterface {
|
||||
override fun doSomething(): Double {
|
||||
return int.toDouble()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this function is intended to have name clash with package TestPackage
|
||||
fun TestPackage(double: Double): TestInterface = object : TestInterface {
|
||||
override fun doSomething(): Double {
|
||||
return double
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: innerPackage.kt
|
||||
|
||||
package TestPackage
|
||||
|
||||
fun identity(double: Double) = double
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
#include "testlib_api.h"
|
||||
#define __ testlib_symbols()->
|
||||
#define T_(x) testlib_kref_ ## x
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
T_(TestInterface) tiFromInt = __ kotlin.root.TestInterface_ (153);
|
||||
printf("TestInterface constructor(Int): %.1f\n", __ kotlin.root.TestInterface.doSomething(tiFromInt));
|
||||
T_(TestInterface) tiFromDouble = __ kotlin.root.TestInterface__ (42.0);
|
||||
printf("TestInterface constructor(Double): %.1f\n", __ kotlin.root.TestInterface.doSomething(tiFromDouble));
|
||||
|
||||
T_(ContainingClass) containingClassInstance = __ kotlin.root.ContainingClass.ContainingClass();
|
||||
T_(ContainingClass_InnerInterface) iiFromInt = __ kotlin.root.ContainingClass.InnerInterface_ (containingClassInstance, 153);
|
||||
printf("InnerInterface constructor(Int): %.1f\n", __ kotlin.root.ContainingClass.InnerInterface.doSomething(iiFromInt));
|
||||
T_(ContainingClass_InnerInterface) iiFromDouble = __ kotlin.root.ContainingClass.InnerInterface__ (containingClassInstance, 42.0);
|
||||
printf("InnerInterface constructor(Double): %.1f\n", __ kotlin.root.ContainingClass.InnerInterface.doSomething(iiFromDouble));
|
||||
|
||||
T_(TestInterface) tiFromInnerPackage = __ kotlin.root.TestPackage_ (__ kotlin.root.TestPackage.identity(19.0));
|
||||
printf("TestInterface initialized from inner package: %.1f\n", __ kotlin.root.TestInterface.doSomething(tiFromInnerPackage));
|
||||
}
|
||||
Reference in New Issue
Block a user