Supported obtaining function type parameter names from KotlinType

This commit is contained in:
Valentin Kipyatkov
2016-09-13 12:07:59 +03:00
parent 8d7b59777c
commit 147d1da1ed
12 changed files with 86 additions and 17 deletions
@@ -28,10 +28,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.annotations.AnnotationsImpl
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.KotlinTypeFactory
import org.jetbrains.kotlin.types.SimpleType
import org.jetbrains.kotlin.types.TypeProjection
import org.jetbrains.kotlin.types.*
fun createValueParametersForInvokeInFunctionType(
functionDescriptor: FunctionDescriptor, parameterTypes: List<TypeProjection>
@@ -54,8 +51,9 @@ fun createFunctionType(
annotations: Annotations,
receiverType: KotlinType?,
parameterTypes: List<KotlinType>,
parameterNames: List<Name>,
returnType: KotlinType
): SimpleType {
): FunctionType {
val arguments = getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType)
val size = parameterTypes.size
val classDescriptor = builtIns.getFunction(if (receiverType == null) size else size + 1)
@@ -74,7 +72,7 @@ fun createFunctionType(
AnnotationsImpl(annotations + extensionFunctionAnnotation)
}
return KotlinTypeFactory.simpleNotNullType(typeAnnotations, classDescriptor, arguments)
return KotlinTypeFactory.functionType(typeAnnotations, classDescriptor, arguments, parameterNames)
}
fun getValueParametersCountFromFunctionType(type: KotlinType): Int {