Rename KotlinBuiltIns.getFunctionType -> createFunctionType, move to functionTypes.kt
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.builtins.FunctionTypesKt;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
|
||||
@@ -76,7 +77,8 @@ public class JvmRuntimeTypes {
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
KotlinType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType(
|
||||
KotlinType functionType = FunctionTypesKt.createFunctionType(
|
||||
DescriptorUtilsKt.getBuiltIns(descriptor),
|
||||
Annotations.Companion.getEMPTY(),
|
||||
receiverParameter == null ? null : receiverParameter.getType(),
|
||||
ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()),
|
||||
@@ -95,7 +97,8 @@ public class JvmRuntimeTypes {
|
||||
extensionReceiver != null ? extensionReceiver.getType() : dispatchReceiver != null ? dispatchReceiver.getType() : null;
|
||||
|
||||
//noinspection ConstantConditions
|
||||
KotlinType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType(
|
||||
KotlinType functionType = FunctionTypesKt.createFunctionType(
|
||||
DescriptorUtilsKt.getBuiltIns(descriptor),
|
||||
Annotations.Companion.getEMPTY(),
|
||||
receiverType,
|
||||
ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()),
|
||||
|
||||
+6
-3
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.load.java.sam;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.FunctionTypesKt;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
@@ -31,7 +32,7 @@ import org.jetbrains.kotlin.resolve.jvm.JavaResolverUtils;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -89,7 +90,9 @@ public class SingleAbstractMethodUtils {
|
||||
for (ValueParameterDescriptor parameter : valueParameters) {
|
||||
parameterTypes.add(parameter.getType());
|
||||
}
|
||||
return DescriptorUtilsKt.getBuiltIns(function).getFunctionType(Annotations.Companion.getEMPTY(), null, parameterTypes, returnType);
|
||||
return FunctionTypesKt.createFunctionType(
|
||||
DescriptorUtilsKt.getBuiltIns(function), Annotations.Companion.getEMPTY(), null, parameterTypes, returnType
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -142,7 +145,7 @@ public class SingleAbstractMethodUtils {
|
||||
null,
|
||||
null,
|
||||
typeParameters.descriptors,
|
||||
Arrays.asList(parameter),
|
||||
Collections.singletonList(parameter),
|
||||
returnType,
|
||||
Modality.FINAL,
|
||||
samInterface.getVisibility()
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import com.intellij.util.SmartList
|
||||
import org.jetbrains.kotlin.builtins.createFunctionType
|
||||
import org.jetbrains.kotlin.context.TypeLazinessToken
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
@@ -206,11 +207,9 @@ class TypeResolver(
|
||||
val returnType = if (returnTypeRef != null) resolveType(c.noBareTypes(), returnTypeRef)
|
||||
else moduleDescriptor.builtIns.unitType
|
||||
|
||||
result = type(
|
||||
moduleDescriptor.builtIns.getFunctionType(
|
||||
annotations, receiverType, parameterDescriptors.map { it.type }, returnType
|
||||
)
|
||||
)
|
||||
result = type(createFunctionType(
|
||||
moduleDescriptor.builtIns, annotations, receiverType, parameterDescriptors.map { it.type }, returnType
|
||||
))
|
||||
}
|
||||
|
||||
private fun resolveParametersOfFunctionType(parameters: List<KtParameter>): List<VariableDescriptor> {
|
||||
|
||||
+1
-1
@@ -319,5 +319,5 @@ fun getResolvedCallableReferenceShapeType(
|
||||
expectedTypeUnknown /* && overload resolution was ambiguous */ ->
|
||||
functionPlaceholders.createFunctionPlaceholderType(emptyList(), false)
|
||||
else ->
|
||||
builtIns.getFunctionType(Annotations.EMPTY, null, emptyList(), TypeUtils.DONT_CARE)
|
||||
createFunctionType(builtIns, Annotations.EMPTY, null, emptyList(), TypeUtils.DONT_CARE)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.FunctionTypesKt;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.builtins.ReflectionTypes;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
@@ -245,7 +246,8 @@ public class ArgumentTypeResolver {
|
||||
callResolver);
|
||||
return CallableReferencesResolutionUtilsKt.getResolvedCallableReferenceShapeType(
|
||||
callableReferenceExpression, receiverType, overloadResolutionResults, context, expectedTypeIsUnknown,
|
||||
reflectionTypes, builtIns, functionPlaceholders);
|
||||
reflectionTypes, builtIns, functionPlaceholders
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -274,7 +276,9 @@ public class ArgumentTypeResolver {
|
||||
return expectedTypeIsUnknown
|
||||
? functionPlaceholders
|
||||
.createFunctionPlaceholderType(Collections.<KotlinType>emptyList(), /* hasDeclaredArguments = */ false)
|
||||
: builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, Collections.<KotlinType>emptyList(), DONT_CARE);
|
||||
: FunctionTypesKt.createFunctionType(
|
||||
builtIns, Annotations.Companion.getEMPTY(), null, Collections.<KotlinType>emptyList(), DONT_CARE
|
||||
);
|
||||
}
|
||||
List<KtParameter> valueParameters = function.getValueParameters();
|
||||
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(
|
||||
@@ -289,7 +293,7 @@ public class ArgumentTypeResolver {
|
||||
|
||||
return expectedTypeIsUnknown && isFunctionLiteral
|
||||
? functionPlaceholders.createFunctionPlaceholderType(parameterTypes, /* hasDeclaredArguments = */ true)
|
||||
: builtIns.getFunctionType(Annotations.Companion.getEMPTY(), receiverType, parameterTypes, returnType);
|
||||
: FunctionTypesKt.createFunctionType(builtIns, Annotations.Companion.getEMPTY(), receiverType, parameterTypes, returnType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -21,6 +21,7 @@ import kotlin.Pair;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.FunctionTypesKt;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
@@ -288,7 +289,9 @@ public class CallResolver {
|
||||
for (int i = 0; i < parameterNumber; i++) {
|
||||
parameterTypes.add(NO_EXPECTED_TYPE);
|
||||
}
|
||||
expectedType = builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, parameterTypes, context.expectedType);
|
||||
expectedType = FunctionTypesKt.createFunctionType(
|
||||
builtIns, Annotations.Companion.getEMPTY(), null, parameterTypes, context.expectedType
|
||||
);
|
||||
}
|
||||
KotlinType calleeType = expressionTypingServices.safeGetType(
|
||||
context.scope, calleeExpression, expectedType, context.dataFlowInfo, context.trace);
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.inference
|
||||
|
||||
import org.jetbrains.kotlin.builtins.createFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
@@ -433,5 +434,5 @@ internal fun createTypeForFunctionPlaceholder(
|
||||
functionPlaceholderTypeConstructor.argumentTypes
|
||||
}
|
||||
val receiverType = if (isExtension) DONT_CARE else null
|
||||
return functionPlaceholder.builtIns.getFunctionType(Annotations.EMPTY, receiverType, newArgumentTypes, DONT_CARE)
|
||||
return createFunctionType(functionPlaceholder.builtIns, Annotations.EMPTY, receiverType, newArgumentTypes, DONT_CARE)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.tasks
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.createFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.*
|
||||
@@ -174,7 +175,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
|
||||
val receiverType = funLiteral.receiverTypeReference?.let { dynamicType }
|
||||
val parameterTypes = funLiteral.valueParameters.map { dynamicType }
|
||||
|
||||
return owner.builtIns.getFunctionType(Annotations.EMPTY, receiverType, parameterTypes, dynamicType)
|
||||
return createFunctionType(owner.builtIns, Annotations.EMPTY, receiverType, parameterTypes, dynamicType)
|
||||
}
|
||||
|
||||
for (arg in call.valueArguments) {
|
||||
|
||||
+11
-15
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.types.expressions
|
||||
import com.google.common.collect.Lists
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.createFunctionType
|
||||
import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isFunctionOrExtensionFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
@@ -119,23 +120,18 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
|
||||
return createTypeInfo(components.dataFlowAnalyzer.checkStatementType(function, context), context)
|
||||
}
|
||||
else {
|
||||
return components.dataFlowAnalyzer.createCheckedTypeInfo(createFunctionType(functionDescriptor), context, function)
|
||||
return components.dataFlowAnalyzer.createCheckedTypeInfo(functionDescriptor.createFunctionType(), context, function)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createFunctionType(functionDescriptor: SimpleFunctionDescriptor): KotlinType? {
|
||||
val receiverType = functionDescriptor.extensionReceiverParameter?.type
|
||||
|
||||
val returnType = functionDescriptor.returnType
|
||||
if (returnType == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
val parameters = functionDescriptor.valueParameters.map {
|
||||
it.type
|
||||
}
|
||||
|
||||
return components.builtIns.getFunctionType(Annotations.EMPTY, receiverType, parameters, returnType)
|
||||
private fun SimpleFunctionDescriptor.createFunctionType(): KotlinType? {
|
||||
return createFunctionType(
|
||||
components.builtIns,
|
||||
Annotations.EMPTY,
|
||||
extensionReceiverParameter?.type,
|
||||
valueParameters.map { it.type },
|
||||
returnType ?: return null
|
||||
)
|
||||
}
|
||||
|
||||
override fun visitLambdaExpression(expression: KtLambdaExpression, context: ExpressionTypingContext): KotlinTypeInfo? {
|
||||
@@ -154,7 +150,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
|
||||
val safeReturnType = computeReturnType(expression, context, functionDescriptor, functionTypeExpected)
|
||||
functionDescriptor.setReturnType(safeReturnType)
|
||||
|
||||
val resultType = createFunctionType(functionDescriptor)!!
|
||||
val resultType = functionDescriptor.createFunctionType()!!
|
||||
if (functionTypeExpected) {
|
||||
// all checks were done before
|
||||
return createTypeInfo(resultType, context)
|
||||
|
||||
Reference in New Issue
Block a user