Initial support of function callable references
This commit is contained in:
+24
@@ -87,6 +87,30 @@ fun ClassDescriptor.getFunction(name: String, types: List<KotlinType>): Function
|
||||
.getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_BACKEND).single().substitute(typeSubstitutor)!!
|
||||
}
|
||||
|
||||
fun ClassDescriptor.getStaticFunction(name: String, types: List<KotlinType>): FunctionDescriptor {
|
||||
val typeSubstitutor = TypeSubstitutor.create(
|
||||
declaredTypeParameters
|
||||
.withIndex()
|
||||
.associateBy({ it.value.typeConstructor }, { TypeProjectionImpl(types[it.index]) })
|
||||
)
|
||||
return staticScope
|
||||
.getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_BACKEND).single().substitute(typeSubstitutor)!!
|
||||
}
|
||||
|
||||
fun ClassDescriptor.getProperty(name: String, types: List<KotlinType>): PropertyDescriptor {
|
||||
val typeSubstitutor = TypeSubstitutor.create(
|
||||
declaredTypeParameters
|
||||
.withIndex()
|
||||
.associateBy({ it.value.typeConstructor }, { TypeProjectionImpl(types[it.index]) })
|
||||
)
|
||||
return unsubstitutedMemberScope
|
||||
.getContributedVariables(
|
||||
Name.identifier(name),
|
||||
NoLookupLocation.FROM_BACKEND
|
||||
).single().substitute(typeSubstitutor) as PropertyDescriptor
|
||||
}
|
||||
|
||||
|
||||
val KotlinType.isFunctionOrKFunctionType: Boolean
|
||||
get() {
|
||||
val kind = constructor.declarationDescriptor?.getFunctionalClassKind()
|
||||
|
||||
@@ -175,6 +175,8 @@ abstract class Symbols<out T : CommonBackendContext>(val context: T, private val
|
||||
|
||||
val kFunctionImpl = calc { symbolTable.referenceClass(context.reflectionTypes.kFunctionImpl) }
|
||||
|
||||
val functionReference = calc { symbolTable.referenceClass(context.getInternalClass("FunctionReference")) }
|
||||
|
||||
val kProperty0Impl = calc { symbolTable.referenceClass(context.reflectionTypes.kProperty0Impl) }
|
||||
val kProperty1Impl = calc { symbolTable.referenceClass(context.reflectionTypes.kProperty1Impl) }
|
||||
val kProperty2Impl = calc { symbolTable.referenceClass(context.reflectionTypes.kProperty2Impl) }
|
||||
|
||||
+1
-1
@@ -239,7 +239,7 @@ fun IrConstructor.callsSuper(): Boolean {
|
||||
return callsSuper
|
||||
}
|
||||
|
||||
fun ParameterDescriptor.copyAsValueParameter(newOwner: CallableDescriptor, index: Int) = when (this) {
|
||||
fun ParameterDescriptor.copyAsValueParameter(newOwner: CallableDescriptor, index: Int, name: Name = this.name) = when (this) {
|
||||
is ValueParameterDescriptor -> this.copy(newOwner, name, index)
|
||||
is ReceiverParameterDescriptor -> ValueParameterDescriptorImpl(
|
||||
containingDeclaration = newOwner,
|
||||
|
||||
Reference in New Issue
Block a user