Support KCallable.callBy with map of parameters to arguments
callBy is able to handle optional parameters. #KT-8827 Fixed
This commit is contained in:
@@ -45,9 +45,16 @@ public interface KCallable<out R> : KAnnotatedElement {
|
||||
public val returnType: KType
|
||||
|
||||
/**
|
||||
* Calls this callable with the specified arguments and returns the result.
|
||||
* Calls this callable with the specified list of arguments and returns the result.
|
||||
* Throws an exception if the number of specified arguments is not equal to the size of [parameters],
|
||||
* or if their types do not match the types of the parameters.
|
||||
*/
|
||||
public fun call(vararg args: Any?): R
|
||||
|
||||
/**
|
||||
* Calls this callable with the specified mapping of parameters to arguments and returns the result.
|
||||
* If a parameter is not found in the mapping and is not optional (as per [KParameter.isOptional]),
|
||||
* or its type does not match the type of the provided value, an exception is thrown.
|
||||
*/
|
||||
public fun callBy(args: Map<KParameter, Any?>): R
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public interface KParameter : KAnnotatedElement {
|
||||
}
|
||||
|
||||
/**
|
||||
* `true` if this parameter is optional, or `false` otherwise.
|
||||
* `true` if this parameter is optional and can be omitted when making a call via [KCallable.call], or `false` otherwise.
|
||||
*
|
||||
* A parameter is optional in any of the two cases:
|
||||
* 1. The default value is provided at the declaration of this parameter.
|
||||
|
||||
Reference in New Issue
Block a user