From 3024ec3da3ba5d5f3ba3cf28209cfaee043d479a Mon Sep 17 00:00:00 2001 From: Nikolay Lunyak Date: Mon, 22 Jan 2024 17:51:16 +0200 Subject: [PATCH] [FIR] Add // FIR_DUMP to some implicit invoke tests Although these dumps don't really show if something is a `FirFunctionCall` or a `FirImplicitInvokeCall`, they do show what goes into the receiver, and what are value arguments. --- ...expressionsInQaSelectorsCornerCases.fir.kt | 1 + ...xpressionsInQaSelectorsCornerCases.fir.txt | 29 +++++++++++++++++++ .../expressionsInQaSelectorsCornerCases.kt | 1 + ...ionsInQaSelectorsReceiverConversion.fir.kt | 1 + ...onsInQaSelectorsReceiverConversion.fir.txt | 4 +++ ...ressionsInQaSelectorsReceiverConversion.kt | 1 + .../expressionsInQaSelectorsWithElvis.fir.txt | 4 +++ .../expressionsInQaSelectorsWithElvis.kt | 1 + .../receiverPresenceErrorForInvoke.fir.kt | 2 ++ .../receiverPresenceErrorForInvoke.fir.txt | 9 ++++++ .../errors/receiverPresenceErrorForInvoke.kt | 2 ++ .../wrongReceiverForInvokeOnExpression.fir.kt | 1 + ...wrongReceiverForInvokeOnExpression.fir.txt | 25 ++++++++++++++++ .../wrongReceiverForInvokeOnExpression.kt | 2 ++ 14 files changed, 83 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.fir.txt create mode 100644 compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.fir.txt create mode 100644 compiler/testData/diagnostics/tests/expressionsInQaSelectorsWithElvis.fir.txt create mode 100644 compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.txt create mode 100644 compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.txt diff --git a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.fir.kt b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.fir.kt index 3ebfd1d02e7..5a3c55a3445 100644 --- a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.fir.kt +++ b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.fir.kt @@ -1,4 +1,5 @@ // ISSUE: KT-64891 +// FIR_DUMP fun T.b(): Int = 10 diff --git a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.fir.txt b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.fir.txt new file mode 100644 index 00000000000..235fc744ec0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.fir.txt @@ -0,0 +1,29 @@ +FILE: expressionsInQaSelectorsCornerCases.fir.kt + public final fun R|T|.b(): R|kotlin/Int| { + ^b Int(10) + } + public final fun R|kotlin/Int|.a(it: R|T|): R|kotlin/Int| { + ^a this@R|/a| + } + public final fun main(): R|kotlin/Unit| { + ::#.#(Int(5)).#() + ::#.#(Int(5), Char(=)).#() + lval c: R|@ExtensionFunctionType kotlin/reflect/KFunction1| = Q|kotlin/Int|::R|/b| + R|/c|.R|SubstitutionOverride|(Int(5)).R|kotlin/Int.inv|() + lval f: R|kotlin/Int.() -> kotlin/Int| = Q|kotlin/Int|::R|/b| + R|/f|.R|SubstitutionOverride|(Int(5)).R|kotlin/Int.inv|() + Q|kotlin/Int|::R|/b|.R|SubstitutionOverride|(Int(5)).R|kotlin/Int.inv|() + lval d: R|@ExtensionFunctionType kotlin/reflect/KFunction2| = Q|kotlin/Int|::R|/a#| + R|/d|.R|SubstitutionOverride|(Int(5), Char(=)).R|kotlin/Int.inv|() + lval e: R|kotlin/Int.(kotlin/Char) -> kotlin/Int| = Q|kotlin/Int|::R|/a| + R|/e|.R|SubstitutionOverride|(Int(5), Char(=)).R|kotlin/Int.inv|() + } + public final val R|T|.x: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ Int(10) + } + public final fun rain(): R|kotlin/Unit| { + #.#(Int(5)).#() + ::#.#(Int(5)).#() + Q|kotlin/Int|::R|/x|.R|SubstitutionOverride#|(Int(5)).R|kotlin/Int.inv|() + } diff --git a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.kt b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.kt index a8cbc4e9f52..60ae5ec4a0f 100644 --- a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.kt +++ b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsCornerCases.kt @@ -1,4 +1,5 @@ // ISSUE: KT-64891 +// FIR_DUMP fun T.b(): Int = 10 diff --git a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.fir.kt b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.fir.kt index 4a03b5be38f..aaba4423c11 100644 --- a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.fir.kt +++ b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.fir.kt @@ -1,4 +1,5 @@ // ISSUE: KT-64891 +// FIR_DUMP fun test(f: (Int) -> Int) { 2.(f)() diff --git a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.fir.txt b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.fir.txt new file mode 100644 index 00000000000..5580ff3d626 --- /dev/null +++ b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.fir.txt @@ -0,0 +1,4 @@ +FILE: expressionsInQaSelectorsReceiverConversion.fir.kt + public final fun test(f: R|(kotlin/Int) -> kotlin/Int|): R|kotlin/Unit| { + R|/f|.R|SubstitutionOverride#|(Int(2)) + } diff --git a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.kt b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.kt index 9b88d7adc1b..f9291e4caf7 100644 --- a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.kt +++ b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsReceiverConversion.kt @@ -1,4 +1,5 @@ // ISSUE: KT-64891 +// FIR_DUMP fun test(f: (Int) -> Int) { 2.(f)() diff --git a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsWithElvis.fir.txt b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsWithElvis.fir.txt new file mode 100644 index 00000000000..90b850238d9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsWithElvis.fir.txt @@ -0,0 +1,4 @@ +FILE: expressionsInQaSelectorsWithElvis.kt + public final fun test(a: R|(kotlin/Int.() -> kotlin/Int)?|, b: R|kotlin/Int.() -> kotlin/Int|): R|kotlin/Unit| { + R|/a| ?: R|/b|.R|SubstitutionOverride|(Int(2)) + } diff --git a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsWithElvis.kt b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsWithElvis.kt index d4ccafc3964..7852b2c419f 100644 --- a/compiler/testData/diagnostics/tests/expressionsInQaSelectorsWithElvis.kt +++ b/compiler/testData/diagnostics/tests/expressionsInQaSelectorsWithElvis.kt @@ -1,5 +1,6 @@ // FIR_IDENTICAL // ISSUE: KT-64891 +// FIR_DUMP fun test(a: (Int.() -> Int)?, b: Int.() -> Int) { 2.(a ?: b)() diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.kt index 799c132e137..44854330428 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.kt @@ -1,3 +1,5 @@ +// FIR_DUMP + fun test1(f: String.() -> Unit) { (f)() diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.txt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.txt new file mode 100644 index 00000000000..703aaf367e7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.txt @@ -0,0 +1,9 @@ +FILE: receiverPresenceErrorForInvoke.fir.kt + public final fun test1(f: R|kotlin/String.() -> kotlin/Unit|): R|kotlin/Unit| { + R|/f|.R|SubstitutionOverride#|() + R|/f|.R|SubstitutionOverride#|() + } + public final fun test2(f: R|(kotlin/Int) -> kotlin/Int|): R|kotlin/Unit| { + IntegerLiteral(1).#(Int(2)) + R|/f|.R|SubstitutionOverride#|(Int(2), Int(2)) + } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.kt index 240cd090e88..70411591e04 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.kt @@ -1,3 +1,5 @@ +// FIR_DUMP + fun test1(f: String.() -> Unit) { (f)() diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.kt index 270b89f4d68..bbbe614d894 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.kt @@ -1,3 +1,4 @@ +// FIR_DUMP fun test1() { 1. (fun String.(i: Int) = i )(1) diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.txt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.txt new file mode 100644 index 00000000000..06c8d1ad477 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.txt @@ -0,0 +1,25 @@ +FILE: wrongReceiverForInvokeOnExpression.fir.kt + public final fun test1(): R|kotlin/Unit| { + fun R|kotlin/String|.(i: R|kotlin/Int|): R|kotlin/Int| { + ^ R|/i| + } + .R|SubstitutionOverride#|(Int(1), Int(1)) + label@fun R|kotlin/String|.(i: R|kotlin/Int|): R|kotlin/Int| { + ^@label R|/i| + } + .R|SubstitutionOverride#|(Int(1), Int(1)) + } + public final fun test2(f: R|kotlin/String.(kotlin/Int) -> kotlin/Unit|): R|kotlin/Unit| { + R|/f|.R|SubstitutionOverride#|(Int(11), Int(1)) + R|/f|.R|SubstitutionOverride#|(Int(11)) + } + public final fun test3(): R|kotlin/Unit| { + local final fun foo(): R|kotlin/String.(kotlin/Int) -> kotlin/Unit| { + ^foo fun R|kotlin/String|.(it: R|kotlin/Int|): R|kotlin/Unit| { + ^ Unit + } + + } + + R|/foo|().R|SubstitutionOverride#|(Int(1), Int(1)) + } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.kt index a97e364f474..079486f4918 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.kt @@ -1,3 +1,5 @@ +// FIR_DUMP + fun test1() { 1. (fun String.(i: Int) = i )(1) 1.(label@ fun String.(i: Int) = i )(1)