Make property java available on KClass<T> where T is type parameter without upper bounds.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: A.java
|
||||
import kotlin.reflect.KClass;
|
||||
|
||||
public class A {
|
||||
public static A getA() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static KClass<A> getKClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// types checked by txt file
|
||||
|
||||
// FILE: 1.kt
|
||||
inline fun <reified X> test1() = X::class.java
|
||||
inline fun <reified X : Any> test2() = X::class.java
|
||||
inline fun <reified X : Any?> test3() = X::class.java
|
||||
inline fun <reified X : Number> test4() = X::class.java
|
||||
inline fun <reified X : Number?> test5() = X::class.java
|
||||
|
||||
fun test6() = A.getA()::class.java
|
||||
fun test7() = A.getKClass().java
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public inline fun </*0*/ reified X> test1(): java.lang.Class<X>
|
||||
public inline fun </*0*/ reified X : kotlin.Any> test2(): java.lang.Class<X>
|
||||
public inline fun </*0*/ reified X> test3(): java.lang.Class<X>
|
||||
public inline fun </*0*/ reified X : kotlin.Number> test4(): java.lang.Class<X>
|
||||
public inline fun </*0*/ reified X : kotlin.Number?> test5(): java.lang.Class<X>
|
||||
public fun test6(): java.lang.Class<out A!>
|
||||
public fun test7(): java.lang.Class<A!>
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public open fun getA(): A!
|
||||
public open fun getKClass(): kotlin.reflect.KClass<A!>!
|
||||
}
|
||||
@@ -108,6 +108,12 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("javaForKClass.kt")
|
||||
public void testJavaForKClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/javaForKClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt9078.kt")
|
||||
public void testKt9078() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/kt9078.kt");
|
||||
|
||||
@@ -33,7 +33,8 @@ import java.lang.Short as JavaLangShort
|
||||
/**
|
||||
* Returns a Java [Class] instance corresponding to the given [KClass] instance.
|
||||
*/
|
||||
public val <T : Any> KClass<T>.java: Class<T>
|
||||
@Suppress("UPPER_BOUND_VIOLATED")
|
||||
public val <T> KClass<T>.java: Class<T>
|
||||
@JvmName("getJavaClass")
|
||||
get() = (this as ClassBasedDeclarationContainer).jClass as Class<T>
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// "Add 'kotlin.Any' as upper bound for E" "true"
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
inline fun <reified /* abc */ E> bar() = E::class.java<caret>
|
||||
|
||||
inline fun <reified /* abc */ E> bar() = E::class.oldJava<caret>
|
||||
|
||||
val <T: Any> KClass<T>.oldJava get() = java
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// "Add 'kotlin.Any' as upper bound for E" "true"
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
inline fun <reified /* abc */ E : Any> bar() = E::class.java
|
||||
|
||||
inline fun <reified /* abc */ E : Any> bar() = E::class.oldJava
|
||||
|
||||
val <T: Any> KClass<T>.oldJava get() = java
|
||||
|
||||
Reference in New Issue
Block a user