Make Class<*>.kotlinPackage nullable
This commit is contained in:
@@ -6,7 +6,7 @@ import kotlin.test.*
|
|||||||
fun box(): String {
|
fun box(): String {
|
||||||
val facadeJClass = Class.forName("test.TestPackage") as Class<Any>
|
val facadeJClass = Class.forName("test.TestPackage") as Class<Any>
|
||||||
|
|
||||||
assertEquals(facadeJClass, facadeJClass.kotlinPackage.javaFacade)
|
assertEquals(facadeJClass, facadeJClass.kotlinPackage!!.javaFacade)
|
||||||
assertEquals(facadeJClass, facadeJClass.kotlin.java)
|
assertEquals(facadeJClass, facadeJClass.kotlin.java)
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|||||||
Vendored
-8
@@ -1,8 +0,0 @@
|
|||||||
import kotlin.test.*
|
|
||||||
import kotlin.reflect.jvm.kotlinPackage
|
|
||||||
|
|
||||||
fun box(): String {
|
|
||||||
val p = javaClass<String>().kotlinPackage
|
|
||||||
if ("$p" != "package java.lang.String") return "Fail: $p"
|
|
||||||
return "OK"
|
|
||||||
}
|
|
||||||
-6
@@ -3177,12 +3177,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
|||||||
doTestWithStdlib(fileName);
|
doTestWithStdlib(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("packageForJavaStaticToString.kt")
|
|
||||||
public void testPackageForJavaStaticToString() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/packageForJavaStaticToString.kt");
|
|
||||||
doTestWithStdlib(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("packageToString.kt")
|
@TestMetadata("packageToString.kt")
|
||||||
public void testPackageToString() throws Exception {
|
public void testPackageToString() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/packageToString.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/packageToString.kt");
|
||||||
|
|||||||
@@ -18,10 +18,14 @@ package kotlin.reflect.jvm
|
|||||||
|
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
import java.lang.reflect.Modifier
|
import kotlin.reflect.KClass
|
||||||
import kotlin.jvm.internal.Reflection
|
import kotlin.reflect.KMutableProperty
|
||||||
import kotlin.reflect.*
|
import kotlin.reflect.KPackage
|
||||||
import kotlin.reflect.jvm.internal.*
|
import kotlin.reflect.KProperty
|
||||||
|
import kotlin.reflect.jvm.internal.KClassImpl
|
||||||
|
import kotlin.reflect.jvm.internal.KMutablePropertyImpl
|
||||||
|
import kotlin.reflect.jvm.internal.KPackageImpl
|
||||||
|
import kotlin.reflect.jvm.internal.KPropertyImpl
|
||||||
|
|
||||||
// Kotlin reflection -> Java reflection
|
// Kotlin reflection -> Java reflection
|
||||||
|
|
||||||
@@ -74,16 +78,14 @@ public val KMutableProperty<*>.javaSetter: Method?
|
|||||||
public val <T> Class<T>.kotlin: KClass<T>
|
public val <T> Class<T>.kotlin: KClass<T>
|
||||||
get() = KClassImpl(this)
|
get() = KClassImpl(this)
|
||||||
|
|
||||||
// TODO: getstatic $kotlinPackage
|
|
||||||
// TODO: make nullable or throw exception
|
|
||||||
/**
|
/**
|
||||||
* Returns a [KPackage] instance corresponding to the Java [Class] instance.
|
* Returns a [KPackage] instance corresponding to the Java [Class] instance.
|
||||||
* The given class is generated from top level functions and properties in the Kotlin package.
|
* The given class is generated from top level functions and properties in the Kotlin package.
|
||||||
* See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/java-interop.html#package-level-functions)
|
* See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/java-interop.html#package-level-functions)
|
||||||
* for more information.
|
* for more information.
|
||||||
*/
|
*/
|
||||||
public val Class<*>.kotlinPackage: KPackage
|
public val Class<*>.kotlinPackage: KPackage?
|
||||||
get() = KPackageImpl(this)
|
get() = if (getAnnotation(javaClass<kotlin.jvm.internal.KotlinPackage>()) != null) KPackageImpl(this) else null
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user