[IR] Dump IdSignatures and mangled names in irText tests

The reason #1 for this feature is that we want to test IdSignatures
generated for declarations. Currently, there is no (easy) way to ensure
that a change in the signature building logic doesn't cause any breaking
changes wrt klibs.

Now, most IdSignatures include hashed mangled names in them, so even if
we catch a regression where the included hash changes, there would be no
way of knowing immediately what caused it, unless we'd also have mangled
names in the expectations.

The reason #2 is to test the manglers themselves. Currently, there are
no tests for them. They heavily duplicate each other, this is already
causing issues (see KT-57427) that would be very hard to catch without
these tests.

^KT-58238 Fixed
This commit is contained in:
Sergej Jaskiewicz
2023-04-06 15:07:36 +02:00
committed by Space Team
parent bccf69910d
commit 6e8283a6fe
791 changed files with 36162 additions and 357 deletions
@@ -0,0 +1,5 @@
// CHECK:
// Mangled name: #test(kotlin.Function0<kotlin.Unit>;java.lang.Runnable;kotlin.Array<kotlin.String>){}
// Public signature: /test|-6479681129946022977[0]
fun test(fn: Function0<Unit>, r: Runnable, arr: Array<String>): Unit
@@ -0,0 +1,5 @@
// CHECK:
// Mangled name: #test(){}
// Public signature: /test|6620506149988718649[0]
fun test(): Unit
@@ -0,0 +1,5 @@
// CHECK JVM_IR:
// Mangled name: #f(kotlin.Any){}kotlin.String
// Public signature: /f|7796856655889654815[0]
fun f(x: Any): String
@@ -1,5 +1,6 @@
// FIR_IDENTICAL
// TARGET_BACKEND: JVM
// FILE: samByProjectedType.kt
fun test1() {
H.bar { x: Any -> x }
@@ -13,4 +14,4 @@ public interface J<T> {
// FILE: H.java
public class H {
public static void bar(J<?> j) {}
}
}
@@ -0,0 +1,5 @@
// CHECK:
// Mangled name: #test1(){}
// Public signature: /test1|4297044443957252634[0]
fun test1(): Unit
@@ -0,0 +1,25 @@
// CHECK:
// Mangled name: #foo(){}
// Public signature: /foo|-1041209573719867811[0]
fun foo(): Unit
// CHECK JVM_IR:
// Mangled name: #test1(){}java.lang.Runnable
// Public signature: /test1|-613876279970827772[0]
fun test1(): Runnable
// CHECK JVM_IR:
// Mangled name: #test2(kotlin.Function0<kotlin.Unit>){}java.lang.Runnable
// Public signature: /test2|-6701609995382300258[0]
fun test2(a: Function0<Unit>): Runnable
// CHECK JVM_IR:
// Mangled name: #test3(){}java.lang.Runnable
// Public signature: /test3|-2297362667420108091[0]
fun test3(): Runnable
// CHECK JVM_IR:
// Mangled name: #test4(){}java.util.Comparator<kotlin.Int>
// Public signature: /test4|-6683954143544750623[0]
fun test4(): Comparator<Int>
@@ -1,5 +1,9 @@
// FIR_IDENTICAL
// TARGET_BACKEND: JVM
// MUTE_SIGNATURE_COMPARISON_K2: ANY
// ^ KT-57429
// FILE: samConversionInGenericConstructorCall.kt
fun test3(
f1: (String) -> String,
@@ -0,0 +1,60 @@
// CHECK:
// Mangled name: Outer
// Public signature: /Outer|null[0]
class Outer<T1 : Any?> {
// CHECK:
// Mangled name: Outer{}j11
// Public signature: /Outer.j11|3042103907784946942[0]
val j11: J<T1, T1>
// CHECK JVM_IR:
// Mangled name: Outer#<get-j11>(){}J<1:0,1:0>
// Public signature: /Outer.j11.<get-j11>|1291746945058754296[0]
get
// CHECK:
// Mangled name: Outer.Inner
// Public signature: /Outer.Inner|null[0]
inner class Inner<T2 : Any?> {
// CHECK:
// Mangled name: Outer.Inner{}j12
// Public signature: /Outer.Inner.j12|8035547960084394556[0]
val j12: J<T1, T2>
// CHECK JVM_IR:
// Mangled name: Outer.Inner#<get-j12>(){}J<2:0,1:0>
// Public signature: /Outer.Inner.j12.<get-j12>|-5099511302970927970[0]
get
// CHECK:
// Mangled name: Outer.Inner#<init>(J<2:0,1:0>){}
// Public signature: /Outer.Inner.<init>|-1839564309215892252[0]
constructor(j12: J<T1, T2>) /* primary */
}
// CHECK:
// Mangled name: Outer#<init>(J<1:0,1:0>){}
// Public signature: /Outer.<init>|3621221723434232230[0]
constructor(j11: J<T1, T1>) /* primary */
}
// CHECK JVM_IR:
// Mangled name: #test3(kotlin.Function1<kotlin.String,kotlin.String>;kotlin.Function1<kotlin.Int,kotlin.String>){}C.D<kotlin.Int?,kotlin.String?>
// Public signature: /test3|-179639781639450333[0]
fun test3(f1: Function1<String, String>, f2: Function1<Int, String>): D<Int?, String?>
// CHECK JVM_IR:
// Mangled name: #test4(kotlin.Function1<kotlin.String,kotlin.String>;kotlin.Function1<kotlin.Any,kotlin.String>){}Outer.Inner<kotlin.Any?,kotlin.String?>
// Public signature: /test4|7503778563590790519[0]
fun test4(f: Function1<String, String>, g: Function1<Any, String>): Inner<Any?, String?>
// CHECK JVM_IR:
// Mangled name: #testGenericJavaCtor1(kotlin.Function1<kotlin.String,kotlin.Int>){}G<kotlin.String?>
// Public signature: /testGenericJavaCtor1|8726720168953319778[0]
fun testGenericJavaCtor1(f: Function1<String, Int>): G<String?>
// CHECK:
// Mangled name: #testGenericJavaCtor2(kotlin.Any){}
// Public signature: /testGenericJavaCtor2|-6916979209934908350[0]
fun testGenericJavaCtor2(x: Any): Unit
@@ -0,0 +1,50 @@
// CHECK JVM_IR:
// Mangled name: #test1(){}J<kotlin.String>
// Public signature: /test1|8889900013954121507[0]
fun test1(): J<String>
// CHECK:
// Mangled name: #test10(kotlin.Function1<kotlin.Int,kotlin.String>){}
// Public signature: /test10|3769162614537259024[0]
fun test10(fn: Function1<Int, String>): Unit
// CHECK JVM_IR:
// Mangled name: #test2(){}J<kotlin.String?>
// Public signature: /test2|-2485267088492515783[0]
fun test2(): J<String?>
// CHECK:
// Mangled name: #test3(){}
// Public signature: /test3|-3759735065270951803[0]
fun test3(): Unit
// CHECK:
// Mangled name: #test4(kotlin.Any){}
// Public signature: /test4|-9023258848991787985[0]
fun test4(a: Any): Unit
// CHECK:
// Mangled name: #test5(kotlin.Any){}
// Public signature: /test5|4504681808078971124[0]
fun test5(a: Any): Unit
// CHECK:
// Mangled name: #test6(kotlin.Function1<0:0,0:0>){0§<kotlin.Any?>}
// Public signature: /test6|-3081320997310711341[0]
fun <T : Any?> test6(a: Function1<T, T>): Unit
// CHECK:
// Mangled name: #test7(kotlin.Any){0§<kotlin.Any?>}
// Public signature: /test7|-5359981114052378429[0]
fun <T : Any?> test7(a: Any): Unit
// CHECK JVM_IR:
// Mangled name: #test8(kotlin.Function1<kotlin.String,kotlin.String>){}J<kotlin.String?>
// Public signature: /test8|-6112132748185879177[0]
fun test8(efn: @ExtensionFunctionType Function1<String, String>): J<String?>
// CHECK:
// Mangled name: #test9(kotlin.Function1<kotlin.String,kotlin.String>){}
// Public signature: /test9|5682079641444556672[0]
fun test9(efn: @ExtensionFunctionType Function1<String, String>): Unit
@@ -1,6 +1,7 @@
// FIR_IDENTICAL
// TARGET_BACKEND: JVM
// WITH_JDK
// FILE: samConversions.kt
fun J.test0(a: Runnable) {
J.runStatic(a)
@@ -30,4 +31,4 @@ public class J {
public void runIt(Runnable r) {}
public void run2(Runnable r1, Runnable r2) {}
}
}
@@ -0,0 +1,25 @@
// CHECK:
// Mangled name: #test0@J(java.lang.Runnable){}
// Public signature: /test0|7082314898497215723[0]
fun J.test0(a: Runnable): Unit
// CHECK:
// Mangled name: #test1(){}
// Public signature: /test1|4297044443957252634[0]
fun test1(): Unit
// CHECK:
// Mangled name: #test2@J(){}
// Public signature: /test2|-509977306549568233[0]
fun J.test2(): Unit
// CHECK:
// Mangled name: #test3@J(kotlin.Function0<kotlin.Unit>){}
// Public signature: /test3|3795186268197616186[0]
fun J.test3(a: Function0<Unit>): Unit
// CHECK:
// Mangled name: #test4@J(kotlin.Function0<kotlin.Unit>;kotlin.Function0<kotlin.Unit>;kotlin.Boolean){}
// Public signature: /test4|-7934218580139307891[0]
fun J.test4(a: Function0<Unit>, b: Function0<Unit>, flag: Boolean): Unit
@@ -0,0 +1,50 @@
// CHECK:
// Mangled name: #test1(kotlin.Function0<kotlin.Unit>){}
// Public signature: /test1|-2870537507416699845[0]
fun test1(a: Function0<Unit>): Unit
// CHECK:
// Mangled name: #test2(kotlin.Function0<kotlin.Unit>){}
// Public signature: /test2|-8241603768593447441[0]
fun test2(a: Function0<Unit>): Unit
// CHECK:
// Mangled name: #test3(kotlin.Function0<kotlin.Unit>){}
// Public signature: /test3|-1760685804488672424[0]
fun test3(a: Function0<Unit>): Unit
// CHECK:
// Mangled name: #test4(kotlin.Function0<kotlin.Unit>;kotlin.Function0<kotlin.Unit>){}
// Public signature: /test4|1443124276429499957[0]
fun test4(a: Function0<Unit>, b: Function0<Unit>): Unit
// CHECK:
// Mangled name: #test5(kotlin.Any){}
// Public signature: /test5|4504681808078971124[0]
fun test5(a: Any): Unit
// CHECK:
// Mangled name: #test5x(kotlin.Any){}
// Public signature: /test5x|8044678810048210306[0]
fun test5x(a: Any): Unit
// CHECK:
// Mangled name: #test6(kotlin.Any){}
// Public signature: /test6|-7590017673454141671[0]
fun test6(a: Any): Unit
// CHECK:
// Mangled name: #test7(kotlin.Function1<kotlin.Int,kotlin.Int>){}
// Public signature: /test7|1095013294548842913[0]
fun test7(a: Function1<Int, Int>): Unit
// CHECK:
// Mangled name: #test8(kotlin.Function0<kotlin.Unit>){}
// Public signature: /test8|8321269803549472585[0]
fun test8(a: Function0<Unit>): Unit
// CHECK:
// Mangled name: #test9(){}
// Public signature: /test9|9214787561267119658[0]
fun test9(): Unit
@@ -0,0 +1,20 @@
// CHECK:
// Mangled name: #f(){}
// Public signature: /f|5316533450599009716[0]
fun f(): Unit
// CHECK:
// Mangled name: #test1@J(){}
// Public signature: /test1|6869262091258899204[0]
fun J.test1(): Unit
// CHECK:
// Mangled name: #test2@J(){}
// Public signature: /test2|-509977306549568233[0]
fun J.test2(): Unit
// CHECK:
// Mangled name: #test3@J(){}
// Public signature: /test3|-2284942743287682332[0]
fun J.test3(): Unit