Move .java and .kotlin extension properties to kotlin.jvm
Delete the old ones in package kotlin.reflect.jvm because otherwise the code using those functions will become red in a lot less meaningful way (overload resolution ambiguity) than if they're deleted (unresolved import) Based on the work originally done by @dnpetrov #KT-8380 Fixed
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin.jvm
|
||||
|
||||
import kotlin.jvm.internal.ClassBasedDeclarationContainer
|
||||
import kotlin.jvm.internal.Intrinsic
|
||||
import kotlin.jvm.internal.Reflection
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* Returns a Java [Class] instance corresponding to the given [KClass] instance.
|
||||
*/
|
||||
@Intrinsic("kotlin.KClass.java.property")
|
||||
public val <T> KClass<T>.java: Class<T>
|
||||
get() = (this as ClassBasedDeclarationContainer).jClass as Class<T>
|
||||
|
||||
/**
|
||||
* Returns a [KClass] instance corresponding to the given Java [Class] instance.
|
||||
*/
|
||||
public val <T> Class<T>.kotlin: KClass<T>
|
||||
get() = Reflection.createKotlinClass(this) as KClass<T>
|
||||
@@ -27,13 +27,16 @@ public annotation(retention = AnnotationRetention.SOURCE) class throws(public va
|
||||
/**
|
||||
* Returns the runtime Java class of this object.
|
||||
*/
|
||||
@Intrinsic("kotlin.javaClass.property") public val <T: Any> T.javaClass : Class<T>
|
||||
@Intrinsic("kotlin.javaClass.property")
|
||||
public val <T: Any> T.javaClass : Class<T>
|
||||
get() = (this as java.lang.Object).getClass() as Class<T>
|
||||
|
||||
/**
|
||||
* Returns the Java class for the specified type.
|
||||
*/
|
||||
@Intrinsic("kotlin.javaClass.function") public fun <reified T: Any> javaClass(): Class<T> = null as Class<T>
|
||||
@Intrinsic("kotlin.javaClass.function")
|
||||
@deprecated("Use the class reference and .java extension property instead: MyClass::class.java", ReplaceWith("T::class.java"))
|
||||
public fun <reified T: Any> javaClass(): Class<T> = T::class.java
|
||||
|
||||
/**
|
||||
* Executes the given function [block] while holding the monitor of the given object [lock].
|
||||
|
||||
Reference in New Issue
Block a user