[LL API] Fix value capturing for multiple receivers

There were problem when 'this' bound symbol was used twice for a call

KT-61144
This commit is contained in:
Alexey Merkulov
2023-07-27 18:49:55 +02:00
committed by Space Team
parent 35eca56d32
commit 3d92d0d05f
20 changed files with 219 additions and 24 deletions
@@ -0,0 +1,16 @@
ContainingClass[name: <this>; isMutated: false; displayText: this@Test]
context(R|Ctx1|, R|Ctx2|)
class Test : R|kotlin/Any|
R|Test|
ContainingClass[name: <this>; isMutated: false; displayText: this@Test]
context(R|Ctx1|, R|Ctx2|)
class Test : R|kotlin/Any|
R|Test|
ContextReceiver[name: Ctx3; isMutated: false; displayText: this@Ctx3]
context(R|Ctx3|, R|Ctx4|)
fun foo(): R|kotlin/Unit|
R|Ctx3|
ContextReceiver[name: Ctx4; isMutated: false; displayText: this@Ctx4]
context(R|Ctx3|, R|Ctx4|)
fun foo(): R|kotlin/Unit|
R|Ctx4|
@@ -0,0 +1,21 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:<root>.Test, p1:<root>.Test, p2:<root>.Ctx3, p3:<root>.Ctx4) returnType:kotlin.Int
VALUE_PARAMETER name:p0 index:0 type:<root>.Test
VALUE_PARAMETER name:p1 index:1 type:<root>.Test
VALUE_PARAMETER name:p2 index:2 type:<root>.Ctx3
VALUE_PARAMETER name:p3 index:3 type:<root>.Ctx4
EXPRESSION_BODY
BLOCK type=kotlin.Int origin=null
CALL 'public final fun useWithCtx1Ctx2Ctx3Ctx4 ($context_receiver_0: <root>.Ctx1, $context_receiver_1: <root>.Ctx2, $context_receiver_2: <root>.Ctx3, $context_receiver_3: <root>.Ctx4): kotlin.Int declared in <root>.MultipleClassAndFunctionContextReceiversKt' type=kotlin.Int origin=null
$context_receiver_0: GET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:<root>.Ctx1 visibility:private [final]' type=<root>.Ctx1 origin=null
receiver: GET_VAR 'p0: <root>.Test declared in <root>.CodeFragment.run' type=<root>.Test origin=null
$context_receiver_1: GET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField1 type:<root>.Ctx2 visibility:private [final]' type=<root>.Ctx2 origin=null
receiver: GET_VAR 'p1: <root>.Test declared in <root>.CodeFragment.run' type=<root>.Test origin=null
$context_receiver_2: GET_VAR 'p2: <root>.Ctx3 declared in <root>.CodeFragment.run' type=<root>.Ctx3 origin=null
$context_receiver_3: GET_VAR 'p3: <root>.Ctx4 declared in <root>.CodeFragment.run' type=<root>.Ctx4 origin=null
@@ -0,0 +1,16 @@
// !LANGUAGE: +ContextReceivers
class Ctx1
class Ctx2
class Ctx3
class Ctx4
context(Ctx1, Ctx2, Ctx3, Ctx4)
fun useWithCtx1Ctx2Ctx3Ctx4() = 3
context(Ctx1, Ctx2)
class Test {
context(Ctx3, Ctx4)
fun foo() {
<caret>val x = 1
}
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: Test, p1: Test, p2: Ctx3, p3: Ctx4): int
}
@@ -0,0 +1,8 @@
ContainingClass[name: <this>; isMutated: false; displayText: this@Test]
context(R|Ctx1|, R|Ctx2|)
class Test : R|kotlin/Any|
R|Test|
ContainingClass[name: <this>; isMutated: false; displayText: this@Test]
context(R|Ctx1|, R|Ctx2|)
class Test : R|kotlin/Any|
R|Test|
@@ -0,0 +1,17 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:<root>.Test, p1:<root>.Test) returnType:kotlin.Int
VALUE_PARAMETER name:p0 index:0 type:<root>.Test
VALUE_PARAMETER name:p1 index:1 type:<root>.Test
EXPRESSION_BODY
BLOCK type=kotlin.Int origin=null
CALL 'public final fun useWithCtx1Ctx2 ($context_receiver_0: <root>.Ctx1, $context_receiver_1: <root>.Ctx2): kotlin.Int declared in <root>.MultipleClassContextReceiversKt' type=kotlin.Int origin=null
$context_receiver_0: GET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:<root>.Ctx1 visibility:private [final]' type=<root>.Ctx1 origin=null
receiver: GET_VAR 'p0: <root>.Test declared in <root>.CodeFragment.run' type=<root>.Test origin=null
$context_receiver_1: GET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField1 type:<root>.Ctx2 visibility:private [final]' type=<root>.Ctx2 origin=null
receiver: GET_VAR 'p1: <root>.Test declared in <root>.CodeFragment.run' type=<root>.Test origin=null
@@ -0,0 +1,13 @@
// !LANGUAGE: +ContextReceivers
class Ctx1
class Ctx2
context(Ctx1, Ctx2)
fun useWithCtx1Ctx2() = 3
context(Ctx1, Ctx2)
class Test {
fun foo() {
<caret>val x = 1
}
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: Test, p1: Test): int
}
@@ -0,0 +1,8 @@
ContextReceiver[name: Ctx1; isMutated: false; displayText: this@Ctx1]
context(R|Ctx1|, R|Ctx2|)
fun foo(): R|kotlin/Unit|
R|Ctx1|
ContextReceiver[name: Ctx2; isMutated: false; displayText: this@Ctx2]
context(R|Ctx1|, R|Ctx2|)
fun foo(): R|kotlin/Unit|
R|Ctx2|
@@ -0,0 +1,15 @@
MODULE_FRAGMENT name:<Sources of main>
FILE fqName:<root> fileName:/fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:<root>.Ctx1, p1:<root>.Ctx2) returnType:kotlin.Int
VALUE_PARAMETER name:p0 index:0 type:<root>.Ctx1
VALUE_PARAMETER name:p1 index:1 type:<root>.Ctx2
EXPRESSION_BODY
BLOCK type=kotlin.Int origin=null
CALL 'public final fun useWithCtx1Ctx2 ($context_receiver_0: <root>.Ctx1, $context_receiver_1: <root>.Ctx2): kotlin.Int declared in <root>.MultipleFunctionContextReceiversKt' type=kotlin.Int origin=null
$context_receiver_0: GET_VAR 'p0: <root>.Ctx1 declared in <root>.CodeFragment.run' type=<root>.Ctx1 origin=null
$context_receiver_1: GET_VAR 'p1: <root>.Ctx2 declared in <root>.CodeFragment.run' type=<root>.Ctx2 origin=null
@@ -0,0 +1,11 @@
// !LANGUAGE: +ContextReceivers
class Ctx1
class Ctx2
context(Ctx1, Ctx2)
fun useWithCtx1Ctx2() = 3
context(Ctx1, Ctx2)
fun foo() {
<caret>val x = 1
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: Ctx1, p1: Ctx2): int
}