Support KParameter.kind: instance, extension receiver, or value

This commit is contained in:
Alexander Udalov
2015-08-20 16:27:09 -07:00
parent a73d02418d
commit d4825cf4f0
5 changed files with 48 additions and 3 deletions
@@ -36,15 +36,15 @@ interface KCallableImpl<out R> : KCallable<R>, KAnnotatedElementImpl {
var index = 0
if (descriptor.dispatchReceiverParameter != null) {
result.add(KParameterImpl(this, index++) { descriptor.dispatchReceiverParameter!! })
result.add(KParameterImpl(this, index++, KParameter.Kind.INSTANCE) { descriptor.dispatchReceiverParameter!! })
}
if (descriptor.extensionReceiverParameter != null) {
result.add(KParameterImpl(this, index++) { descriptor.extensionReceiverParameter!! })
result.add(KParameterImpl(this, index++, KParameter.Kind.EXTENSION_RECEIVER) { descriptor.extensionReceiverParameter!! })
}
for (i in descriptor.valueParameters.indices) {
result.add(KParameterImpl(this, index++) { descriptor.valueParameters[i] })
result.add(KParameterImpl(this, index++, KParameter.Kind.VALUE) { descriptor.valueParameters[i] })
}
result.trimToSize()
@@ -25,6 +25,7 @@ import kotlin.reflect.KType
class KParameterImpl(
val callable: KCallableImpl<*>,
override val index: Int,
override val kind: KParameter.Kind,
computeDescriptor: () -> ParameterDescriptor
) : KParameter, KAnnotatedElementImpl {
private val descriptor: ParameterDescriptor by ReflectProperties.lazySoft(computeDescriptor)