New J2K: add type star projections for converted classes raw references
#KT-31818 fixed
This commit is contained in:
@@ -310,14 +310,14 @@ inline fun <reified T : JKType> T.addTypeParametersToRawProjectionType(typeParam
|
|||||||
) as T
|
) as T
|
||||||
} else this
|
} else this
|
||||||
|
|
||||||
fun JKClassSymbol.expectedTypeParametersCount(): Int {
|
fun JKClassSymbol.expectedTypeParametersCount(): Int =
|
||||||
val resolvedClass = target
|
when (val resolvedClass = target) {
|
||||||
return when (resolvedClass) {
|
|
||||||
is PsiClass -> resolvedClass.typeParameters.size
|
is PsiClass -> resolvedClass.typeParameters.size
|
||||||
is KtClass -> resolvedClass.typeParameters.size
|
is KtClass -> resolvedClass.typeParameters.size
|
||||||
|
is JKClass -> resolvedClass.typeParameterList.typeParameters.size
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val primitiveTypes =
|
val primitiveTypes =
|
||||||
listOf(
|
listOf(
|
||||||
|
|||||||
+2
-2
@@ -22,7 +22,7 @@ class Identifier<T> {
|
|||||||
object User {
|
object User {
|
||||||
fun main() {
|
fun main() {
|
||||||
val i1: Identifier<*> = Identifier<String?>("name", false, true)
|
val i1: Identifier<*> = Identifier<String?>("name", false, true)
|
||||||
val i2 = Identifier("name", false)
|
val i2: Identifier<*> = Identifier<String?>("name", false)
|
||||||
val i3 = Identifier("name")
|
val i3: Identifier<*> = Identifier<String?>("name")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
// ERROR: The integer literal does not conform to the expected type CapturedType(*)
|
// ERROR: The integer literal does not conform to the expected type CapturedType(*)
|
||||||
// ERROR: The integer literal does not conform to the expected type CapturedType(*)
|
// ERROR: The integer literal does not conform to the expected type CapturedType(*)
|
||||||
|
// ERROR: Type argument is not within its bounds: should be subtype of 'String?'
|
||||||
internal class G<T : String?>(t: T?)
|
internal class G<T : String?>(t: T?)
|
||||||
class Java {
|
class Java {
|
||||||
internal fun test() {
|
internal fun test() {
|
||||||
@@ -9,7 +10,7 @@ class Java {
|
|||||||
|
|
||||||
internal fun test2() {
|
internal fun test2() {
|
||||||
val m: HashMap<*, *> = HashMap<Any?, Any?>()
|
val m: HashMap<*, *> = HashMap<Any?, Any?>()
|
||||||
val g = G("")
|
val g: G<*> = G<Any?>("")
|
||||||
val g2 = G("")
|
val g2 = G("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
public class ClassC<T>{}
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ClassC a;
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
class ClassC<T>
|
||||||
|
|
||||||
|
object Test {
|
||||||
|
@JvmStatic
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
var a: ClassC<*>
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -23,7 +23,7 @@ object User {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val i1: Identifier<*> = Identifier<String?>("name", false, true)
|
val i1: Identifier<*> = Identifier<String?>("name", false, true)
|
||||||
val i2 = Identifier("name", false)
|
val i2: Identifier<*> = Identifier<String?>("name", false)
|
||||||
val i3 = Identifier("name")
|
val i3: Identifier<*> = Identifier<String?>("name")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,8 @@ internal class Collection<E>(e: E?) {
|
|||||||
|
|
||||||
internal class Test {
|
internal class Test {
|
||||||
fun main() {
|
fun main() {
|
||||||
val raw1 = Collection(1)
|
val raw1: Collection<*> = Collection<Any?>(1)
|
||||||
val raw2 = Collection(1)
|
val raw2: Collection<*> = Collection<Int?>(1)
|
||||||
val raw3 = Collection("1")
|
val raw3: Collection<*> = Collection<String?>("1")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
@@ -2701,6 +2701,11 @@ public class NewJavaToKotlinConverterSingleFileTestGenerated extends AbstractNew
|
|||||||
runTest("nj2k/testData/newJ2k/issues/kt-19943.java");
|
runTest("nj2k/testData/newJ2k/issues/kt-19943.java");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt-31818.java")
|
||||||
|
public void testKt_31818() throws Exception {
|
||||||
|
runTest("nj2k/testData/newJ2k/issues/kt-31818.java");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt-5294.java")
|
@TestMetadata("kt-5294.java")
|
||||||
public void testKt_5294() throws Exception {
|
public void testKt_5294() throws Exception {
|
||||||
runTest("nj2k/testData/newJ2k/issues/kt-5294.java");
|
runTest("nj2k/testData/newJ2k/issues/kt-5294.java");
|
||||||
|
|||||||
Reference in New Issue
Block a user