From 37371edb8c214641bd652d6fcf97fa4b81de2303 Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Fri, 29 Nov 2019 18:40:19 +0700 Subject: [PATCH] Auto-import: add quickfix for overloaded generic function #KT-34667 Fixed --- .../kotlin/idea/quickfix/QuickFixRegistrar.kt | 2 ++ .../extensionWrongTypeParam2.test | 33 +++++++++++++++++++ .../extensionWrongTypeParam3.test | 31 +++++++++++++++++ .../QuickFixMultiFileTestGenerated.java | 10 ++++++ 4 files changed, 76 insertions(+) create mode 100644 idea/testData/quickfix/autoImports/mismatchingArgs/extensionWrongTypeParam2.test create mode 100644 idea/testData/quickfix/autoImports/mismatchingArgs/extensionWrongTypeParam3.test diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index d177470283a..432b15b9c60 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -168,6 +168,8 @@ class QuickFixRegistrar : QuickFixContributor { NAMED_PARAMETER_NOT_FOUND.registerFactory(ImportForMismatchingArgumentsFix) NONE_APPLICABLE.registerFactory(ImportForMismatchingArgumentsFix) WRONG_NUMBER_OF_TYPE_ARGUMENTS.registerFactory(ImportForMismatchingArgumentsFix) + NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER.registerFactory(ImportForMismatchingArgumentsFix) + TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER.registerFactory(ImportForMismatchingArgumentsFix) UNRESOLVED_REFERENCE_WRONG_RECEIVER.registerFactory(ImportFix) diff --git a/idea/testData/quickfix/autoImports/mismatchingArgs/extensionWrongTypeParam2.test b/idea/testData/quickfix/autoImports/mismatchingArgs/extensionWrongTypeParam2.test new file mode 100644 index 00000000000..a88619a3e23 --- /dev/null +++ b/idea/testData/quickfix/autoImports/mismatchingArgs/extensionWrongTypeParam2.test @@ -0,0 +1,33 @@ +// FILE: first.before.kt +// "Import" "true" +// ERROR: Type inference failed: Not enough information to infer parameter T in fun foo(): Unit
Please specify it explicitly.
+// ACTION: Create type parameter in function 'shade' +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference + +package pack_one + +fun foo() {} +fun main() { + foo() +} + +// FILE: second.kt +package pack_one.sub + +fun foo() {} + +// FILE: first.after.kt +// "Import" "true" +// ERROR: Type inference failed: Not enough information to infer parameter T in fun foo(): Unit
Please specify it explicitly.
+// ACTION: Create type parameter in function 'shade' +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference + +package pack_one + +import pack_one.sub.foo + +fun foo() {} +fun main() { + foo() +} + diff --git a/idea/testData/quickfix/autoImports/mismatchingArgs/extensionWrongTypeParam3.test b/idea/testData/quickfix/autoImports/mismatchingArgs/extensionWrongTypeParam3.test new file mode 100644 index 00000000000..d00a9fa4be4 --- /dev/null +++ b/idea/testData/quickfix/autoImports/mismatchingArgs/extensionWrongTypeParam3.test @@ -0,0 +1,31 @@ +// FILE: first.before.kt +// "Import" "true" +// ERROR: Not enough information to infer type variable T +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference + +package pack_one + +fun foo() {} +fun main() { + foo() +} + +// FILE: second.kt +package pack_one.sub + +fun foo() {} + +// FILE: first.after.kt +// "Import" "true" +// ERROR: Not enough information to infer type variable T +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference + +package pack_one + +import pack_one.sub.foo + +fun foo() {} +fun main() { + foo() +} + diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java index 85fb8912a7f..f8da4d4423c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java @@ -1130,6 +1130,16 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes runTest("idea/testData/quickfix/autoImports/mismatchingArgs/extensionWrongTypeParam.test"); } + @TestMetadata("extensionWrongTypeParam2.test") + public void testExtensionWrongTypeParam2() throws Exception { + runTest("idea/testData/quickfix/autoImports/mismatchingArgs/extensionWrongTypeParam2.test"); + } + + @TestMetadata("extensionWrongTypeParam3.test") + public void testExtensionWrongTypeParam3() throws Exception { + runTest("idea/testData/quickfix/autoImports/mismatchingArgs/extensionWrongTypeParam3.test"); + } + @TestMetadata("ignoreErrorsOutsideCall.test") public void testIgnoreErrorsOutsideCall() throws Exception { runTest("idea/testData/quickfix/autoImports/mismatchingArgs/ignoreErrorsOutsideCall.test");