KT-22063 Add intrinsics for javaObjectType and javaPrimitiveType
Fix of https://youtrack.jetbrains.com/issue/KT-22063
This commit is contained in:
committed by
Alexander Udalov
parent
d79a4fd9a0
commit
3a50d0d78f
@@ -0,0 +1,96 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class A {
|
||||
}
|
||||
|
||||
fun m() {
|
||||
}
|
||||
|
||||
fun getJavaObjectType1():Class<*> {
|
||||
return Int::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType2():Class<*> {
|
||||
return Integer::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType3():Class<*> {
|
||||
return Void::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType4():Class<*> {
|
||||
return Boolean::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType5():Class<*>? {
|
||||
return A::class.javaObjectType
|
||||
}
|
||||
|
||||
inline fun <reified T : Any> getJavaObjectType6():Class<*> {
|
||||
return T::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType7():Class<*> {
|
||||
return A()::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType8():Class<*> {
|
||||
val i: Int? = 1
|
||||
return i!!::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType9():Class<*> {
|
||||
val i: Int = 1
|
||||
return i::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType10():Class<*> {
|
||||
return m()::class.javaObjectType
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (getJavaObjectType1() !== Int::class.javaObjectType) {
|
||||
return "Failure 1"
|
||||
}
|
||||
if (getJavaObjectType2() !== Int::class.javaObjectType) {
|
||||
return "Failure 2"
|
||||
}
|
||||
if (getJavaObjectType3() !== Void::class.javaObjectType) {
|
||||
return "Failure 3"
|
||||
}
|
||||
if (getJavaObjectType4() !== java.lang.Boolean::class.javaObjectType) {
|
||||
return "Failure 4"
|
||||
}
|
||||
if (getJavaObjectType5() !== A::class.javaObjectType) {
|
||||
return "Failure 5"
|
||||
}
|
||||
if (getJavaObjectType6<A>() !== A::class.javaObjectType) {
|
||||
return "Failure 6 (A)"
|
||||
}
|
||||
if (getJavaObjectType6<Int>() !== Int::class.javaObjectType) {
|
||||
return "Failure 6 (Int)"
|
||||
}
|
||||
if (getJavaObjectType6<Integer>() !== Int::class.javaObjectType) {
|
||||
return "Failure 6 (Integer)"
|
||||
}
|
||||
if (getJavaObjectType7() !== A::class.javaObjectType) {
|
||||
return "Failure 7"
|
||||
}
|
||||
if (getJavaObjectType8() !== Int::class.javaObjectType) {
|
||||
return "Failure 8"
|
||||
}
|
||||
if (getJavaObjectType9() !== Int::class.javaObjectType) {
|
||||
return "Failure 9"
|
||||
}
|
||||
if (getJavaObjectType10() !== Unit::class.javaObjectType) {
|
||||
return "Failure 10"
|
||||
}
|
||||
var x = 42
|
||||
if ({ x *= 2; x }()::class.javaObjectType != Int::class.javaObjectType || x != 84) {
|
||||
return "Failure 11"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
class A {
|
||||
}
|
||||
|
||||
fun m() {
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType1():Class<*>? {
|
||||
return Int::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType2():Class<*>? {
|
||||
return Integer::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType3():Class<*>? {
|
||||
return Void::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType4():Class<*>? {
|
||||
return Boolean::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType5():Class<*>? {
|
||||
return A::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
inline fun <reified T : Any> getJavaPrimitiveType6():Class<*>? {
|
||||
return T::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType7():Class<*>? {
|
||||
return A()::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType8():Class<*>? {
|
||||
val i:Int? = 1
|
||||
return i!!::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType9():Class<*>? {
|
||||
val i:Int = 1
|
||||
return i::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType10():Class<*>? {
|
||||
return m()::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (getJavaPrimitiveType1() !== Int::class.javaPrimitiveType) {
|
||||
return "Failure 1"
|
||||
}
|
||||
if (getJavaPrimitiveType2() !== Int::class.javaPrimitiveType) {
|
||||
return "Failure 2"
|
||||
}
|
||||
if (getJavaPrimitiveType3() !== Void::class.javaPrimitiveType) {
|
||||
return "Failure 3"
|
||||
}
|
||||
if (getJavaPrimitiveType4() !== Boolean::class.javaPrimitiveType) {
|
||||
return "Failure 4"
|
||||
}
|
||||
if (getJavaPrimitiveType5() !== null) {
|
||||
return "Failure 5"
|
||||
}
|
||||
if (getJavaPrimitiveType6<A>() !== null) {
|
||||
return "Failure 6 (A)"
|
||||
}
|
||||
if (getJavaPrimitiveType6<Int>() !== Int::class.javaPrimitiveType) {
|
||||
return "Failure 6 (Int)"
|
||||
}
|
||||
if (getJavaPrimitiveType7() !== null) {
|
||||
return "Failure 7"
|
||||
}
|
||||
if (getJavaPrimitiveType8() !== Int::class.javaPrimitiveType) {
|
||||
return "Failure 8"
|
||||
}
|
||||
if (getJavaPrimitiveType9() !== Int::class.javaPrimitiveType) {
|
||||
return "Failure 9"
|
||||
}
|
||||
if (getJavaPrimitiveType10() !== null) {
|
||||
return "Failure 10"
|
||||
}
|
||||
var x = 42
|
||||
if ({ x *= 2; x }()::class.javaPrimitiveType !== Int::class.javaPrimitiveType || x != 84) {
|
||||
return "Failure 11"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class A {
|
||||
}
|
||||
|
||||
fun m() {
|
||||
}
|
||||
|
||||
fun getJavaObjectType1():Class<*> {
|
||||
// LDC Ljava/lang/Integer;.class
|
||||
return Int::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType2():Class<*> {
|
||||
// LDC Ljava/lang/Integer;.class
|
||||
return Integer::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType3():Class<*> {
|
||||
// LDC Ljava/lang/Void;.class
|
||||
return Void::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType4():Class<*> {
|
||||
// LDC Ljava/lang/Boolean;.class
|
||||
return Boolean::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType5():Class<*>? {
|
||||
// LDC LA;.class
|
||||
return A::class.javaObjectType
|
||||
}
|
||||
|
||||
inline fun <reified T : Any> getJavaObjectType6(): Class<*> {
|
||||
// INVOKESTATIC kotlin/jvm/internal/Intrinsics.reifiedOperationMarker
|
||||
// LDC Ljava/lang/Object;.class
|
||||
return T::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType7():Class<*> {
|
||||
// INVOKEVIRTUAL java/lang/Object.getClass
|
||||
return A()::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType8():Class<*> {
|
||||
val i: Int? = 1
|
||||
// LDC Ljava/lang/Integer;.class
|
||||
return i!!::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType9():Class<*> {
|
||||
val i: Int = 1
|
||||
// LDC Ljava/lang/Integer;.class
|
||||
return i::class.javaObjectType
|
||||
}
|
||||
|
||||
fun getJavaObjectType10():Class<*> {
|
||||
// GETSTATIC kotlin/Unit.INSTANCE
|
||||
// INVOKEVIRTUAL java/lang/Object.getClass
|
||||
return m()::class.javaObjectType
|
||||
}
|
||||
|
||||
// 4 LDC Ljava/lang/Integer;.class
|
||||
// 1 LDC Ljava/lang/Object;.class
|
||||
// 1 LDC Ljava/lang/Void;.class
|
||||
// 1 LDC Ljava/lang/Boolean;.class
|
||||
// 1 INVOKESTATIC kotlin/jvm/internal/Intrinsics.reifiedOperationMarker
|
||||
// 0 INVOKESTATIC kotlin/jvm/internal/Reflection.getOrCreateKotlinClass
|
||||
// 0 INVOKESTATIC kotlin/jvm/JvmClassMappingKt.getJavaObjectType
|
||||
@@ -0,0 +1,77 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class A {
|
||||
}
|
||||
|
||||
fun m() {
|
||||
}
|
||||
|
||||
|
||||
fun getJavaPrimitiveType1():Class<*>? {
|
||||
// GETSTATIC java/lang/Integer.TYPE
|
||||
return Int::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType2():Class<*>? {
|
||||
// GETSTATIC java/lang/Integer.TYPE
|
||||
return Integer::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType3():Class<*>? {
|
||||
// GETSTATIC java/lang/Void.TYPE
|
||||
return Void::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType4():Class<*>? {
|
||||
// GETSTATIC java/lang/Boolean.TYPE
|
||||
return Boolean::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType5():Class<*>? {
|
||||
// ACONST_NULL
|
||||
return A::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
inline fun <reified T : Any> getJavaPrimitiveType6():Class<*>? {
|
||||
// INVOKESTATIC kotlin/jvm/internal/Intrinsics.reifiedOperationMarker
|
||||
// LDC Ljava/lang/Object;.class
|
||||
// INVOKESTATIC kotlin/jvm/internal/Reflection.getOrCreateKotlinClass
|
||||
// INVOKESTATIC kotlin/jvm/JvmClassMappingKt.getJavaPrimitiveType
|
||||
return T::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType7():Class<*>? {
|
||||
// INVOKEVIRTUAL java/lang/Object.getClass
|
||||
// INVOKESTATIC kotlin/jvm/internal/Reflection.getOrCreateKotlinClass
|
||||
// INVOKESTATIC kotlin/jvm/JvmClassMappingKt.getJavaPrimitiveType
|
||||
return A()::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType8():Class<*>? {
|
||||
val i:Int? = 1
|
||||
// GETSTATIC java/lang/Integer.TYPE
|
||||
return i!!::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType9():Class<*>? {
|
||||
val i:Int = 1
|
||||
// GETSTATIC java/lang/Integer.TYPE
|
||||
return i::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
fun getJavaPrimitiveType10():Class<*>? {
|
||||
// INVOKEVIRTUAL java/lang/Object.getClass
|
||||
// INVOKESTATIC kotlin/jvm/internal/Reflection.getOrCreateKotlinClass
|
||||
// INVOKESTATIC kotlin/jvm/JvmClassMappingKt.getJavaPrimitiveType
|
||||
return m()::class.javaPrimitiveType
|
||||
}
|
||||
|
||||
// 1 ACONST_NULL
|
||||
// 4 GETSTATIC java/lang/Integer.TYPE
|
||||
// 1 GETSTATIC java/lang/Void.TYPE
|
||||
// 1 GETSTATIC java/lang/Boolean.TYPE
|
||||
// 1 LDC Ljava/lang/Object;.class
|
||||
// 1 INVOKESTATIC kotlin/jvm/internal/Intrinsics.reifiedOperationMarker
|
||||
// 2 INVOKEVIRTUAL java/lang/Object.getClass
|
||||
// 3 INVOKESTATIC kotlin/jvm/internal/Reflection.getOrCreateKotlinClass
|
||||
// 3 INVOKESTATIC kotlin/jvm/JvmClassMappingKt.getJavaPrimitiveType
|
||||
Reference in New Issue
Block a user