KT-12054 J2K generates obj is Type<Any> instead of obj is Type<*>
#KT-12054 Fixed
This commit is contained in:
@@ -2,4 +2,4 @@ package to
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
internal annotation class Ann(val value: KClass<Any>)
|
||||
internal annotation class Ann(val value: KClass<*>)
|
||||
@@ -1 +1 @@
|
||||
class B : X<Any>
|
||||
class B : X<*>
|
||||
@@ -105,10 +105,7 @@ class TypeVisitor(
|
||||
if (classType is PsiClassReferenceType) {
|
||||
val targetClass = classType.reference.resolve() as? PsiClass
|
||||
if (targetClass != null) {
|
||||
return targetClass.typeParameters.map {
|
||||
val superType = it.superTypes.first() // there must be at least one super type always
|
||||
typeConverter.convertType(superType, Nullability.Default, mutability, inAnnotationType).assignNoPrototype()
|
||||
}
|
||||
return targetClass.typeParameters.map { StarProjectionType().assignNoPrototype() }
|
||||
}
|
||||
}
|
||||
return listOf()
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import java.util.HashSet
|
||||
|
||||
internal class Foo {
|
||||
fun foo(o: HashSet<Any?>?) {
|
||||
val o2: HashSet<Any?>? = o
|
||||
fun foo(o: HashSet<*>?) {
|
||||
val o2: HashSet<*>? = o
|
||||
var foo: Int = 0
|
||||
foo = o2!!.size
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import java.util.HashSet
|
||||
|
||||
internal class Foo {
|
||||
fun foo(o: HashSet<Any>) {
|
||||
fun foo(o: HashSet<*>) {
|
||||
val o2 = o
|
||||
var foo = 0
|
||||
foo = o2.size
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
class C {
|
||||
boolean bar(Object o, Collection<String> collection) {
|
||||
return o instanceof Collection && collection instanceof List;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
internal class C {
|
||||
fun bar(o: Any, collection: Collection<String>): Boolean {
|
||||
return o is Collection<*> && collection is List<*>
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//TODO: uncomment this test when KT-12133 fixed
|
||||
class JavaClass1<T extends JavaClass2> {
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// ERROR: Type inference failed. Expected type mismatch: inferred type is HashMap<Any!, Any!> but Map<String, String> was expected
|
||||
// ERROR: Type inference failed. Expected type mismatch: inferred type is HashMap<Any?, Any?> but Map<String, String> was expected
|
||||
import java.util.*
|
||||
|
||||
internal object A {
|
||||
fun foo(): Map<String, String> {
|
||||
val props = Properties()
|
||||
return HashMap(props as Map<Any, Any>)
|
||||
return HashMap(props as Map<*, *>)
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -2698,6 +2698,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("rawType.java")
|
||||
public void testRawType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/isOperator/rawType.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleReference.java")
|
||||
public void testSimpleReference() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/isOperator/simpleReference.java");
|
||||
@@ -4078,12 +4084,6 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("j2k/testData/fileOrElement/rawGenerics"), Pattern.compile("^(.+)\\.java$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("cycle.java")
|
||||
public void testCycle() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/rawGenerics/cycle.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt-540.java")
|
||||
public void testKt_540() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/rawGenerics/kt-540.java");
|
||||
|
||||
+6
-6
@@ -2698,6 +2698,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("rawType.java")
|
||||
public void testRawType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/isOperator/rawType.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleReference.java")
|
||||
public void testSimpleReference() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/isOperator/simpleReference.java");
|
||||
@@ -4078,12 +4084,6 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("j2k/testData/fileOrElement/rawGenerics"), Pattern.compile("^(.+)\\.java$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("cycle.java")
|
||||
public void testCycle() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/rawGenerics/cycle.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt-540.java")
|
||||
public void testKt_540() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/rawGenerics/kt-540.java");
|
||||
|
||||
Reference in New Issue
Block a user