Minor. Move createFunctionType to core
As it will be used in the type mapper soon
This commit is contained in:
committed by
Stanislav Erokhin
parent
72401efb9f
commit
b1d1128466
+2
-34
@@ -16,19 +16,16 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.util
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.getFunctionTypeArgumentProjections
|
||||
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl
|
||||
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.*
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeProjection
|
||||
|
||||
fun createValueParametersForInvokeInFunctionType(
|
||||
functionDescriptor: FunctionDescriptor, parameterTypes: List<TypeProjection>
|
||||
@@ -46,35 +43,6 @@ fun createValueParametersForInvokeInFunctionType(
|
||||
}
|
||||
}
|
||||
|
||||
fun createFunctionType(
|
||||
builtIns: KotlinBuiltIns,
|
||||
annotations: Annotations,
|
||||
receiverType: KotlinType?,
|
||||
parameterTypes: List<KotlinType>,
|
||||
parameterNames: List<Name>?,
|
||||
returnType: KotlinType
|
||||
): SimpleType {
|
||||
val arguments = getFunctionTypeArgumentProjections(receiverType, parameterTypes, parameterNames, returnType, builtIns)
|
||||
val size = parameterTypes.size
|
||||
val classDescriptor = builtIns.getFunction(if (receiverType == null) size else size + 1)
|
||||
|
||||
val typeAnnotations =
|
||||
if (receiverType == null || annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.extensionFunctionType) != null) {
|
||||
annotations
|
||||
}
|
||||
else {
|
||||
val extensionFunctionAnnotation = AnnotationDescriptorImpl(
|
||||
builtIns.getBuiltInClassByName(KotlinBuiltIns.FQ_NAMES.extensionFunctionType.shortName()).defaultType,
|
||||
emptyMap(), SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
// TODO: preserve laziness of given annotations
|
||||
AnnotationsImpl(annotations + extensionFunctionAnnotation)
|
||||
}
|
||||
|
||||
return KotlinTypeFactory.simpleNotNullType(typeAnnotations, classDescriptor, arguments)
|
||||
}
|
||||
|
||||
fun getValueParametersCountFromFunctionType(type: KotlinType): Int {
|
||||
assert(type.isFunctionType) { "Not a function type: $type" }
|
||||
// Function type arguments = receiver? + parameters + return-type
|
||||
|
||||
Reference in New Issue
Block a user