Fix KFunction.javaMethod for property accessors
This commit is contained in:
@@ -57,6 +57,8 @@ interface KMutablePropertyImpl<R> : KMutableProperty<R>, KPropertyImpl<R> {
|
||||
override val setter: Setter<R>
|
||||
|
||||
abstract class Setter<R> : KMutableProperty.Setter<R>, KPropertyImpl.Accessor<R>, KCallableImpl<Unit> {
|
||||
abstract override val property: KMutablePropertyImpl<R>
|
||||
|
||||
override val name: String get() = "<set-${property.name}>"
|
||||
|
||||
override val descriptor: PropertySetterDescriptor by ReflectProperties.lazySoft {
|
||||
|
||||
@@ -68,7 +68,12 @@ public val KMutableProperty<*>.javaSetter: Method?
|
||||
* or `null` if this function is a constructor or cannot be represented by a Java [Method].
|
||||
*/
|
||||
public val KFunction<*>.javaMethod: Method?
|
||||
get() = ((this as? KFunctionImpl)?.caller as? FunctionCaller.Method)?.method
|
||||
get() = when (this) {
|
||||
is KFunctionImpl -> (caller as? FunctionCaller.Method)?.method
|
||||
is KPropertyImpl.Getter<*> -> property.javaGetter
|
||||
is KMutablePropertyImpl.Setter<*> -> property.javaSetter
|
||||
else -> null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Java [Constructor] instance corresponding to the given Kotlin function,
|
||||
@@ -76,7 +81,10 @@ public val KFunction<*>.javaMethod: Method?
|
||||
*/
|
||||
@suppress("UNCHECKED_CAST")
|
||||
public val <T> KFunction<T>.javaConstructor: Constructor<T>?
|
||||
get() = ((this as? KFunctionImpl)?.caller as? FunctionCaller.Constructor)?.constructor as? Constructor<T>
|
||||
get() = when (this) {
|
||||
is KFunctionImpl -> (caller as? FunctionCaller.Constructor)?.constructor as? Constructor<T>
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user