Fix for KT-6790 J2K: Static import of Map.Entry is lost during conversion
#KT-6790 fixed
This commit is contained in:
committed by
Simon Ogorodnik
parent
73ea0e8460
commit
41aaaa6a0d
@@ -58,8 +58,13 @@ private fun Converter.convertImport(fqName: FqName, ref: PsiJavaCodeReferenceEle
|
|||||||
if (!isOnDemand) {
|
if (!isOnDemand) {
|
||||||
if (annotationConverter.isImportNotRequired(fqName)) return emptyList()
|
if (annotationConverter.isImportNotRequired(fqName)) return emptyList()
|
||||||
|
|
||||||
// If imported class has a kotlin analog, drop the import
|
|
||||||
if (JavaToKotlinClassMap.INSTANCE.isJavaPlatformClass(fqName)) return emptyList()
|
val mapped = JavaToKotlinClassMap.INSTANCE.mapJavaToKotlin(fqName)
|
||||||
|
mapped?.let {
|
||||||
|
// If imported class has a kotlin analog, drop the import if it is not nested
|
||||||
|
if (!it.isNestedClass) return emptyList()
|
||||||
|
return convertNonStaticImport(it.asSingleFqName(), false, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: how to detect compiled Kotlin here?
|
//TODO: how to detect compiled Kotlin here?
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
public class A {
|
||||||
|
void foo(Entry<Object, Object> o) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import kotlin.collections.Map.Entry
|
||||||
|
|
||||||
|
class A {
|
||||||
|
internal fun foo(o: Entry<Any, Any>) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2927,6 +2927,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt-6790.java")
|
||||||
|
public void testKt_6790() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/issues/kt-6790.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt-696.java")
|
@TestMetadata("kt-696.java")
|
||||||
public void testKt_696() throws Exception {
|
public void testKt_696() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/issues/kt-696.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/issues/kt-696.java");
|
||||||
|
|||||||
@@ -2927,6 +2927,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt-6790.java")
|
||||||
|
public void testKt_6790() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/issues/kt-6790.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt-696.java")
|
@TestMetadata("kt-696.java")
|
||||||
public void testKt_696() throws Exception {
|
public void testKt_696() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/issues/kt-696.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/issues/kt-696.java");
|
||||||
|
|||||||
Reference in New Issue
Block a user