KT-64832 [FIR] Add more testData for invoke on local variables

Covers:
- suspend functional local variables
- overloads
- custom types with invoke operator
This commit is contained in:
Roman Golyshev
2024-01-09 13:17:21 +01:00
committed by Space Team
parent 2c90f1327d
commit 0cad4c9632
16 changed files with 259 additions and 0 deletions
@@ -3152,6 +3152,18 @@ public class DiagnosticCompilerTestFirTestdataTestGenerated extends AbstractDiag
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invoke.kt");
}
@Test
@TestMetadata("invokeCustomTypeExt.kt")
public void testInvokeCustomTypeExt() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeCustomTypeExt.kt");
}
@Test
@TestMetadata("invokeCustomTypeMember.kt")
public void testInvokeCustomTypeMember() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeCustomTypeMember.kt");
}
@Test
@TestMetadata("invokeKFunction.kt")
public void testInvokeKFunction() throws Exception {
@@ -3170,6 +3182,30 @@ public class DiagnosticCompilerTestFirTestdataTestGenerated extends AbstractDiag
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeKSuspendFunction.kt");
}
@Test
@TestMetadata("invokeOverload1.kt")
public void testInvokeOverload1() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeOverload1.kt");
}
@Test
@TestMetadata("invokeOverload2.kt")
public void testInvokeOverload2() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeOverload2.kt");
}
@Test
@TestMetadata("invokeSuspend.kt")
public void testInvokeSuspend() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeSuspend.kt");
}
@Test
@TestMetadata("invokeWithExtensionReceiver.kt")
public void testInvokeWithExtensionReceiver() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeWithExtensionReceiver.kt");
}
@Test
@TestMetadata("lambda.kt")
public void testLambda() throws Exception {
@@ -3152,6 +3152,18 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invoke.kt");
}
@Test
@TestMetadata("invokeCustomTypeExt.kt")
public void testInvokeCustomTypeExt() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeCustomTypeExt.kt");
}
@Test
@TestMetadata("invokeCustomTypeMember.kt")
public void testInvokeCustomTypeMember() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeCustomTypeMember.kt");
}
@Test
@TestMetadata("invokeKFunction.kt")
public void testInvokeKFunction() throws Exception {
@@ -3170,6 +3182,30 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeKSuspendFunction.kt");
}
@Test
@TestMetadata("invokeOverload1.kt")
public void testInvokeOverload1() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeOverload1.kt");
}
@Test
@TestMetadata("invokeOverload2.kt")
public void testInvokeOverload2() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeOverload2.kt");
}
@Test
@TestMetadata("invokeSuspend.kt")
public void testInvokeSuspend() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeSuspend.kt");
}
@Test
@TestMetadata("invokeWithExtensionReceiver.kt")
public void testInvokeWithExtensionReceiver() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeWithExtensionReceiver.kt");
}
@Test
@TestMetadata("lambda.kt")
public void testLambda() throws Exception {
@@ -0,0 +1,13 @@
FILE: invokeCustomTypeExt.kt
public final class Foo : R|kotlin/Any| {
public constructor(): R|Foo| {
super<R|kotlin/Any|>()
}
}
public final operator fun R|Foo|.invoke(): R|kotlin/Unit| {
}
public final fun foo(): R|kotlin/Unit| {
lval x: R|Foo| = R|/Foo.Foo|()
R|<local>/x|.R|/invoke|()
}
@@ -0,0 +1,9 @@
class Foo
operator fun Foo.invoke() {}
fun foo() {
val <!UNUSED_VARIABLE!>x<!> = Foo()
x()
}
@@ -0,0 +1,14 @@
FILE: invokeCustomTypeMember.kt
public final class Foo : R|kotlin/Any| {
public constructor(): R|Foo| {
super<R|kotlin/Any|>()
}
public final operator fun invoke(): R|kotlin/Unit| {
}
}
public final fun foo(): R|kotlin/Unit| {
lval x: R|Foo| = R|/Foo.Foo|()
R|<local>/x|.R|/Foo.invoke|()
}
@@ -0,0 +1,9 @@
class Foo {
operator fun invoke() {}
}
fun foo() {
val <!UNUSED_VARIABLE!>x<!> = Foo()
x()
}
@@ -0,0 +1,13 @@
FILE: invokeOverload1.kt
public final fun foo(): R|kotlin/Unit| {
lval x: R|(kotlin/String) -> kotlin/Unit| = fun <anonymous>(s: R|kotlin/String|): R|kotlin/Unit| <inline=Unknown> {
}
local final fun nested(): R|kotlin/Unit| {
lval x: R|(kotlin/Int) -> kotlin/Unit| = fun <anonymous>(i: R|kotlin/Int|): R|kotlin/Unit| <inline=Unknown> {
}
R|<local>/x|.R|SubstitutionOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(String(hello))
}
}
@@ -0,0 +1,9 @@
fun foo() {
val x = fun(s: String) {}
fun nested() {
val <!UNUSED_VARIABLE!>x<!> = fun(i: Int) {}
x("hello")
}
}
@@ -0,0 +1,13 @@
FILE: invokeOverload2.kt
public final fun foo(): R|kotlin/Unit| {
lval x: R|(kotlin/String) -> kotlin/Unit| = fun <anonymous>(s: R|kotlin/String|): R|kotlin/Unit| <inline=Unknown> {
}
local final fun nested(): R|kotlin/Unit| {
lval x: R|(kotlin/Int) -> kotlin/Unit| = fun <anonymous>(i: R|kotlin/Int|): R|kotlin/Unit| <inline=Unknown> {
}
R|<local>/x|.R|SubstitutionOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(Int(10))
}
}
@@ -0,0 +1,9 @@
fun foo() {
val x = fun(s: String) {}
fun nested() {
val <!UNUSED_VARIABLE!>x<!> = fun(i: Int) {}
x(10)
}
}
@@ -0,0 +1,5 @@
FILE: invokeSuspend.kt
public final suspend fun foo(action: R|suspend () -> kotlin/Unit|): R|kotlin/Unit| {
lval x: R|suspend () -> kotlin/Unit| = R|<local>/action|
R|<local>/x|.R|SubstitutionOverride<kotlin/coroutines/SuspendFunction0.invoke: R|kotlin/Unit|>|()
}
@@ -0,0 +1,5 @@
suspend fun foo(action: suspend () -> Unit) {
val <!UNUSED_VARIABLE!>x<!> = action
x()
}
@@ -0,0 +1,7 @@
FILE: invokeWithExtensionReceiver.kt
public final fun foo(): R|kotlin/Unit| {
lval ext: R|kotlin/String.(kotlin/Int) -> kotlin/Unit|
lval usedReceiver: R|kotlin/String| = String(foo)
lval unusedReceiver: R|kotlin/String| = String(bar)
R|<local>/ext|.R|SubstitutionOverride<kotlin/Function2.invoke: R|kotlin/Unit|>|(R|<local>/usedReceiver|, Int(10))
}
@@ -0,0 +1,9 @@
fun foo() {
val ext: String.(Int) -> Unit
val usedReceiver = "foo"
val <!UNUSED_VARIABLE!>unusedReceiver<!> = "bar"
usedReceiver.ext(10)
}
@@ -3152,6 +3152,18 @@ public class FirLightTreeDiagnosticsTestGenerated extends AbstractFirLightTreeDi
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invoke.kt");
}
@Test
@TestMetadata("invokeCustomTypeExt.kt")
public void testInvokeCustomTypeExt() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeCustomTypeExt.kt");
}
@Test
@TestMetadata("invokeCustomTypeMember.kt")
public void testInvokeCustomTypeMember() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeCustomTypeMember.kt");
}
@Test
@TestMetadata("invokeKFunction.kt")
public void testInvokeKFunction() throws Exception {
@@ -3170,6 +3182,30 @@ public class FirLightTreeDiagnosticsTestGenerated extends AbstractFirLightTreeDi
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeKSuspendFunction.kt");
}
@Test
@TestMetadata("invokeOverload1.kt")
public void testInvokeOverload1() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeOverload1.kt");
}
@Test
@TestMetadata("invokeOverload2.kt")
public void testInvokeOverload2() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeOverload2.kt");
}
@Test
@TestMetadata("invokeSuspend.kt")
public void testInvokeSuspend() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeSuspend.kt");
}
@Test
@TestMetadata("invokeWithExtensionReceiver.kt")
public void testInvokeWithExtensionReceiver() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeWithExtensionReceiver.kt");
}
@Test
@TestMetadata("lambda.kt")
public void testLambda() throws Exception {
@@ -3152,6 +3152,18 @@ public class FirPsiDiagnosticTestGenerated extends AbstractFirPsiDiagnosticTest
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invoke.kt");
}
@Test
@TestMetadata("invokeCustomTypeExt.kt")
public void testInvokeCustomTypeExt() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeCustomTypeExt.kt");
}
@Test
@TestMetadata("invokeCustomTypeMember.kt")
public void testInvokeCustomTypeMember() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeCustomTypeMember.kt");
}
@Test
@TestMetadata("invokeKFunction.kt")
public void testInvokeKFunction() throws Exception {
@@ -3170,6 +3182,30 @@ public class FirPsiDiagnosticTestGenerated extends AbstractFirPsiDiagnosticTest
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeKSuspendFunction.kt");
}
@Test
@TestMetadata("invokeOverload1.kt")
public void testInvokeOverload1() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeOverload1.kt");
}
@Test
@TestMetadata("invokeOverload2.kt")
public void testInvokeOverload2() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeOverload2.kt");
}
@Test
@TestMetadata("invokeSuspend.kt")
public void testInvokeSuspend() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeSuspend.kt");
}
@Test
@TestMetadata("invokeWithExtensionReceiver.kt")
public void testInvokeWithExtensionReceiver() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/invokeWithExtensionReceiver.kt");
}
@Test
@TestMetadata("lambda.kt")
public void testLambda() throws Exception {