[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
@@ -2,6 +2,9 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// MUTE_SIGNATURE_COMPARISON_K2: ANY
// ^ KT-57435
interface Canvas {
val suffix: String
}
@@ -0,0 +1,71 @@
// CHECK:
// Mangled name: Circle
// Public signature: /Circle|null[0]
class Circle : Shape {
// CHECK:
// Mangled name: Circle#<init>(){}
// Public signature: /Circle.<init>|-5645683436151566731[0]
constructor() /* primary */
// CHECK JVM_IR:
// Mangled name computed from Ir: Circle#draw(Canvas){}kotlin.String
// Mangled name computed from Descriptor: Circle#draw!Canvas(){}kotlin.String
// Public signature: /Circle.draw|-6733499063990640842[0]
override fun draw($context_receiver_0: Canvas): String
}
// CHECK:
// Mangled name: Canvas
// Public signature: /Canvas|null[0]
interface Canvas {
// CHECK:
// Mangled name: Canvas{}suffix
// Public signature: /Canvas.suffix|-3301965527200666288[0]
abstract val suffix: String
// CHECK JVM_IR:
// Mangled name: Canvas#<get-suffix>(){}kotlin.String
// Public signature: /Canvas.suffix.<get-suffix>|8958072538558116778[0]
abstract get
}
// CHECK:
// Mangled name: Shape
// Public signature: /Shape|null[0]
interface Shape {
// CHECK JVM_IR:
// Mangled name computed from Ir: Shape#draw(Canvas){}kotlin.String
// Mangled name computed from Descriptor: Shape#draw!Canvas(){}kotlin.String
// Public signature: /Shape.draw|-6733499063990640842[0]
abstract fun draw($context_receiver_0: Canvas): String
}
// CHECK:
// Mangled name: MyCanvas
// Public signature: /MyCanvas|null[0]
object MyCanvas : Canvas {
// CHECK:
// Mangled name: MyCanvas{}suffix
// Public signature: /MyCanvas.suffix|-3301965527200666288[0]
override val suffix: String
// CHECK JVM_IR:
// Mangled name: MyCanvas#<get-suffix>(){}kotlin.String
// Public signature: /MyCanvas.suffix.<get-suffix>|8958072538558116778[0]
override get
// CHECK:
// Mangled name: MyCanvas#<init>(){}
// Public signature: /MyCanvas.<init>|-5645683436151566731[0]
private constructor() /* primary */
}
// CHECK JVM_IR:
// Mangled name: #box(){}kotlin.String
// Public signature: /box|-9347091776561469[0]
fun box(): String
@@ -1,6 +1,9 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// MUTE_SIGNATURE_COMPARISON_K2: ANY
// ^ KT-57429, KT-57435
data class Pair<A, B>(val first: A, val second: B)
context(Comparator<T>)
@@ -0,0 +1,79 @@
// CHECK:
// Mangled name: Pair
// Public signature: /Pair|null[0]
data class Pair<A : Any?, B : Any?> {
// CHECK:
// Mangled name: Pair{}first
// Public signature: /Pair.first|1497393077339299626[0]
val first: A
// CHECK JVM_IR:
// Mangled name: Pair#<get-first>(){}1:0
// Public signature: /Pair.first.<get-first>|-2355525345180386541[0]
get
// CHECK:
// Mangled name: Pair{}second
// Public signature: /Pair.second|8934636033843101515[0]
val second: B
// CHECK JVM_IR:
// Mangled name: Pair#<get-second>(){}1:1
// Public signature: /Pair.second.<get-second>|-7108495346814383827[0]
get
// CHECK:
// Mangled name: Pair#<init>(1:0;1:1){}
// Public signature: /Pair.<init>|3086114026882374588[0]
constructor(first: A, second: B) /* primary */
// CHECK JVM_IR:
// Mangled name: Pair#component1(){}1:0
// Public signature: /Pair.component1|2393470133763651536[0]
operator fun component1(): A
// CHECK JVM_IR:
// Mangled name: Pair#component2(){}1:1
// Public signature: /Pair.component2|319033347667924570[0]
operator fun component2(): B
// CHECK JVM_IR:
// Mangled name: Pair#copy(1:0;1:1){}Pair<1:0,1:1>
// Public signature: /Pair.copy|7298985996422673194[0]
fun copy(first: A, second: B): Pair<A, B>
// CHECK JVM_IR:
// Mangled name: Pair#equals(kotlin.Any?){}kotlin.Boolean
// Public signature: /Pair.equals|722809408929142791[0]
override operator fun equals(other: Any?): Boolean
// CHECK JVM_IR:
// Mangled name: Pair#hashCode(){}kotlin.Int
// Public signature: /Pair.hashCode|-8048879360829830756[0]
override fun hashCode(): Int
// CHECK JVM_IR:
// Mangled name: Pair#toString(){}kotlin.String
// Public signature: /Pair.toString|6958853723545266802[0]
override fun toString(): String
}
// CHECK JVM_IR:
// Mangled name: #box(){}kotlin.String
// Public signature: /box|-9347091776561469[0]
fun box(): String
// CHECK JVM_IR:
// Mangled name computed from Ir: #compareTo@0:0(java.util.Comparator<0:0>;0:0){0§<kotlin.Any?>}kotlin.Int
// Mangled name computed from Descriptor: #compareTo!java.util.Comparator<0:0>@0:0(0:0){0§<kotlin.Any?>}kotlin.Int
// Public signature: /compareTo|-4091974102091923679[0]
infix operator fun <T : Any?> T.compareTo($context_receiver_0: Comparator<T>, other: T): Int
// CHECK:
// Mangled name: @Pair<0:0,0:0>{0§<kotlin.Any?>}min
// Public signature: /min|6885845668930107919[0]
val <T : Any?> Pair<T, T>.min: T
// CHECK JVM_IR:
// Mangled name computed from Ir: #<get-min>@Pair<0:0,0:0>(java.util.Comparator<0:0>){0§<kotlin.Any?>}0:0
// Mangled name computed from Descriptor: #<get-min>!java.util.Comparator<0:0>@Pair<0:0,0:0>(){0§<kotlin.Any?>}0:0
// Public signature: /min.<get-min>|6404877126791863503[0]
get($context_receiver_0: Comparator<T>): T
@@ -2,6 +2,9 @@
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// MUTE_SIGNATURE_COMPARISON_K2: ANY
// ^ KT-57435
class View {
val coefficient = 42
}
@@ -0,0 +1,35 @@
// CHECK:
// Mangled name: View
// Public signature: /View|null[0]
class View {
// CHECK:
// Mangled name: View{}coefficient
// Public signature: /View.coefficient|4563127391682800227[0]
val coefficient: Int
// CHECK JVM_IR:
// Mangled name: View#<get-coefficient>(){}kotlin.Int
// Public signature: /View.coefficient.<get-coefficient>|2286291581442465794[0]
get
// CHECK:
// Mangled name: View#<init>(){}
// Public signature: /View.<init>|-5645683436151566731[0]
constructor() /* primary */
}
// CHECK JVM_IR:
// Mangled name: #box(){}kotlin.String
// Public signature: /box|-9347091776561469[0]
fun box(): String
// CHECK:
// Mangled name: @kotlin.Int{}dp
// Public signature: /dp|-4245635280375224248[0]
val Int.dp: Int
// CHECK JVM_IR:
// Mangled name computed from Ir: #<get-dp>@kotlin.Int(View){}kotlin.Int
// Mangled name computed from Descriptor: #<get-dp>!View@kotlin.Int(){}kotlin.Int
// Public signature: /dp.<get-dp>|933397372434095199[0]
get($context_receiver_0: View): Int
@@ -1,6 +1,9 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// MUTE_SIGNATURE_COMPARISON_K2: ANY
// ^ KT-57435
class Param
class O {
val o = "O"
@@ -0,0 +1,62 @@
// CHECK:
// Mangled name: K
// Public signature: /K|null[0]
class K {
// CHECK:
// Mangled name: K{}k
// Public signature: /K.k|2162811783424158931[0]
val k: String
// CHECK JVM_IR:
// Mangled name: K#<get-k>(){}kotlin.String
// Public signature: /K.k.<get-k>|-8248201737917988340[0]
get
// CHECK:
// Mangled name: K#<init>(){}
// Public signature: /K.<init>|-5645683436151566731[0]
constructor() /* primary */
}
// CHECK:
// Mangled name: O
// Public signature: /O|null[0]
class O {
// CHECK:
// Mangled name: O{}o
// Public signature: /O.o|-5332571409865440260[0]
val o: String
// CHECK JVM_IR:
// Mangled name: O#<get-o>(){}kotlin.String
// Public signature: /O.o.<get-o>|2606027183154875572[0]
get
// CHECK:
// Mangled name: O#<init>(){}
// Public signature: /O.<init>|-5645683436151566731[0]
constructor() /* primary */
}
// CHECK:
// Mangled name: Param
// Public signature: /Param|null[0]
class Param {
// CHECK:
// Mangled name: Param#<init>(){}
// Public signature: /Param.<init>|-5645683436151566731[0]
constructor() /* primary */
}
// CHECK JVM_IR:
// Mangled name: #box(){}kotlin.String
// Public signature: /box|-9347091776561469[0]
fun box(): String
// CHECK JVM_IR:
// Mangled name computed from Ir: #f@K(O;kotlin.Function3<O,K,Param,0:0>){0§<kotlin.Any?>}0:0
// Mangled name computed from Descriptor: #f!O@K(kotlin.Function3<O,K,Param,0:0>){0§<kotlin.Any?>}0:0
// Public signature: /f|-7653040485655702379[0]
fun <T : Any?> K.f($context_receiver_0: O, g: @ExtensionFunctionType Function3<O, K, Param, T>): T
@@ -2,6 +2,9 @@
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// MUTE_SIGNATURE_COMPARISON_K2: ANY
// ^ KT-57435
interface Semigroup<T> {
infix fun T.combine(other: T): T
}
@@ -0,0 +1,93 @@
// CHECK:
// Mangled name: Monoid
// Public signature: /Monoid|null[0]
interface Monoid<T : Any?> : Semigroup<T> {
// CHECK JVM_IR:
// Mangled name: Monoid#combine@1:0(1:0){}1:0
// Public signature: /Monoid.combine|-3517256775590682507[0]
abstract /* fake */ override infix fun T.combine(other: T): T
// CHECK:
// Mangled name: Monoid{}unit
// Public signature: /Monoid.unit|-5200734743185576787[0]
abstract val unit: T
// CHECK JVM_IR:
// Mangled name: Monoid#<get-unit>(){}1:0
// Public signature: /Monoid.unit.<get-unit>|-2842189358620964971[0]
abstract get
}
// CHECK:
// Mangled name: Semigroup
// Public signature: /Semigroup|null[0]
interface Semigroup<T : Any?> {
// CHECK JVM_IR:
// Mangled name: Semigroup#combine@1:0(1:0){}1:0
// Public signature: /Semigroup.combine|-3517256775590682507[0]
abstract infix fun T.combine(other: T): T
}
// CHECK:
// Mangled name: IntMonoid
// Public signature: /IntMonoid|null[0]
object IntMonoid : Monoid<Int> {
// CHECK:
// Mangled name: IntMonoid{}unit
// Public signature: /IntMonoid.unit|-5200734743185576787[0]
override val unit: Int
// CHECK JVM_IR:
// Mangled name: IntMonoid#<get-unit>(){}kotlin.Int
// Public signature: /IntMonoid.unit.<get-unit>|3772729924213749256[0]
override get
// CHECK:
// Mangled name: IntMonoid#<init>(){}
// Public signature: /IntMonoid.<init>|-5645683436151566731[0]
private constructor() /* primary */
// CHECK JVM_IR:
// Mangled name: IntMonoid#combine@kotlin.Int(kotlin.Int){}kotlin.Int
// Public signature: /IntMonoid.combine|4765448259581317405[0]
override infix fun Int.combine(other: Int): Int
}
// CHECK:
// Mangled name: StringMonoid
// Public signature: /StringMonoid|null[0]
object StringMonoid : Monoid<String> {
// CHECK:
// Mangled name: StringMonoid{}unit
// Public signature: /StringMonoid.unit|-5200734743185576787[0]
override val unit: String
// CHECK JVM_IR:
// Mangled name: StringMonoid#<get-unit>(){}kotlin.String
// Public signature: /StringMonoid.unit.<get-unit>|4504480110251605077[0]
override get
// CHECK:
// Mangled name: StringMonoid#<init>(){}
// Public signature: /StringMonoid.<init>|-5645683436151566731[0]
private constructor() /* primary */
// CHECK JVM_IR:
// Mangled name: StringMonoid#combine@kotlin.String(kotlin.String){}kotlin.String
// Public signature: /StringMonoid.combine|-5815259829474546918[0]
override infix fun String.combine(other: String): String
}
// CHECK JVM_IR:
// Mangled name: #box(){}kotlin.String
// Public signature: /box|-9347091776561469[0]
fun box(): String
// CHECK JVM_IR:
// Mangled name computed from Ir: #sum@kotlin.collections.List<0:0>(Monoid<0:0>){0§<kotlin.Any?>}0:0
// Mangled name computed from Descriptor: #sum!Monoid<0:0>@kotlin.collections.List<0:0>(){0§<kotlin.Any?>}0:0
// Public signature: /sum|7635142307973834922[0]
fun <T : Any?> List<T>.sum($context_receiver_0: Monoid<T>): T