Methods in KotlinBuiltIns made static where already possible
This commit is contained in:
+1
-1
@@ -232,7 +232,7 @@ public class DiagnosticsWithSuppression implements Diagnostics {
|
||||
builder.addAll(suppressStringProvider.get(annotationDescriptor));
|
||||
}
|
||||
|
||||
if (!KotlinBuiltIns.getInstance().isSuppressAnnotation(annotationDescriptor)) continue;
|
||||
if (!KotlinBuiltIns.isSuppressAnnotation(annotationDescriptor)) continue;
|
||||
|
||||
// We only add strings and skip other values to facilitate recovery in presence of erroneous code
|
||||
for (CompileTimeConstant<?> arrayValue : annotationDescriptor.getAllValueArguments().values()) {
|
||||
|
||||
@@ -98,12 +98,12 @@ public class FunctionDescriptorUtil {
|
||||
@NotNull Visibility visibility
|
||||
) {
|
||||
|
||||
assert KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(functionType);
|
||||
functionDescriptor.initialize(KotlinBuiltIns.getInstance().getReceiverType(functionType),
|
||||
assert KotlinBuiltIns.isFunctionOrExtensionFunctionType(functionType);
|
||||
functionDescriptor.initialize(KotlinBuiltIns.getReceiverType(functionType),
|
||||
dispatchReceiverParameter,
|
||||
Collections.<TypeParameterDescriptorImpl>emptyList(),
|
||||
KotlinBuiltIns.getInstance().getValueParameters(functionDescriptor, functionType),
|
||||
KotlinBuiltIns.getInstance().getReturnTypeFromFunctionType(functionType),
|
||||
KotlinBuiltIns.getValueParameters(functionDescriptor, functionType),
|
||||
KotlinBuiltIns.getReturnTypeFromFunctionType(functionType),
|
||||
modality,
|
||||
visibility);
|
||||
}
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ public class ArgumentTypeResolver {
|
||||
}
|
||||
|
||||
private static boolean isFunctionOrErrorType(@NotNull JetType supertype) {
|
||||
return KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(supertype) || supertype.isError();
|
||||
return KotlinBuiltIns.isFunctionOrExtensionFunctionType(supertype) || supertype.isError();
|
||||
}
|
||||
|
||||
public void checkTypesWithNoCallee(@NotNull CallResolutionContext<?> context) {
|
||||
|
||||
@@ -42,7 +42,7 @@ public class CallResolverUtil {
|
||||
|
||||
|
||||
public static boolean hasUnknownFunctionParameter(@NotNull JetType type) {
|
||||
assert KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(type);
|
||||
assert KotlinBuiltIns.isFunctionOrExtensionFunctionType(type);
|
||||
List<TypeProjection> arguments = type.getArguments();
|
||||
// last argument is return type of function type
|
||||
List<TypeProjection> functionParameters = arguments.subList(0, arguments.size() - 1);
|
||||
@@ -56,13 +56,13 @@ public class CallResolverUtil {
|
||||
}
|
||||
|
||||
public static boolean hasUnknownReturnType(@NotNull JetType type) {
|
||||
assert KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(type);
|
||||
JetType returnTypeFromFunctionType = KotlinBuiltIns.getInstance().getReturnTypeFromFunctionType(type);
|
||||
assert KotlinBuiltIns.isFunctionOrExtensionFunctionType(type);
|
||||
JetType returnTypeFromFunctionType = KotlinBuiltIns.getReturnTypeFromFunctionType(type);
|
||||
return ErrorUtils.containsErrorType(returnTypeFromFunctionType);
|
||||
}
|
||||
|
||||
public static JetType replaceReturnTypeByUnknown(@NotNull JetType type) {
|
||||
assert KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(type);
|
||||
assert KotlinBuiltIns.isFunctionOrExtensionFunctionType(type);
|
||||
List<TypeProjection> arguments = type.getArguments();
|
||||
List<TypeProjection> newArguments = Lists.newArrayList();
|
||||
newArguments.addAll(arguments.subList(0, arguments.size() - 1));
|
||||
|
||||
@@ -250,7 +250,7 @@ public class CandidateResolver {
|
||||
if (expectedType == null || TypeUtils.isDontCarePlaceholder(expectedType)) {
|
||||
expectedType = argumentTypeResolver.getShapeTypeOfFunctionLiteral(functionLiteralExpression, context.scope, context.trace, false);
|
||||
}
|
||||
if (expectedType == null || !KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(expectedType)
|
||||
if (expectedType == null || !KotlinBuiltIns.isFunctionOrExtensionFunctionType(expectedType)
|
||||
|| CallResolverUtil.hasUnknownFunctionParameter(expectedType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-2
@@ -221,7 +221,7 @@ public class InlineCallResolverExtension implements CallResolverExtension {
|
||||
private static boolean isInlinableParameter(@NotNull CallableDescriptor descriptor) {
|
||||
JetType type = descriptor.getReturnType();
|
||||
return type != null &&
|
||||
KotlinBuiltIns.getInstance().isExactFunctionOrExtensionFunctionType(type) &&
|
||||
KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(type) &&
|
||||
!type.isNullable() &&
|
||||
!InlineUtil.hasNoinlineAnnotation(descriptor);
|
||||
}
|
||||
@@ -234,7 +234,7 @@ public class InlineCallResolverExtension implements CallResolverExtension {
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
boolean isInvoke = descriptor.getName().asString().equals("invoke") &&
|
||||
containingDeclaration instanceof ClassDescriptor &&
|
||||
KotlinBuiltIns.getInstance().isExactFunctionOrExtensionFunctionType(((ClassDescriptor) containingDeclaration).getDefaultType());
|
||||
KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(((ClassDescriptor) containingDeclaration).getDefaultType());
|
||||
|
||||
return isInvoke ||
|
||||
//or inline extension
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ private fun getSuperClassesReachableByClassInheritance(
|
||||
): Set<ClassDescriptor> {
|
||||
val superClass = getSuperClass(descriptor)
|
||||
result.add(superClass)
|
||||
if (!KotlinBuiltIns.getInstance().isAny(superClass)) {
|
||||
if (!KotlinBuiltIns.isAny(superClass)) {
|
||||
getSuperClassesReachableByClassInheritance(superClass, result)
|
||||
}
|
||||
return result
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ public class TracingStrategyForInvoke extends AbstractTracingStrategy {
|
||||
}
|
||||
|
||||
private void functionExpectedOrNoReceiverAllowed(BindingTrace trace) {
|
||||
if (KotlinBuiltIns.getInstance().isFunctionType(calleeType)) {
|
||||
if (KotlinBuiltIns.isFunctionType(calleeType)) {
|
||||
LOG.assertTrue(call.getExplicitReceiver().exists(),
|
||||
"'Invoke' is not found on expression of function type (" + calleeType + "): "
|
||||
+ PsiUtilPackage.getTextWithLocation(call.getCallElement()));
|
||||
|
||||
+1
-2
@@ -149,9 +149,8 @@ public class InlineAnalyzerExtension implements FunctionAnalyzerExtension.Analyz
|
||||
@NotNull CallableDescriptor functionDescriptor,
|
||||
@Nullable BindingTrace trace
|
||||
) {
|
||||
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||
JetType type = parameter.getReturnType();
|
||||
if (type != null && builtIns.isExactFunctionOrExtensionFunctionType(type)) {
|
||||
if (type != null && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(type)) {
|
||||
if (!InlineUtil.hasNoinlineAnnotation(parameter)) {
|
||||
if (type.isNullable()) {
|
||||
if (trace != null) {
|
||||
|
||||
+1
-1
@@ -500,7 +500,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
new Function0<Supertypes>() {
|
||||
@Override
|
||||
public Supertypes invoke() {
|
||||
if (KotlinBuiltIns.getInstance().isSpecialClassWithNoSupertypes(LazyClassDescriptor.this)) {
|
||||
if (KotlinBuiltIns.isSpecialClassWithNoSupertypes(LazyClassDescriptor.this)) {
|
||||
return new Supertypes(Collections.<JetType>emptyList());
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -107,7 +107,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (!expression.getFunctionLiteral().hasBody()) return null;
|
||||
|
||||
JetType expectedType = context.expectedType;
|
||||
boolean functionTypeExpected = !noExpectedType(expectedType) && KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(
|
||||
boolean functionTypeExpected = !noExpectedType(expectedType) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(
|
||||
expectedType);
|
||||
|
||||
AnonymousFunctionDescriptor functionDescriptor = createFunctionDescriptor(expression, context, functionTypeExpected);
|
||||
@@ -118,7 +118,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
List<JetType> valueParametersTypes = ExpressionTypingUtils.getValueParametersTypes(functionDescriptor.getValueParameters());
|
||||
JetType resultType = KotlinBuiltIns.getInstance().getFunctionType(
|
||||
Annotations.EMPTY, receiver, valueParametersTypes, safeReturnType);
|
||||
if (!noExpectedType(expectedType) && KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(expectedType)) {
|
||||
if (!noExpectedType(expectedType) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(expectedType)) {
|
||||
// all checks were done before
|
||||
return JetTypeInfo.create(resultType, context.dataFlowInfo);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetType effectiveReceiverType;
|
||||
if (receiverTypeRef == null) {
|
||||
if (functionTypeExpected) {
|
||||
effectiveReceiverType = KotlinBuiltIns.getInstance().getReceiverType(context.expectedType);
|
||||
effectiveReceiverType = KotlinBuiltIns.getReceiverType(context.expectedType);
|
||||
}
|
||||
else {
|
||||
effectiveReceiverType = null;
|
||||
@@ -177,7 +177,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
List<JetParameter> declaredValueParameters = functionLiteral.getValueParameters();
|
||||
|
||||
List<ValueParameterDescriptor> expectedValueParameters = (functionTypeExpected)
|
||||
? KotlinBuiltIns.getInstance().getValueParameters(functionDescriptor, context.expectedType)
|
||||
? KotlinBuiltIns.getValueParameters(functionDescriptor, context.expectedType)
|
||||
: null;
|
||||
|
||||
JetParameterList valueParameterList = functionLiteral.getValueParameterList();
|
||||
@@ -261,7 +261,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
@NotNull SimpleFunctionDescriptorImpl functionDescriptor,
|
||||
boolean functionTypeExpected
|
||||
) {
|
||||
JetType expectedReturnType = functionTypeExpected ? KotlinBuiltIns.getInstance().getReturnTypeFromFunctionType(context.expectedType) : null;
|
||||
JetType expectedReturnType = functionTypeExpected ? KotlinBuiltIns.getReturnTypeFromFunctionType(context.expectedType) : null;
|
||||
JetType returnType = computeUnsafeReturnType(expression, context, functionDescriptor, expectedReturnType);
|
||||
|
||||
if (!expression.getFunctionLiteral().hasDeclaredReturnType() && functionTypeExpected) {
|
||||
|
||||
Reference in New Issue
Block a user