Mpp: KT-23457, fix importing common classes into common modules
Add test for KT-23457 NOTE: fixes 'importClassInCommon' test Other test cases added to increase coverage #KT-23457 Fixed
This commit is contained in:
@@ -625,13 +625,12 @@ internal object ImportForMissingOperatorFactory : ImportFixBase.Factory() {
|
||||
|
||||
|
||||
private fun KotlinIndicesHelper.getClassesByName(expressionForPlatform: KtExpression, name: String) =
|
||||
when (TargetPlatformDetector.getPlatform(expressionForPlatform.containingKtFile)) {
|
||||
JsPlatform -> getKotlinClasses({ it == name },
|
||||
// Enum entries should be contributes with members import fix
|
||||
psiFilter = { ktDeclaration -> ktDeclaration !is KtEnumEntry },
|
||||
kindFilter = { kind -> kind != ClassKind.ENUM_ENTRY })
|
||||
JvmPlatform -> getJvmClassesByName(name)
|
||||
else -> emptyList()
|
||||
}
|
||||
when (TargetPlatformDetector.getPlatform(expressionForPlatform.containingKtFile)) {
|
||||
JvmPlatform -> getJvmClassesByName(name)
|
||||
else -> getKotlinClasses({ it == name },
|
||||
// Enum entries should be contributes with members import fix
|
||||
psiFilter = { ktDeclaration -> ktDeclaration !is KtEnumEntry },
|
||||
kindFilter = { kind -> kind != ClassKind.ENUM_ENTRY })
|
||||
}
|
||||
|
||||
private fun CallTypeAndReceiver<*, *>.toFilter() = { descriptor: DeclarationDescriptor -> this.callType.descriptorKindFilter.accepts(descriptor) }
|
||||
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
class Foo
|
||||
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
class Foo
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
fun use(f: <caret>Foo) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
import foo.Foo
|
||||
|
||||
fun use(f: Foo) {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
class Foo
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
class Foo
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
fun use(f: <caret>Foo) {
|
||||
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
import foo.Foo
|
||||
|
||||
fun use(f: Foo) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
class Foo
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
fun use(f: <caret>Foo) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
import foo.Foo
|
||||
|
||||
fun use(f: Foo) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
class Foo
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
fun use(f: <caret>Foo) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
import foo.Foo
|
||||
|
||||
fun use(f: Foo) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
package foo
|
||||
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: foo
|
||||
package bar
|
||||
|
||||
fun use() {
|
||||
<caret>foo()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: foo
|
||||
package bar
|
||||
|
||||
import foo.foo
|
||||
|
||||
fun use() {
|
||||
foo()
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
expect class Foo
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
actual class Foo
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
fun use(f: <caret>Foo) {
|
||||
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
import foo.Foo
|
||||
|
||||
fun use(f: Foo) {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
expect class Foo
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Import" "false"
|
||||
// ACTION: Create annotation 'Foo'
|
||||
// ACTION: Create class 'Foo'
|
||||
// ACTION: Create enum 'Foo'
|
||||
// ACTION: Create interface 'Foo'
|
||||
// ACTION: Create type alias 'Foo'
|
||||
// ACTION: Create type parameter 'Foo' in function 'use'
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
fun use(f: <caret>Foo) {
|
||||
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Import" "false"
|
||||
// ACTION: Create annotation 'Foo'
|
||||
// ACTION: Create class 'Foo'
|
||||
// ACTION: Create enum 'Foo'
|
||||
// ACTION: Create interface 'Foo'
|
||||
// ACTION: Create type alias 'Foo'
|
||||
// ACTION: Create type parameter 'Foo' in function 'use'
|
||||
// ERROR: Unresolved reference: Foo
|
||||
package bar
|
||||
|
||||
fun use(f: Foo) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
package foo
|
||||
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: foo
|
||||
package bar
|
||||
|
||||
fun use() {
|
||||
<caret>foo()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: foo
|
||||
package bar
|
||||
|
||||
import foo.foo
|
||||
|
||||
fun use() {
|
||||
foo()
|
||||
}
|
||||
+40
@@ -184,6 +184,46 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
|
||||
runTest("idea/testData/multiModuleQuickFix/implementMembersInImplClassNonImplInheritor/");
|
||||
}
|
||||
|
||||
@TestMetadata("importClassInCommon")
|
||||
public void testImportClassInCommon() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/importClassInCommon/");
|
||||
}
|
||||
|
||||
@TestMetadata("importClassInFromProductionInCommonTests")
|
||||
public void testImportClassInFromProductionInCommonTests() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/importClassInFromProductionInCommonTests/");
|
||||
}
|
||||
|
||||
@TestMetadata("importCommonClassInJs")
|
||||
public void testImportCommonClassInJs() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/importCommonClassInJs/");
|
||||
}
|
||||
|
||||
@TestMetadata("importCommonClassInJvm")
|
||||
public void testImportCommonClassInJvm() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/importCommonClassInJvm/");
|
||||
}
|
||||
|
||||
@TestMetadata("importCommonFunInJvm")
|
||||
public void testImportCommonFunInJvm() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/importCommonFunInJvm/");
|
||||
}
|
||||
|
||||
@TestMetadata("importExpectClassWithActualInJvm")
|
||||
public void testImportExpectClassWithActualInJvm() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/importExpectClassWithActualInJvm/");
|
||||
}
|
||||
|
||||
@TestMetadata("importExpectClassWithoutActualInJvm")
|
||||
public void testImportExpectClassWithoutActualInJvm() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/importExpectClassWithoutActualInJvm/");
|
||||
}
|
||||
|
||||
@TestMetadata("importFunInCommon")
|
||||
public void testImportFunInCommon() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/importFunInCommon/");
|
||||
}
|
||||
|
||||
@TestMetadata("interface")
|
||||
public void testInterface() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/interface/");
|
||||
|
||||
Reference in New Issue
Block a user