[FIR, IR] Fix name mangling for functions with context receivers

- Mangled names of property accessors now include context receiver
  types of the corresponding property when computed from FIR.
- Context receivers are now supported when computing mangled names
  from IR
- IrBasedDescriptors now account for context receivers

^KT-57435 Fixed
This commit is contained in:
Sergej Jaskiewicz
2023-04-11 17:23:10 +02:00
committed by Space Team
parent 5700212119
commit 1a29b9efff
56 changed files with 120 additions and 199 deletions
@@ -2,9 +2,6 @@
// !LANGUAGE: +ContextReceivers
// IGNORE_BACKEND: JS_IR
// MUTE_SIGNATURE_COMPARISON_K2: ANY
// ^ KT-57435
interface Canvas {
val suffix: String
}
@@ -8,8 +8,7 @@ class Circle : Shape {
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
// Mangled name: Circle#draw!Canvas(){}kotlin.String
// Public signature: /Circle.draw|-6733499063990640842[0]
override fun draw($context_receiver_0: Canvas): String
@@ -37,8 +36,7 @@ interface Canvas {
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
// Mangled name: Shape#draw!Canvas(){}kotlin.String
// Public signature: /Shape.draw|-6733499063990640842[0]
abstract fun draw($context_receiver_0: Canvas): String
@@ -2,7 +2,7 @@
// IGNORE_BACKEND: JS_IR
// MUTE_SIGNATURE_COMPARISON_K2: ANY
// ^ KT-57429, KT-57435
// ^ KT-57429
data class Pair<A, B>(val first: A, val second: B)
@@ -62,8 +62,7 @@ data class Pair<A : Any?, B : Any?> {
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
// Mangled name: #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
@@ -72,8 +71,7 @@ infix operator fun <T : Any?> T.compareTo($context_receiver_0: Comparator<T>, ot
// 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
// Mangled name: #<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
@@ -1,10 +1,6 @@
// !LANGUAGE: +ContextReceivers
// IGNORE_BACKEND: JS_IR
// WITH_STDLIB
// MUTE_SIGNATURE_COMPARISON_K2: ANY
// ^ KT-57435
class View {
val coefficient = 42
}
@@ -28,8 +28,7 @@ fun box(): String
// 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
// Mangled name: #<get-dp>!View@kotlin.Int(){}kotlin.Int
// Public signature: /dp.<get-dp>|933397372434095199[0]
get($context_receiver_0: View): Int
@@ -1,9 +1,6 @@
// !LANGUAGE: +ContextReceivers
// IGNORE_BACKEND: JS_IR
// MUTE_SIGNATURE_COMPARISON_K2: ANY
// ^ KT-57435
class Param
class O {
val o = "O"
@@ -55,8 +55,7 @@ class Param {
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
// Mangled name: #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
@@ -1,10 +1,6 @@
// !LANGUAGE: +ContextReceivers
// IGNORE_BACKEND: JS_IR
// WITH_STDLIB
// MUTE_SIGNATURE_COMPARISON_K2: ANY
// ^ KT-57435
interface Semigroup<T> {
infix fun T.combine(other: T): T
}
@@ -86,8 +86,7 @@ object StringMonoid : Monoid<String> {
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
// Mangled name: #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