From 01ff89641b9f5cfbd8f62e729d56e6aeb7d0e643 Mon Sep 17 00:00:00 2001 From: Roman Efremov Date: Wed, 24 Jul 2024 10:54:00 +0200 Subject: [PATCH] [Kotlin] Add tests for the problematic cases leading to an exception ...about incorrect number of type args. ^KT-65803 Fixed GitOrigin-RevId: 4aa22b56320433a1f331a3a272a17a138e7de933 --- .../tests/K2IntentionTestGenerated.java | 5 +++++ .../intentions/K1IntentionTestGenerated.java | 5 +++++ .../idea/quickfix/K1QuickFixTestGenerated.java | 10 ++++++++++ .../missingTypeArgument.kt | 4 ++++ .../missingTypeArgument.kt.after | 4 ++++ .../missingTypeArgument.kt.after.k2 | 4 ++++ ...ClassWithTypeParameterFromExtensionParent.kt | 11 +++++++++++ ...ithTypeParameterFromExtensionParent.kt.after | 15 +++++++++++++++ ...sInNestedClassWithTypeParameterFromParent.kt | 13 +++++++++++++ ...tedClassWithTypeParameterFromParent.kt.after | 17 +++++++++++++++++ 10 files changed, 88 insertions(+) create mode 100644 plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt create mode 100644 plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt.after create mode 100644 plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt.after.k2 create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInLocalClassWithTypeParameterFromExtensionParent.kt create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInLocalClassWithTypeParameterFromExtensionParent.kt.after create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInNestedClassWithTypeParameterFromParent.kt create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInNestedClassWithTypeParameterFromParent.kt.after diff --git a/plugins/kotlin/code-insight/intentions-k2/tests/test/org/jetbrains/kotlin/idea/k2/intentions/tests/K2IntentionTestGenerated.java b/plugins/kotlin/code-insight/intentions-k2/tests/test/org/jetbrains/kotlin/idea/k2/intentions/tests/K2IntentionTestGenerated.java index 43b2c144c644..39263911206b 100644 --- a/plugins/kotlin/code-insight/intentions-k2/tests/test/org/jetbrains/kotlin/idea/k2/intentions/tests/K2IntentionTestGenerated.java +++ b/plugins/kotlin/code-insight/intentions-k2/tests/test/org/jetbrains/kotlin/idea/k2/intentions/tests/K2IntentionTestGenerated.java @@ -3477,6 +3477,11 @@ public abstract class K2IntentionTestGenerated extends AbstractK2IntentionTest { runTest("../../../idea/tests/testData/intentions/convertReferenceToLambda/member.kt"); } + @TestMetadata("missingTypeArgument.kt") + public void testMissingTypeArgument() throws Exception { + runTest("../../../idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt"); + } + @TestMetadata("multipleLambdaArgumentsAreNotMovedOutsideParentheses.kt") public void testMultipleLambdaArgumentsAreNotMovedOutsideParentheses() throws Exception { runTest("../../../idea/tests/testData/intentions/convertReferenceToLambda/multipleLambdaArgumentsAreNotMovedOutsideParentheses.kt"); diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java index 3447325f45dd..9cb6af44ffae 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java @@ -8318,6 +8318,11 @@ public abstract class K1IntentionTestGenerated extends AbstractK1IntentionTest { runTest("testData/intentions/convertReferenceToLambda/member.kt"); } + @TestMetadata("missingTypeArgument.kt") + public void testMissingTypeArgument() throws Exception { + runTest("testData/intentions/convertReferenceToLambda/missingTypeArgument.kt"); + } + @TestMetadata("multipleLambdaArgumentsAreNotMovedOutsideParentheses.kt") public void testMultipleLambdaArgumentsAreNotMovedOutsideParentheses() throws Exception { runTest("testData/intentions/convertReferenceToLambda/multipleLambdaArgumentsAreNotMovedOutsideParentheses.kt"); diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/K1QuickFixTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/K1QuickFixTestGenerated.java index 503577e69e8d..dcf881e41e8d 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/K1QuickFixTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/K1QuickFixTestGenerated.java @@ -5604,6 +5604,16 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest { runTest("testData/quickfix/createFromUsage/createFunction/call/member/funWithNullableTypeParameter.kt"); } + @TestMetadata("implicitThisInLocalClassWithTypeParameterFromExtensionParent.kt") + public void testImplicitThisInLocalClassWithTypeParameterFromExtensionParent() throws Exception { + runTest("testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInLocalClassWithTypeParameterFromExtensionParent.kt"); + } + + @TestMetadata("implicitThisInNestedClassWithTypeParameterFromParent.kt") + public void testImplicitThisInNestedClassWithTypeParameterFromParent() throws Exception { + runTest("testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInNestedClassWithTypeParameterFromParent.kt"); + } + @TestMetadata("inconsistentTypes.kt") public void testInconsistentTypes() throws Exception { runTest("testData/quickfix/createFromUsage/createFunction/call/member/inconsistentTypes.kt"); diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt b/plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt new file mode 100644 index 000000000000..d50dd919d20a --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt @@ -0,0 +1,4 @@ +// SKIP_ERRORS_BEFORE + +class Test +val x = Test::toString diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt.after b/plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt.after new file mode 100644 index 000000000000..014421f8ba8d --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt.after @@ -0,0 +1,4 @@ +// SKIP_ERRORS_BEFORE + +class Test +val x = { test: Test<*> -> test.toString() } diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt.after.k2 b/plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt.after.k2 new file mode 100644 index 000000000000..a1add4c7480a --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/intentions/convertReferenceToLambda/missingTypeArgument.kt.after.k2 @@ -0,0 +1,4 @@ +// SKIP_ERRORS_BEFORE + +class Test +val x = { test: Test -> test.toString() } diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInLocalClassWithTypeParameterFromExtensionParent.kt b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInLocalClassWithTypeParameterFromExtensionParent.kt new file mode 100644 index 000000000000..95882bdae089 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInLocalClassWithTypeParameterFromExtensionParent.kt @@ -0,0 +1,11 @@ +// "Create function 'foo'" "true" +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.CreateCallableFromUsageFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.quickFixes.createFromUsage.CreateKotlinCallableAction + +fun T.ext() { + class Local { + fun test() { + foo() + } + } +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInLocalClassWithTypeParameterFromExtensionParent.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInLocalClassWithTypeParameterFromExtensionParent.kt.after new file mode 100644 index 000000000000..b949277bde85 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInLocalClassWithTypeParameterFromExtensionParent.kt.after @@ -0,0 +1,15 @@ +// "Create function 'foo'" "true" +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.CreateCallableFromUsageFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.quickFixes.createFromUsage.CreateKotlinCallableAction + +fun T.ext() { + class Local { + fun test() { + foo() + } + + private fun foo() { + TODO("Not yet implemented") + } + } +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInNestedClassWithTypeParameterFromParent.kt b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInNestedClassWithTypeParameterFromParent.kt new file mode 100644 index 000000000000..b8f9c57216b2 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInNestedClassWithTypeParameterFromParent.kt @@ -0,0 +1,13 @@ +// "Create function 'foo'" "true" +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.CreateCallableFromUsageFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.quickFixes.createFromUsage.CreateKotlinCallableAction + +class A { + fun getT(): T = null!! + + inner class B { + fun test() { + foo(getT()) + } + } +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInNestedClassWithTypeParameterFromParent.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInNestedClassWithTypeParameterFromParent.kt.after new file mode 100644 index 000000000000..5cecc560b6e4 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/call/member/implicitThisInNestedClassWithTypeParameterFromParent.kt.after @@ -0,0 +1,17 @@ +// "Create function 'foo'" "true" +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.CreateCallableFromUsageFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.quickFixes.createFromUsage.CreateKotlinCallableAction + +class A { + fun getT(): T = null!! + + inner class B { + fun test() { + foo(getT()) + } + + private fun foo(t: T) { + TODO("Not yet implemented") + } + } +}