diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java index f4e9b40e8e8..3d540efe4a6 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java @@ -1082,6 +1082,11 @@ public class KotlinTypeMapper { return name; } + String manglingSuffix = InlineClassManglingUtilsKt.getInlineClassValueParametersManglingSuffix(descriptor); + if (manglingSuffix != null) { + name += "$" + manglingSuffix; + } + if (DescriptorUtils.isTopLevelDeclaration(descriptor)) { if (Visibilities.isPrivate(descriptor.getVisibility()) && !(descriptor instanceof ConstructorDescriptor) && !"".equals(name)) { String partName = getPartSimpleNameForMangling(descriptor); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/inlineClassManglingUtils.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/inlineClassManglingUtils.kt new file mode 100644 index 00000000000..9240c47a3bb --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/inlineClassManglingUtils.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.codegen.state + +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.load.kotlin.getRepresentativeUpperBound +import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe +import org.jetbrains.kotlin.resolve.isInlineClassType +import org.jetbrains.kotlin.types.KotlinType + +import java.security.MessageDigest + +fun getInlineClassValueParametersManglingSuffix(descriptor: CallableMemberDescriptor): String? { + if (descriptor !is FunctionDescriptor) return null + if (descriptor is ConstructorDescriptor) return null + + val actualValueParameterTypes = listOfNotNull(descriptor.extensionReceiverParameter?.type) + descriptor.valueParameters.map { it.type } + + if (actualValueParameterTypes.none { it.isInlineClassType() || it.isTypeParameterWithInlineClassUpperBound() }) return null + + return md5radix36string(collectSignatureForMangling(actualValueParameterTypes)) +} + +private fun collectSignatureForMangling(types: List) = + types.joinToString { getSignatureElementForMangling(it) } + +private fun getSignatureElementForMangling(type: KotlinType): String = buildString { + val descriptor = type.constructor.declarationDescriptor ?: return "" + when (descriptor) { + is ClassDescriptor -> { + append('L') + append(descriptor.fqNameUnsafe) + if (type.isMarkedNullable) append('?') + append(';') + } + + is TypeParameterDescriptor -> { + append(getSignatureElementForMangling(getRepresentativeUpperBound(descriptor))) + } + } +} + +private fun md5radix36string(signatureForMangling: String): String { + val d = MessageDigest.getInstance("MD5").digest(signatureForMangling.toByteArray()) + var acc = 0L + for (i in 0..4) { + acc = (acc shl 8) + (d[i].toLong() and 0xFFL) + } + return acc.toString(36) +} + +fun KotlinType.isTypeParameterWithInlineClassUpperBound(): Boolean { + val descriptor = constructor.declarationDescriptor as? TypeParameterDescriptor ?: return false + return descriptor.isWithInlineClassUpperBoundInner(hashSetOf(descriptor)) +} + +private fun TypeParameterDescriptor.isWithInlineClassUpperBoundInner(visited: MutableSet): Boolean { + for (type in typeConstructor.supertypes) { + if (type.isInlineClassType()) return true + + val typeParameterDescriptor = type.constructor.declarationDescriptor as? TypeParameterDescriptor ?: continue + if (!visited.add(typeParameterDescriptor)) continue + if (typeParameterDescriptor.isWithInlineClassUpperBoundInner(visited)) return true + } + return false +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/anonymousObjectInFunctionWithMangledName.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/anonymousObjectInFunctionWithMangledName.kt new file mode 100644 index 00000000000..9260f726c67 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/anonymousObjectInFunctionWithMangledName.kt @@ -0,0 +1,13 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class S(val string: String) + +fun foo(s: S): String { + val anon = object { + fun bar() = s.string + } + return anon.bar() +} + +fun box() = foo(S("OK")) \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/extensionFunctionsDoNotClash.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/extensionFunctionsDoNotClash.kt new file mode 100644 index 00000000000..23ea9559a6e --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/extensionFunctionsDoNotClash.kt @@ -0,0 +1,50 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class Id(val id: String) + +inline class Name(val name: String) + +inline class Password(val password: String) + +fun Id.test() { + if (id != "OK") throw AssertionError() +} + +fun Name.test() { + if (name != "OK") throw AssertionError() +} + +fun test(password: Password) { + if (password.password != "OK") throw AssertionError() +} + +class Outer { + fun Id.testExn() { + if (id != "OK") throw AssertionError() + } + + fun Name.testExn() { + if (name != "OK") throw AssertionError() + } + + fun testExn(password: Password) { + if (password.password != "OK") throw AssertionError() + } + + fun testExns() { + Id("OK").testExn() + Name("OK").testExn() + testExn(Password("OK")) + } +} + +fun box(): String { + Id("OK").test() + Name("OK").test() + test(Password("OK")) + + Outer().testExns() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/functionsWithDifferentNullabilityDoNotClash.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/functionsWithDifferentNullabilityDoNotClash.kt new file mode 100644 index 00000000000..37f21882038 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/functionsWithDifferentNullabilityDoNotClash.kt @@ -0,0 +1,19 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class Id(val id: String) + +fun test(id: Id) { + if (id.id != "OK") throw AssertionError() +} + +fun test(id: Id?) { + if (id != null) throw AssertionError() +} + +fun box(): String { + test(Id("OK")) + test(null) + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/genericFunctionsDoNotClash.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/genericFunctionsDoNotClash.kt new file mode 100644 index 00000000000..1b3050e7eeb --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/genericFunctionsDoNotClash.kt @@ -0,0 +1,23 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class S1(val s1: String) +inline class S2(val s2: String) + +object X1 +object X2 + +fun test(s1: S1, x: T) { + if (s1.s1 != "OK" && x != X1) throw AssertionError() +} + +fun test(s2: S2, x: T) { + if (s2.s2 != "OK" && x != X2) throw AssertionError() +} + +fun box(): String { + test(S1("OK"), X1) + test(S2("OK"), X2) + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/localClassInFunctionWithMangledName.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/localClassInFunctionWithMangledName.kt new file mode 100644 index 00000000000..b51eef65a84 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/localClassInFunctionWithMangledName.kt @@ -0,0 +1,13 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class S(val string: String) + +fun foo(s: S): String { + class Local { + fun bar() = s.string + } + return Local().bar() +} + +fun box() = foo(S("OK")) \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsCanBeOverridden.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsCanBeOverridden.kt new file mode 100644 index 00000000000..08a32d55d8a --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsCanBeOverridden.kt @@ -0,0 +1,89 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class Id(val id: String) + +inline class Name(val name: String) + +interface IA { + fun fromInterface(id: Id) + fun fromInterface(name: Name) + + fun fromBoth(id: Id) + fun fromBoth(name: Name) + + fun withDefaultImpl(id: Id) { + if (id.id != "OK") throw AssertionError() + } + + fun withDefaultImpl(name: Name) { + if (name.name != "OK") throw AssertionError() + } +} + +abstract class Base { + abstract fun fromClass(id: Id) + abstract fun fromClass(name: Name) + + abstract fun fromBoth(id: Id) + abstract fun fromBoth(name: Name) +} + + +class C : Base(), IA { + override fun fromInterface(id: Id) { + if (id.id != "OK") throw AssertionError() + } + + override fun fromInterface(name: Name) { + if (name.name != "OK") throw AssertionError() + } + + override fun fromClass(id: Id) { + if (id.id != "OK") throw AssertionError() + } + + override fun fromClass(name: Name) { + if (name.name != "OK") throw AssertionError() + } + + override fun fromBoth(id: Id) { + if (id.id != "OK") throw AssertionError() + } + + override fun fromBoth(name: Name) { + if (name.name != "OK") throw AssertionError() + } +} + +fun testIA(a: IA) { + a.fromInterface(Id("OK")) + a.fromInterface(Name("OK")) + + a.fromBoth(Id("OK")) + a.fromBoth(Name("OK")) + + a.withDefaultImpl(Id("OK")) + a.withDefaultImpl(Name("OK")) +} + +fun testBase(b: Base) { + b.fromClass(Id("OK")) + b.fromClass(Name("OK")) + + b.fromBoth(Id("OK")) + b.fromBoth(Name("OK")) +} + +fun testC(c: C) { + c.withDefaultImpl(Id("OK")) + c.withDefaultImpl(Name("OK")) +} + +fun box(): String { + testIA(C()) + testBase(C()) + testC(C()) + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsDoNotClash.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsDoNotClash.kt new file mode 100644 index 00000000000..50ef1a12fc2 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsDoNotClash.kt @@ -0,0 +1,28 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class Id(val id: String) + +inline class Name(val name: String) + +inline class Password(val password: String) + +fun test(id: Id) { + if (id.id != "OK") throw AssertionError() +} + +fun test(name: Name) { + if (name.name != "OK") throw AssertionError() +} + +fun test(password: Password) { + if (password.password != "OK") throw AssertionError() +} + +fun box(): String { + test(Id("OK")) + test(Name("OK")) + test(Password("OK")) + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsPresentInStackTrace.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsPresentInStackTrace.kt new file mode 100644 index 00000000000..d9bf179742d --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsPresentInStackTrace.kt @@ -0,0 +1,35 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR, JS, JS_IR +// FULL_JDK +// WITH_RUNTIME + +inline class Id(val id: String) + +fun throws() { + throw RuntimeException() +} + +fun test(id: Id) { + throws() +} + +fun foo() { + test(Id("id")) +} + +fun box(): String { + val stackTrace = try { + foo() + throw AssertionError() + } catch (e: RuntimeException) { + e.stackTrace + } + + for (entry in stackTrace) { + if (entry.methodName.startsWith("test$")) { + return "OK" + } + } + + throw AssertionError() +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mixedSignatureFunctionsDoNotClash.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mixedSignatureFunctionsDoNotClash.kt new file mode 100644 index 00000000000..7b536a6c598 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/mixedSignatureFunctionsDoNotClash.kt @@ -0,0 +1,19 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class Id(val id: String) + +fun test(id: Id, str: String) { + if (id.id != "OK" && str != "1") throw AssertionError() +} + +fun test(str: String, id: Id) { + if (id.id != "OK" && str != "2") throw AssertionError() +} + +fun box(): String { + test(Id("OK"), "1") + test("2", Id("OK")) + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass.kt new file mode 100644 index 00000000000..7ade834b8be --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass.kt @@ -0,0 +1,14 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +abstract class GenericBase { + abstract fun foo(x: T): T +} + +inline class Str(val str: String) + +class Derived : GenericBase() { + override fun foo(x: Str): Str = x +} + +fun box() = Derived().foo(Str("OK")).str \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass2.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass2.kt new file mode 100644 index 00000000000..943f9f6c187 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass2.kt @@ -0,0 +1,24 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +abstract class GenericBase { + abstract fun foo(x: T): T +} + +interface IFoo { + fun foo(x: String): String +} + +inline class Str(val str: String) + +class Derived : GenericBase(), IFoo { + override fun foo(x: Str): Str = x + override fun foo(x: String): String = x +} + +fun box(): String { + if (Derived().foo(Str("OK")).str != "OK") throw AssertionError() + if (Derived().foo("OK") != "OK") throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/propertySetterWithInlineClassTypeArgument.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/propertySetterWithInlineClassTypeArgument.kt new file mode 100644 index 00000000000..d2532c91e4f --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/propertySetterWithInlineClassTypeArgument.kt @@ -0,0 +1,14 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class Str(val string: String) + +class C { + var s = Str("") +} + +fun box(): String { + val x = C() + x.s = Str("OK") + return x.s.string +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt new file mode 100644 index 00000000000..6df0b44a3e4 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt @@ -0,0 +1,17 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR, JS, JS_IR +// WITH_RUNTIME +import kotlin.test.* + +inline class S(val string: String) + +fun foo(s: S) = s + +fun box(): String { + val fooRef = ::foo + + assertEquals("abc", fooRef.invoke(S("abc")).string) + assertEquals("foo", fooRef.name) + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForLocalClassInFunctionWithMangledName.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForLocalClassInFunctionWithMangledName.kt new file mode 100644 index 00000000000..273613a5f6f --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForLocalClassInFunctionWithMangledName.kt @@ -0,0 +1,26 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR, JS, JS_IR +// WITH_REFLECT +import kotlin.test.* + +import kotlin.test.* + +inline class S(val string: String) + +fun test(s: S) { + class Local + + val localKClass = Local::class + val localJClass = localKClass.java + + assertEquals("test\$Local", localKClass.simpleName) + + assertTrue { localJClass.isLocalClass } + assertEquals("test\$Local", localJClass.simpleName) +} + +fun box(): String { + test(S("")) + + return "OK" +} diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForPropertyOfInlineClassType.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForPropertyOfInlineClassType.kt new file mode 100644 index 00000000000..0f8a4e3ff2a --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForPropertyOfInlineClassType.kt @@ -0,0 +1,21 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR, JS, JS_IR +// WITH_RUNTIME +import kotlin.test.* + +inline class S(val string: String) + +var prop = S("") + +fun box(): String { + val propRef = ::prop + + assertEquals(S(""), propRef.get()) + + propRef.set(S("abc")) + assertEquals(S("abc"), propRef.get()) + + assertEquals("prop", propRef.name) + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorForFunctionWithMangledName.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorForFunctionWithMangledName.kt new file mode 100644 index 00000000000..d508d2dfff8 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorForFunctionWithMangledName.kt @@ -0,0 +1,14 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class S(val string: String) + +class Outer { + private fun foo(s: S) = s.string + + inner class Inner(val string: String) { + fun bar() = foo(S(string)) + } +} + +fun box(): String = Outer().Inner("OK").bar() \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt new file mode 100644 index 00000000000..ec8b5cf0155 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class S(val string: String) + +class Outer { + private var pr = S("") + + inner class Inner() { + fun updateOuter(string: String): String { + pr = S(string) + return pr.string + } + } +} + +fun box(): String = + Outer().Inner().updateOuter("OK") \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/callMemberMethodsInsideInlineClass.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/callMemberMethodsInsideInlineClass.kt index e9b32168813..88f92d8960f 100644 --- a/compiler/testData/codegen/bytecodeText/inlineClasses/callMemberMethodsInsideInlineClass.kt +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/callMemberMethodsInsideInlineClass.kt @@ -14,5 +14,5 @@ inline class Foo(val x: Int) { // 1 INVOKESTATIC Foo\$Erased.empty \(I\)V // 1 INVOKESTATIC Foo\$Erased.withParam \(ILjava/lang/String;\)V -// 1 INVOKESTATIC Foo\$Erased.withInlineClassParam \(II\)V +// 1 INVOKESTATIC Foo\$Erased.withInlineClassParam\$1e4ch6lh \(II\)V // 5 INVOKEVIRTUAL \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/constructorWithInlineClassParametersIsNotMangled.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/constructorWithInlineClassParametersIsNotMangled.kt new file mode 100644 index 00000000000..f0638278062 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/constructorWithInlineClassParametersIsNotMangled.kt @@ -0,0 +1,10 @@ +// !LANGUAGE: +InlineClasses + +inline class Str(val s: String) + +class C1(val ss: Str) + +class C2(val ss1: Str, val ss2: Str) + +// 2 public \\(Ljava/lang/String;\)V +// 1 public \\(Ljava/lang/String;Ljava/lang/String;\)V \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/functionsWithInlineClassParametersHaveStableMangledNames.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/functionsWithInlineClassParametersHaveStableMangledNames.kt new file mode 100644 index 00000000000..2ee0f21121d --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/functionsWithInlineClassParametersHaveStableMangledNames.kt @@ -0,0 +1,29 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +inline class Id(val id: String) + +inline class Name(val name: String) + +inline class Password(val password: String) + +fun test(id: Id) { + if (id.id != "OK") throw AssertionError() +} + +fun test(id: Id?) { + if (id != null) throw AssertionError() +} + +fun test(name: Name) { + if (name.name != "OK") throw AssertionError() +} + +fun test(password: Password) { + if (password.password != "OK") throw AssertionError() +} + +// 1 public final static test\$9zx0e0j9\(Ljava/lang/String;\)V +// 1 public final static test\$79jv2l6i\(Ljava/lang/String;\)V +// 1 public final static test\$d4pejdz3\(Ljava/lang/String;\)V +// 1 public final static test\$c6sgoxk6\(Ljava/lang/String;\)V \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/propertySetterWithInlineClassTypeArgument.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/propertySetterWithInlineClassTypeArgument.kt new file mode 100644 index 00000000000..47b17425a4c --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/propertySetterWithInlineClassTypeArgument.kt @@ -0,0 +1,10 @@ +// !LANGUAGE: +InlineClasses + +inline class Str(val string: String) + +class C { + var s = Str("") +} + +// 1 public final getS\(\)Ljava/lang/String; +// 1 public final setS\$90215lrx\(Ljava/lang/String;\)V \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesClash.kt b/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesClash.kt new file mode 100644 index 00000000000..875f220bdde --- /dev/null +++ b/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesClash.kt @@ -0,0 +1,37 @@ +// !LANGUAGE: +InlineClasses +// !DIAGNOSTICS: -UNUSED_PARAMETER + +inline class X(val x: Int) +inline class Z(val x: Int) +inline class Str(val str: String) +inline class Name(val name: String) +inline class NStr(val str: String?) + +fun testSimple(x: X) {} +fun testSimple(z: Z) {} + +fun testMixed(x: Int, y: Int) {} +fun testMixed(x: X, y: Int) {} +fun testMixed(x: Int, y: X) {} +fun testMixed(x: X, y: X) {} + +fun testNewType(s: Str) {} +fun testNewType(name: Name) {} + +fun testNullableVsNonNull1(s: Str) {} +fun testNullableVsNonNull1(s: Str?) {} + +fun testNullableVsNonNull2(ns: NStr) {} +fun testNullableVsNonNull2(ns: NStr?) {} + +fun testFunVsExt(x: X) {} +fun X.testFunVsExt() {} + +fun testNonGenericVsGeneric(x: X, y: Number) {} +fun testNonGenericVsGeneric(x: X, y: T) {} + +class C { + fun testNonGenericVsGeneric(x: X, y: Number) {} + fun testNonGenericVsGeneric(x: X, y: T) {} + fun testNonGenericVsGeneric(x: X, y: TC) {} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesClash.txt b/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesClash.txt new file mode 100644 index 00000000000..84b7ae97e21 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesClash.txt @@ -0,0 +1,68 @@ +package + +public fun testFunVsExt(/*0*/ x: X): kotlin.Unit +public fun testMixed(/*0*/ x: X, /*1*/ y: X): kotlin.Unit +public fun testMixed(/*0*/ x: X, /*1*/ y: kotlin.Int): kotlin.Unit +public fun testMixed(/*0*/ x: kotlin.Int, /*1*/ y: X): kotlin.Unit +public fun testMixed(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int): kotlin.Unit +public fun testNewType(/*0*/ name: Name): kotlin.Unit +public fun testNewType(/*0*/ s: Str): kotlin.Unit +public fun testNonGenericVsGeneric(/*0*/ x: X, /*1*/ y: T): kotlin.Unit +public fun testNonGenericVsGeneric(/*0*/ x: X, /*1*/ y: kotlin.Number): kotlin.Unit +public fun testNullableVsNonNull1(/*0*/ s: Str): kotlin.Unit +public fun testNullableVsNonNull1(/*0*/ s: Str?): kotlin.Unit +public fun testNullableVsNonNull2(/*0*/ ns: NStr): kotlin.Unit +public fun testNullableVsNonNull2(/*0*/ ns: NStr?): kotlin.Unit +public fun testSimple(/*0*/ x: X): kotlin.Unit +public fun testSimple(/*0*/ z: Z): kotlin.Unit +public fun X.testFunVsExt(): kotlin.Unit + +public final class C { + public constructor C() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun testNonGenericVsGeneric(/*0*/ x: X, /*1*/ y: T): kotlin.Unit + public final fun testNonGenericVsGeneric(/*0*/ x: X, /*1*/ y: TC): kotlin.Unit + public final fun testNonGenericVsGeneric(/*0*/ x: X, /*1*/ y: kotlin.Number): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final inline class NStr { + public constructor NStr(/*0*/ str: kotlin.String?) + public final val str: kotlin.String? + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} + +public final inline class Name { + public constructor Name(/*0*/ name: kotlin.String) + public final val name: kotlin.String + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} + +public final inline class Str { + public constructor Str(/*0*/ str: kotlin.String) + public final val str: kotlin.String + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} + +public final inline class X { + public constructor X(/*0*/ x: kotlin.Int) + public final val x: kotlin.Int + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} + +public final inline class Z { + public constructor Z(/*0*/ x: kotlin.Int) + public final val x: kotlin.Int + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesConflictOnInheritance.kt b/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesConflictOnInheritance.kt new file mode 100644 index 00000000000..4d71d826e72 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesConflictOnInheritance.kt @@ -0,0 +1,14 @@ +// !LANGUAGE: +InlineClasses + +inline class Name(val name: String) +inline class Password(val password: String) + +interface NameVerifier { + fun verify(name: Name) +} + +interface PasswordVerifier { + fun verify(password: Password) +} + +interface NameAndPasswordVerifier : NameVerifier, PasswordVerifier diff --git a/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesConflictOnInheritance.txt b/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesConflictOnInheritance.txt new file mode 100644 index 00000000000..9493b259a02 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesConflictOnInheritance.txt @@ -0,0 +1,39 @@ +package + +public final inline class Name { + public constructor Name(/*0*/ name: kotlin.String) + public final val name: kotlin.String + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} + +public interface NameAndPasswordVerifier : NameVerifier, PasswordVerifier { + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + public abstract override /*1*/ /*fake_override*/ fun verify(/*0*/ name: Name): kotlin.Unit + public abstract override /*1*/ /*fake_override*/ fun verify(/*0*/ password: Password): kotlin.Unit +} + +public interface NameVerifier { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public abstract fun verify(/*0*/ name: Name): kotlin.Unit +} + +public final inline class Password { + public constructor Password(/*0*/ password: kotlin.String) + public final val password: kotlin.String + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} + +public interface PasswordVerifier { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public abstract fun verify(/*0*/ password: Password): kotlin.Unit +} diff --git a/compiler/testData/writeSignature/inlineClasses/basicInlineClassDeclarationCodegen.kt b/compiler/testData/writeSignature/inlineClasses/basicInlineClassDeclarationCodegen.kt index 695f6a72d3f..e76484ba3bb 100644 --- a/compiler/testData/writeSignature/inlineClasses/basicInlineClassDeclarationCodegen.kt +++ b/compiler/testData/writeSignature/inlineClasses/basicInlineClassDeclarationCodegen.kt @@ -25,6 +25,6 @@ inline class Foo(val x: Int) { // jvm signature: (ILjava/lang/Object;D)V // generic signature: null -// method: Foo$Erased::withInlineClassType +// method: Foo$Erased::withInlineClassType$1e4ch6lh // jvm signature: (II)V // generic signature: null diff --git a/compiler/testData/writeSignature/inlineClasses/genericInlineClassBasedOnGenericType.kt b/compiler/testData/writeSignature/inlineClasses/genericInlineClassBasedOnGenericType.kt index 4de2af91a78..a3ca77b2ae7 100644 --- a/compiler/testData/writeSignature/inlineClasses/genericInlineClassBasedOnGenericType.kt +++ b/compiler/testData/writeSignature/inlineClasses/genericInlineClassBasedOnGenericType.kt @@ -9,15 +9,15 @@ object Test { fun nullableValue(f: Foo?) {} } -// method: Test::nonNullTypeArgument +// method: Test::nonNullTypeArgument$1e4ch6lh // jvm signature: (Ljava/util/List;)V // generic signature: (Ljava/util/List;)V -// method: Test::nullableTypeArgument +// method: Test::nullableTypeArgument$1e4ch6lh // jvm signature: (Ljava/util/List;)V // generic signature: (Ljava/util/List;)V -// method: Test::nullableValue +// method: Test::nullableValue$31ee2c96 // jvm signature: (Ljava/util/List;)V // generic signature: (Ljava/util/List;)V diff --git a/compiler/testData/writeSignature/inlineClasses/genericInlineClassWithDefaultTypeParameter.kt b/compiler/testData/writeSignature/inlineClasses/genericInlineClassWithDefaultTypeParameter.kt index 8430b20a0ba..66eb9c67c0f 100644 --- a/compiler/testData/writeSignature/inlineClasses/genericInlineClassWithDefaultTypeParameter.kt +++ b/compiler/testData/writeSignature/inlineClasses/genericInlineClassWithDefaultTypeParameter.kt @@ -15,23 +15,23 @@ object Test { fun asNullableAndNullableTypeArgument(a: Default?) {} } -// method: Test::withNotNullPrimitive +// method: Test::withNotNullPrimitive$7odoyk9m // jvm signature: (Ljava/lang/Object;)V // generic signature: null -// method: Test::withAdditionalGenericParameter +// method: Test::withAdditionalGenericParameter$1k09dck1 // jvm signature: (LInv;Ljava/lang/Object;)V // generic signature: (LInv;Ljava/lang/Object;)V -// method: Test::asNullable +// method: Test::asNullable$ao7usvyu // jvm signature: (LDefault;)V // generic signature: (LDefault;)V -// method: Test::asNullableTypeArgument +// method: Test::asNullableTypeArgument$7odoyk9m // jvm signature: (Ljava/lang/Object;)V // generic signature: null -// method: Test::asNullableAndNullableTypeArgument +// method: Test::asNullableAndNullableTypeArgument$ao7usvyu // jvm signature: (LDefault;)V // generic signature: (LDefault;)V diff --git a/compiler/testData/writeSignature/inlineClasses/genericInlineClassWithNotNullTypeParameter.kt b/compiler/testData/writeSignature/inlineClasses/genericInlineClassWithNotNullTypeParameter.kt index d6d10565804..69fb0b44e38 100644 --- a/compiler/testData/writeSignature/inlineClasses/genericInlineClassWithNotNullTypeParameter.kt +++ b/compiler/testData/writeSignature/inlineClasses/genericInlineClassWithNotNullTypeParameter.kt @@ -14,18 +14,18 @@ object Test { fun asNullableForNullableValue(a: NullableValue?) {} } -// method: Test::withNotNullPrimitive +// method: Test::withNotNullPrimitive$7l8qu2mt // jvm signature: (Ljava/lang/Object;)V // generic signature: null -// method: Test::asNullable +// method: Test::asNullable$4hed6sie // jvm signature: (Ljava/lang/Object;)V // generic signature: null -// method: Test::withNotNullForNullableValue +// method: Test::withNotNullForNullableValue$c6wvqrdl // jvm signature: (Ljava/lang/Object;)V // generic signature: null -// method: Test::asNullableForNullableValue +// method: Test::asNullableForNullableValue$aloai6d9 // jvm signature: (LNullableValue;)V // generic signature: (LNullableValue;)V \ No newline at end of file diff --git a/compiler/testData/writeSignature/inlineClasses/inlineClassBasedOnOtherInlineClass.kt b/compiler/testData/writeSignature/inlineClasses/inlineClassBasedOnOtherInlineClass.kt index 61fb7048772..ce1200030f9 100644 --- a/compiler/testData/writeSignature/inlineClasses/inlineClassBasedOnOtherInlineClass.kt +++ b/compiler/testData/writeSignature/inlineClasses/inlineClassBasedOnOtherInlineClass.kt @@ -8,7 +8,7 @@ object Test { fun listOfFoo(f: List) {} } -// method: Test::simple +// method: Test::simple$1e4ch6lh // jvm signature: (I)V // generic signature: null diff --git a/compiler/testData/writeSignature/inlineClasses/inlineClassWithComplexSubstitutedType.kt b/compiler/testData/writeSignature/inlineClasses/inlineClassWithComplexSubstitutedType.kt index e1c78e03220..2113cecf874 100644 --- a/compiler/testData/writeSignature/inlineClasses/inlineClassWithComplexSubstitutedType.kt +++ b/compiler/testData/writeSignature/inlineClasses/inlineClassWithComplexSubstitutedType.kt @@ -16,26 +16,26 @@ object Test { fun withInnerGenericInlineClassIn(a: AsCmp>>) {} } -// method: Test::withInlineClassArgumentOut +// method: Test::withInlineClassArgumentOut$5xv5g663 // jvm signature: (Ljava/util/List;)V // generic signature: (Ljava/util/List;)V -// method: Test::withInlineClassArgumentIn +// method: Test::withInlineClassArgumentIn$brqdr5wn // jvm signature: (Ljava/lang/Comparable;)V // generic signature: (Ljava/lang/Comparable<-LUInt;>;)V -// method: Test::withListOfInlineClassArgument +// method: Test::withListOfInlineClassArgument$5xv5g663 // jvm signature: (Ljava/util/List;)V // generic signature: (Ljava/util/List<+Ljava/util/List;>;)V -// method: Test::withComparableOfInlineClassArgument +// method: Test::withComparableOfInlineClassArgument$brqdr5wn // jvm signature: (Ljava/lang/Comparable;)V // generic signature: (Ljava/lang/Comparable<-Ljava/lang/Comparable<-LUInt;>;>;)V -// method: Test::withInnerGenericInlineClassOut +// method: Test::withInnerGenericInlineClassOut$5xv5g663 // jvm signature: (Ljava/util/List;)V // generic signature: (Ljava/util/List;>;>;)V -// method: Test::withInnerGenericInlineClassIn +// method: Test::withInnerGenericInlineClassIn$brqdr5wn // jvm signature: (Ljava/lang/Comparable;)V // generic signature: (Ljava/lang/Comparable<-LAsCmp;>;>;)V \ No newline at end of file diff --git a/compiler/testData/writeSignature/inlineClasses/nullableInlineClassType.kt b/compiler/testData/writeSignature/inlineClasses/nullableInlineClassType.kt index d2d06c1814c..687b1afc79b 100644 --- a/compiler/testData/writeSignature/inlineClasses/nullableInlineClassType.kt +++ b/compiler/testData/writeSignature/inlineClasses/nullableInlineClassType.kt @@ -13,18 +13,18 @@ object Test { fun withNullableReferenceAsNullable(a: InlineNullableReference?) {} } -// method: Test::withPrimitiveAsNullable +// method: Test::withPrimitiveAsNullable$arwt9fzf // jvm signature: (LInlinePrimitive;)V // generic signature: null -// method: Test::withReferenceAsNullable +// method: Test::withReferenceAsNullable$8k1ogbuu // jvm signature: (Ljava/lang/String;)V // generic signature: null -// method: Test::withNullablePrimitiveAsNullable +// method: Test::withNullablePrimitiveAsNullable$aiqm4cvc // jvm signature: (LInlineNullablePrimitive;)V // generic signature: null -// method: Test::withNullableReferenceAsNullable +// method: Test::withNullableReferenceAsNullable$7pmrpo2y // jvm signature: (LInlineNullableReference;)V // generic signature: null \ No newline at end of file diff --git a/compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsPrimitive.kt b/compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsPrimitive.kt index 268801e2ee2..fa89043c0cc 100644 --- a/compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsPrimitive.kt +++ b/compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsPrimitive.kt @@ -9,7 +9,7 @@ object Test { fun Foo.asAll(x: Any?, a: Foo, b: Int): Foo = TODO() } -// method: Test::asParam +// method: Test::asParam$1e4ch6lh // jvm signature: (I)V // generic signature: null @@ -17,10 +17,10 @@ object Test { // jvm signature: ()I // generic signature: null -// method: Test::asExtension +// method: Test::asExtension$1e4ch6lh // jvm signature: (I)V // generic signature: null -// method: Test::asAll +// method: Test::asAll$dmjdpekg // jvm signature: (ILjava/lang/Object;II)I // generic signature: null diff --git a/compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsReference.kt b/compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsReference.kt index 5ac7890735d..7f19134e2b2 100644 --- a/compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsReference.kt +++ b/compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsReference.kt @@ -10,7 +10,7 @@ object Test { fun asReturn(): Bar = TODO() } -// method: Test::asParam +// method: Test::asParam$1e4ch6lh // jvm signature: (Ljava/lang/Integer;)V // generic signature: null diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index f81ceb597ae..3e74e92d80e 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -10877,6 +10877,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/inlineClasses/delegatedPropertyInInlineClass.kt"); } + @TestMetadata("functionsJvmSignaturesClash.kt") + public void testFunctionsJvmSignaturesClash() throws Exception { + runTest("compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesClash.kt"); + } + + @TestMetadata("functionsJvmSignaturesConflictOnInheritance.kt") + public void testFunctionsJvmSignaturesConflictOnInheritance() throws Exception { + runTest("compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesConflictOnInheritance.kt"); + } + @TestMetadata("identityComparisonWithInlineClasses.kt") public void testIdentityComparisonWithInlineClasses() throws Exception { runTest("compiler/testData/diagnostics/tests/inlineClasses/identityComparisonWithInlineClasses.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 0ec223cba82..ceab712b8e1 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -10877,6 +10877,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inlineClasses/delegatedPropertyInInlineClass.kt"); } + @TestMetadata("functionsJvmSignaturesClash.kt") + public void testFunctionsJvmSignaturesClash() throws Exception { + runTest("compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesClash.kt"); + } + + @TestMetadata("functionsJvmSignaturesConflictOnInheritance.kt") + public void testFunctionsJvmSignaturesConflictOnInheritance() throws Exception { + runTest("compiler/testData/diagnostics/tests/inlineClasses/functionsJvmSignaturesConflictOnInheritance.kt"); + } + @TestMetadata("identityComparisonWithInlineClasses.kt") public void testIdentityComparisonWithInlineClasses() throws Exception { runTest("compiler/testData/diagnostics/tests/inlineClasses/identityComparisonWithInlineClasses.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index d8e92ed7c64..09c2635a73b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -11757,6 +11757,104 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testUseThisInsideInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/useThisInsideInlineClass.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionNameMangling extends AbstractBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInFunctionNameMangling() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/functionNameMangling"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("anonymousObjectInFunctionWithMangledName.kt") + public void testAnonymousObjectInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/anonymousObjectInFunctionWithMangledName.kt"); + } + + @TestMetadata("extensionFunctionsDoNotClash.kt") + public void testExtensionFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/extensionFunctionsDoNotClash.kt"); + } + + @TestMetadata("functionsWithDifferentNullabilityDoNotClash.kt") + public void testFunctionsWithDifferentNullabilityDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/functionsWithDifferentNullabilityDoNotClash.kt"); + } + + @TestMetadata("genericFunctionsDoNotClash.kt") + public void testGenericFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/genericFunctionsDoNotClash.kt"); + } + + @TestMetadata("localClassInFunctionWithMangledName.kt") + public void testLocalClassInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/localClassInFunctionWithMangledName.kt"); + } + + @TestMetadata("mangledFunctionsCanBeOverridden.kt") + public void testMangledFunctionsCanBeOverridden() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsCanBeOverridden.kt"); + } + + @TestMetadata("mangledFunctionsDoNotClash.kt") + public void testMangledFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsDoNotClash.kt"); + } + + @TestMetadata("mangledFunctionsPresentInStackTrace.kt") + public void testMangledFunctionsPresentInStackTrace() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsPresentInStackTrace.kt"); + } + + @TestMetadata("mixedSignatureFunctionsDoNotClash.kt") + public void testMixedSignatureFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mixedSignatureFunctionsDoNotClash.kt"); + } + + @TestMetadata("overridingMethodInGenericClass.kt") + public void testOverridingMethodInGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass.kt"); + } + + @TestMetadata("overridingMethodInGenericClass2.kt") + public void testOverridingMethodInGenericClass2() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass2.kt"); + } + + @TestMetadata("propertySetterWithInlineClassTypeArgument.kt") + public void testPropertySetterWithInlineClassTypeArgument() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/propertySetterWithInlineClassTypeArgument.kt"); + } + + @TestMetadata("reflectionForFunctionWithMangledName.kt") + public void testReflectionForFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt"); + } + + @TestMetadata("reflectionForLocalClassInFunctionWithMangledName.kt") + public void testReflectionForLocalClassInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForLocalClassInFunctionWithMangledName.kt"); + } + + @TestMetadata("reflectionForPropertyOfInlineClassType.kt") + public void testReflectionForPropertyOfInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForPropertyOfInlineClassType.kt"); + } + + @TestMetadata("syntheticAccessorForFunctionWithMangledName.kt") + public void testSyntheticAccessorForFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorForFunctionWithMangledName.kt"); + } + + @TestMetadata("syntheticAccessorsForPropertyOfInlineClassType.kt") + public void testSyntheticAccessorsForPropertyOfInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index 385d0e43f34..57f1cb7095e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -2058,6 +2058,16 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/checkOuterInlineFunctionCall.kt"); } + @TestMetadata("constructorWithInlineClassParametersIsNotMangled.kt") + public void testConstructorWithInlineClassParametersIsNotMangled() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/constructorWithInlineClassParametersIsNotMangled.kt"); + } + + @TestMetadata("functionsWithInlineClassParametersHaveStableMangledNames.kt") + public void testFunctionsWithInlineClassParametersHaveStableMangledNames() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/functionsWithInlineClassParametersHaveStableMangledNames.kt"); + } + @TestMetadata("generationOfAccessorToUnderlyingValue.kt") public void testGenerationOfAccessorToUnderlyingValue() throws Exception { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/generationOfAccessorToUnderlyingValue.kt"); @@ -2113,6 +2123,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/passInlineClassesWithSpreadOperatorToVarargs.kt"); } + @TestMetadata("propertySetterWithInlineClassTypeArgument.kt") + public void testPropertySetterWithInlineClassTypeArgument() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/propertySetterWithInlineClassTypeArgument.kt"); + } + @TestMetadata("skipCallToUnderlyingValueOfInlineClass.kt") public void testSkipCallToUnderlyingValueOfInlineClass() throws Exception { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/skipCallToUnderlyingValueOfInlineClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index d43337c32d7..03f36ca23c6 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -11757,6 +11757,104 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes public void testUseThisInsideInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/useThisInsideInlineClass.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionNameMangling extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInFunctionNameMangling() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/functionNameMangling"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("anonymousObjectInFunctionWithMangledName.kt") + public void testAnonymousObjectInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/anonymousObjectInFunctionWithMangledName.kt"); + } + + @TestMetadata("extensionFunctionsDoNotClash.kt") + public void testExtensionFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/extensionFunctionsDoNotClash.kt"); + } + + @TestMetadata("functionsWithDifferentNullabilityDoNotClash.kt") + public void testFunctionsWithDifferentNullabilityDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/functionsWithDifferentNullabilityDoNotClash.kt"); + } + + @TestMetadata("genericFunctionsDoNotClash.kt") + public void testGenericFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/genericFunctionsDoNotClash.kt"); + } + + @TestMetadata("localClassInFunctionWithMangledName.kt") + public void testLocalClassInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/localClassInFunctionWithMangledName.kt"); + } + + @TestMetadata("mangledFunctionsCanBeOverridden.kt") + public void testMangledFunctionsCanBeOverridden() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsCanBeOverridden.kt"); + } + + @TestMetadata("mangledFunctionsDoNotClash.kt") + public void testMangledFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsDoNotClash.kt"); + } + + @TestMetadata("mangledFunctionsPresentInStackTrace.kt") + public void testMangledFunctionsPresentInStackTrace() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsPresentInStackTrace.kt"); + } + + @TestMetadata("mixedSignatureFunctionsDoNotClash.kt") + public void testMixedSignatureFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mixedSignatureFunctionsDoNotClash.kt"); + } + + @TestMetadata("overridingMethodInGenericClass.kt") + public void testOverridingMethodInGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass.kt"); + } + + @TestMetadata("overridingMethodInGenericClass2.kt") + public void testOverridingMethodInGenericClass2() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass2.kt"); + } + + @TestMetadata("propertySetterWithInlineClassTypeArgument.kt") + public void testPropertySetterWithInlineClassTypeArgument() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/propertySetterWithInlineClassTypeArgument.kt"); + } + + @TestMetadata("reflectionForFunctionWithMangledName.kt") + public void testReflectionForFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt"); + } + + @TestMetadata("reflectionForLocalClassInFunctionWithMangledName.kt") + public void testReflectionForLocalClassInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForLocalClassInFunctionWithMangledName.kt"); + } + + @TestMetadata("reflectionForPropertyOfInlineClassType.kt") + public void testReflectionForPropertyOfInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForPropertyOfInlineClassType.kt"); + } + + @TestMetadata("syntheticAccessorForFunctionWithMangledName.kt") + public void testSyntheticAccessorForFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorForFunctionWithMangledName.kt"); + } + + @TestMetadata("syntheticAccessorsForPropertyOfInlineClassType.kt") + public void testSyntheticAccessorsForPropertyOfInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index e2148077901..a8f830ce18b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -11757,6 +11757,104 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testUseThisInsideInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/useThisInsideInlineClass.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionNameMangling extends AbstractIrBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInFunctionNameMangling() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/functionNameMangling"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); + } + + @TestMetadata("anonymousObjectInFunctionWithMangledName.kt") + public void testAnonymousObjectInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/anonymousObjectInFunctionWithMangledName.kt"); + } + + @TestMetadata("extensionFunctionsDoNotClash.kt") + public void testExtensionFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/extensionFunctionsDoNotClash.kt"); + } + + @TestMetadata("functionsWithDifferentNullabilityDoNotClash.kt") + public void testFunctionsWithDifferentNullabilityDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/functionsWithDifferentNullabilityDoNotClash.kt"); + } + + @TestMetadata("genericFunctionsDoNotClash.kt") + public void testGenericFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/genericFunctionsDoNotClash.kt"); + } + + @TestMetadata("localClassInFunctionWithMangledName.kt") + public void testLocalClassInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/localClassInFunctionWithMangledName.kt"); + } + + @TestMetadata("mangledFunctionsCanBeOverridden.kt") + public void testMangledFunctionsCanBeOverridden() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsCanBeOverridden.kt"); + } + + @TestMetadata("mangledFunctionsDoNotClash.kt") + public void testMangledFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsDoNotClash.kt"); + } + + @TestMetadata("mangledFunctionsPresentInStackTrace.kt") + public void testMangledFunctionsPresentInStackTrace() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsPresentInStackTrace.kt"); + } + + @TestMetadata("mixedSignatureFunctionsDoNotClash.kt") + public void testMixedSignatureFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mixedSignatureFunctionsDoNotClash.kt"); + } + + @TestMetadata("overridingMethodInGenericClass.kt") + public void testOverridingMethodInGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass.kt"); + } + + @TestMetadata("overridingMethodInGenericClass2.kt") + public void testOverridingMethodInGenericClass2() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass2.kt"); + } + + @TestMetadata("propertySetterWithInlineClassTypeArgument.kt") + public void testPropertySetterWithInlineClassTypeArgument() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/propertySetterWithInlineClassTypeArgument.kt"); + } + + @TestMetadata("reflectionForFunctionWithMangledName.kt") + public void testReflectionForFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt"); + } + + @TestMetadata("reflectionForLocalClassInFunctionWithMangledName.kt") + public void testReflectionForLocalClassInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForLocalClassInFunctionWithMangledName.kt"); + } + + @TestMetadata("reflectionForPropertyOfInlineClassType.kt") + public void testReflectionForPropertyOfInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForPropertyOfInlineClassType.kt"); + } + + @TestMetadata("syntheticAccessorForFunctionWithMangledName.kt") + public void testSyntheticAccessorForFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorForFunctionWithMangledName.kt"); + } + + @TestMetadata("syntheticAccessorsForPropertyOfInlineClassType.kt") + public void testSyntheticAccessorsForPropertyOfInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt index 1002bf70322..8035e2cef3f 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt @@ -286,7 +286,7 @@ fun computeInternalName( private fun getContainer(container: DeclarationDescriptor?): DeclarationDescriptor? = container as? ClassDescriptor ?: container as? PackageFragmentDescriptor ?: container?.let { getContainer(it.containingDeclaration) } -private fun getRepresentativeUpperBound(descriptor: TypeParameterDescriptor): KotlinType { +fun getRepresentativeUpperBound(descriptor: TypeParameterDescriptor): KotlinType { val upperBounds = descriptor.upperBounds assert(!upperBounds.isEmpty()) { "Upper bounds should not be empty: $descriptor" } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java index 735b4e7c8b6..f48c4e903cd 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java @@ -10307,6 +10307,104 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { public void testUseThisInsideInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/useThisInsideInlineClass.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionNameMangling extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInFunctionNameMangling() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/functionNameMangling"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); + } + + @TestMetadata("anonymousObjectInFunctionWithMangledName.kt") + public void testAnonymousObjectInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/anonymousObjectInFunctionWithMangledName.kt"); + } + + @TestMetadata("extensionFunctionsDoNotClash.kt") + public void testExtensionFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/extensionFunctionsDoNotClash.kt"); + } + + @TestMetadata("functionsWithDifferentNullabilityDoNotClash.kt") + public void testFunctionsWithDifferentNullabilityDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/functionsWithDifferentNullabilityDoNotClash.kt"); + } + + @TestMetadata("genericFunctionsDoNotClash.kt") + public void testGenericFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/genericFunctionsDoNotClash.kt"); + } + + @TestMetadata("localClassInFunctionWithMangledName.kt") + public void testLocalClassInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/localClassInFunctionWithMangledName.kt"); + } + + @TestMetadata("mangledFunctionsCanBeOverridden.kt") + public void testMangledFunctionsCanBeOverridden() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsCanBeOverridden.kt"); + } + + @TestMetadata("mangledFunctionsDoNotClash.kt") + public void testMangledFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsDoNotClash.kt"); + } + + @TestMetadata("mangledFunctionsPresentInStackTrace.kt") + public void testMangledFunctionsPresentInStackTrace() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsPresentInStackTrace.kt"); + } + + @TestMetadata("mixedSignatureFunctionsDoNotClash.kt") + public void testMixedSignatureFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mixedSignatureFunctionsDoNotClash.kt"); + } + + @TestMetadata("overridingMethodInGenericClass.kt") + public void testOverridingMethodInGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass.kt"); + } + + @TestMetadata("overridingMethodInGenericClass2.kt") + public void testOverridingMethodInGenericClass2() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass2.kt"); + } + + @TestMetadata("propertySetterWithInlineClassTypeArgument.kt") + public void testPropertySetterWithInlineClassTypeArgument() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/propertySetterWithInlineClassTypeArgument.kt"); + } + + @TestMetadata("reflectionForFunctionWithMangledName.kt") + public void testReflectionForFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt"); + } + + @TestMetadata("reflectionForLocalClassInFunctionWithMangledName.kt") + public void testReflectionForLocalClassInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForLocalClassInFunctionWithMangledName.kt"); + } + + @TestMetadata("reflectionForPropertyOfInlineClassType.kt") + public void testReflectionForPropertyOfInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForPropertyOfInlineClassType.kt"); + } + + @TestMetadata("syntheticAccessorForFunctionWithMangledName.kt") + public void testSyntheticAccessorForFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorForFunctionWithMangledName.kt"); + } + + @TestMetadata("syntheticAccessorsForPropertyOfInlineClassType.kt") + public void testSyntheticAccessorsForPropertyOfInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested") diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 3f2abde3472..be4d6d5ef48 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -11367,6 +11367,104 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { public void testUseThisInsideInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/useThisInsideInlineClass.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionNameMangling extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInFunctionNameMangling() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/functionNameMangling"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); + } + + @TestMetadata("anonymousObjectInFunctionWithMangledName.kt") + public void testAnonymousObjectInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/anonymousObjectInFunctionWithMangledName.kt"); + } + + @TestMetadata("extensionFunctionsDoNotClash.kt") + public void testExtensionFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/extensionFunctionsDoNotClash.kt"); + } + + @TestMetadata("functionsWithDifferentNullabilityDoNotClash.kt") + public void testFunctionsWithDifferentNullabilityDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/functionsWithDifferentNullabilityDoNotClash.kt"); + } + + @TestMetadata("genericFunctionsDoNotClash.kt") + public void testGenericFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/genericFunctionsDoNotClash.kt"); + } + + @TestMetadata("localClassInFunctionWithMangledName.kt") + public void testLocalClassInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/localClassInFunctionWithMangledName.kt"); + } + + @TestMetadata("mangledFunctionsCanBeOverridden.kt") + public void testMangledFunctionsCanBeOverridden() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsCanBeOverridden.kt"); + } + + @TestMetadata("mangledFunctionsDoNotClash.kt") + public void testMangledFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsDoNotClash.kt"); + } + + @TestMetadata("mangledFunctionsPresentInStackTrace.kt") + public void testMangledFunctionsPresentInStackTrace() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsPresentInStackTrace.kt"); + } + + @TestMetadata("mixedSignatureFunctionsDoNotClash.kt") + public void testMixedSignatureFunctionsDoNotClash() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mixedSignatureFunctionsDoNotClash.kt"); + } + + @TestMetadata("overridingMethodInGenericClass.kt") + public void testOverridingMethodInGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass.kt"); + } + + @TestMetadata("overridingMethodInGenericClass2.kt") + public void testOverridingMethodInGenericClass2() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass2.kt"); + } + + @TestMetadata("propertySetterWithInlineClassTypeArgument.kt") + public void testPropertySetterWithInlineClassTypeArgument() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/propertySetterWithInlineClassTypeArgument.kt"); + } + + @TestMetadata("reflectionForFunctionWithMangledName.kt") + public void testReflectionForFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt"); + } + + @TestMetadata("reflectionForLocalClassInFunctionWithMangledName.kt") + public void testReflectionForLocalClassInFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForLocalClassInFunctionWithMangledName.kt"); + } + + @TestMetadata("reflectionForPropertyOfInlineClassType.kt") + public void testReflectionForPropertyOfInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForPropertyOfInlineClassType.kt"); + } + + @TestMetadata("syntheticAccessorForFunctionWithMangledName.kt") + public void testSyntheticAccessorForFunctionWithMangledName() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorForFunctionWithMangledName.kt"); + } + + @TestMetadata("syntheticAccessorsForPropertyOfInlineClassType.kt") + public void testSyntheticAccessorsForPropertyOfInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/innerNested")