Automatically put 'operator' modifier on appropriate Java methods
This commit is contained in:
+1
-3
@@ -47,9 +47,7 @@ public class AccessorForConstructorDescriptor(
|
|||||||
copyValueParameters(calleeDescriptor),
|
copyValueParameters(calleeDescriptor),
|
||||||
calleeDescriptor.returnType,
|
calleeDescriptor.returnType,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
Visibilities.LOCAL,
|
Visibilities.LOCAL
|
||||||
false,
|
|
||||||
false
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -47,9 +47,9 @@ public class AccessorForFunctionDescriptor extends AbstractAccessorForFunctionDe
|
|||||||
copyValueParameters(descriptor),
|
copyValueParameters(descriptor),
|
||||||
descriptor.getReturnType(),
|
descriptor.getReturnType(),
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
Visibilities.LOCAL,
|
Visibilities.LOCAL);
|
||||||
descriptor.isOperator(),
|
setOperator(descriptor.isOperator());
|
||||||
descriptor.isInfix());
|
setInfix(descriptor.isInfix());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
|||||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
|
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
|
||||||
import org.jetbrains.kotlin.serialization.ProtoBuf;
|
import org.jetbrains.kotlin.serialization.ProtoBuf;
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
import org.jetbrains.kotlin.types.JetType;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
import org.jetbrains.kotlin.utils.UtilsPackage;
|
import org.jetbrains.kotlin.utils.UtilsPackage;
|
||||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
||||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||||
@@ -194,7 +194,7 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
|
|||||||
descriptorForBridges
|
descriptorForBridges
|
||||||
.initialize(null, erasedInterfaceFunction.getDispatchReceiverParameter(), erasedInterfaceFunction.getTypeParameters(),
|
.initialize(null, erasedInterfaceFunction.getDispatchReceiverParameter(), erasedInterfaceFunction.getTypeParameters(),
|
||||||
erasedInterfaceFunction.getValueParameters(), erasedInterfaceFunction.getReturnType(),
|
erasedInterfaceFunction.getValueParameters(), erasedInterfaceFunction.getReturnType(),
|
||||||
Modality.OPEN, erasedInterfaceFunction.getVisibility(), false, false);
|
Modality.OPEN, erasedInterfaceFunction.getVisibility());
|
||||||
|
|
||||||
descriptorForBridges.addOverriddenDescriptor(erasedInterfaceFunction);
|
descriptorForBridges.addOverriddenDescriptor(erasedInterfaceFunction);
|
||||||
functionCodegen.generateBridges(descriptorForBridges);
|
functionCodegen.generateBridges(descriptorForBridges);
|
||||||
@@ -465,6 +465,6 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
|
|||||||
? getBuiltIns(elementDescriptor).getFunction(arity)
|
? getBuiltIns(elementDescriptor).getFunction(arity)
|
||||||
: getBuiltIns(elementDescriptor).getExtensionFunction(arity);
|
: getBuiltIns(elementDescriptor).getExtensionFunction(arity);
|
||||||
JetScope scope = elementClass.getDefaultType().getMemberScope();
|
JetScope scope = elementClass.getDefaultType().getMemberScope();
|
||||||
return scope.getFunctions(OperatorConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next();
|
return scope.getFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
|
|||||||
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||||
Collections.<ValueParameterDescriptor>emptyList(),
|
Collections.<ValueParameterDescriptor>emptyList(),
|
||||||
DescriptorUtilPackage.getModule(descriptor).getBuiltIns().getUnitType(),
|
DescriptorUtilPackage.getModule(descriptor).getBuiltIns().getUnitType(),
|
||||||
null, Visibilities.PRIVATE, false, false);
|
null, Visibilities.PRIVATE);
|
||||||
|
|
||||||
this.clInit = new ExpressionCodegen(mv, new FrameMap(), Type.VOID_TYPE, context.intoFunction(clInit), state, this);
|
this.clInit = new ExpressionCodegen(mv, new FrameMap(), Type.VOID_TYPE, context.intoFunction(clInit), state, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public class PropertyReferenceCodegen(
|
|||||||
SourceElement.NO_SOURCE
|
SourceElement.NO_SOURCE
|
||||||
)
|
)
|
||||||
fakeDescriptor.initialize(null, classDescriptor.getThisAsReceiverParameter(), emptyList(), emptyList(),
|
fakeDescriptor.initialize(null, classDescriptor.getThisAsReceiverParameter(), emptyList(), emptyList(),
|
||||||
classDescriptor.builtIns.getAnyType(), Modality.OPEN, Visibilities.PUBLIC, false, false)
|
classDescriptor.builtIns.getAnyType(), Modality.OPEN, Visibilities.PUBLIC)
|
||||||
|
|
||||||
val fakeCodegen = ExpressionCodegen(
|
val fakeCodegen = ExpressionCodegen(
|
||||||
this, FrameMap(), OBJECT_TYPE, context.intoFunction(fakeDescriptor), state, this@PropertyReferenceCodegen
|
this, FrameMap(), OBJECT_TYPE, context.intoFunction(fakeDescriptor), state, this@PropertyReferenceCodegen
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.name.Name;
|
|||||||
import org.jetbrains.kotlin.psi.JetFile;
|
import org.jetbrains.kotlin.psi.JetFile;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
import org.jetbrains.kotlin.types.JetType;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||||
@@ -147,7 +147,7 @@ public class SamWrapperCodegen {
|
|||||||
(ClassDescriptor) erasedInterfaceFunction.getContainingDeclaration(), OwnerKind.IMPLEMENTATION, state), cv, state, parentCodegen);
|
(ClassDescriptor) erasedInterfaceFunction.getContainingDeclaration(), OwnerKind.IMPLEMENTATION, state), cv, state, parentCodegen);
|
||||||
|
|
||||||
FunctionDescriptor invokeFunction =
|
FunctionDescriptor invokeFunction =
|
||||||
functionJetType.getMemberScope().getFunctions(OperatorConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next().getOriginal();
|
functionJetType.getMemberScope().getFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next().getOriginal();
|
||||||
StackValue functionField = StackValue.field(functionType, ownerType, FUNCTION_FIELD_NAME, false, StackValue.none());
|
StackValue functionField = StackValue.field(functionType, ownerType, FUNCTION_FIELD_NAME, false, StackValue.none());
|
||||||
codegen.genDelegate(erasedInterfaceFunction, invokeFunction, functionField);
|
codegen.genDelegate(erasedInterfaceFunction, invokeFunction, functionField);
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ public class SamWrapperCodegen {
|
|||||||
descriptorForBridges
|
descriptorForBridges
|
||||||
.initialize(null, originalInterfaceErased.getDispatchReceiverParameter(), originalInterfaceErased.getTypeParameters(),
|
.initialize(null, originalInterfaceErased.getDispatchReceiverParameter(), originalInterfaceErased.getTypeParameters(),
|
||||||
originalInterfaceErased.getValueParameters(), originalInterfaceErased.getReturnType(),
|
originalInterfaceErased.getValueParameters(), originalInterfaceErased.getReturnType(),
|
||||||
Modality.OPEN, originalInterfaceErased.getVisibility(), false, false);
|
Modality.OPEN, originalInterfaceErased.getVisibility());
|
||||||
|
|
||||||
descriptorForBridges.addOverriddenDescriptor(originalInterfaceErased);
|
descriptorForBridges.addOverriddenDescriptor(originalInterfaceErased);
|
||||||
codegen.generateBridges(descriptorForBridges);
|
codegen.generateBridges(descriptorForBridges);
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage;
|
|||||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes;
|
import org.jetbrains.kotlin.resolve.jvm.AsmTypes;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName;
|
import org.jetbrains.kotlin.resolve.jvm.JvmClassName;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
import org.jetbrains.org.objectweb.asm.*;
|
import org.jetbrains.org.objectweb.asm.*;
|
||||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||||
import org.jetbrains.org.objectweb.asm.tree.*;
|
import org.jetbrains.org.objectweb.asm.tree.*;
|
||||||
@@ -235,7 +236,7 @@ public class InlineCodegenUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInvokeOnLambda(@NotNull String owner, @NotNull String name) {
|
public static boolean isInvokeOnLambda(@NotNull String owner, @NotNull String name) {
|
||||||
return OperatorConventions.INVOKE.asString().equals(name) &&
|
return OperatorNameConventions.INVOKE.asString().equals(name) &&
|
||||||
owner.startsWith(NUMBERED_FUNCTION_PREFIX) &&
|
owner.startsWith(NUMBERED_FUNCTION_PREFIX) &&
|
||||||
isInteger(owner.substring(NUMBERED_FUNCTION_PREFIX.length()));
|
isInteger(owner.substring(NUMBERED_FUNCTION_PREFIX.length()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
|||||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializedType;
|
import org.jetbrains.kotlin.serialization.deserialization.DeserializedType;
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor;
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor;
|
||||||
import org.jetbrains.kotlin.types.*;
|
import org.jetbrains.kotlin.types.*;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
import org.jetbrains.org.objectweb.asm.commons.Method;
|
import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||||
|
|
||||||
@@ -845,10 +845,10 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OperatorConventions.INVOKE.asString();
|
return OperatorNameConventions.INVOKE.asString();
|
||||||
}
|
}
|
||||||
else if (isLocalFunction(descriptor) || isFunctionExpression(descriptor)) {
|
else if (isLocalFunction(descriptor) || isFunctionExpression(descriptor)) {
|
||||||
return OperatorConventions.INVOKE.asString();
|
return OperatorNameConventions.INVOKE.asString();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return updateMemberNameIfInternal(descriptor.getName().asString(), descriptor);
|
return updateMemberNameIfInternal(descriptor.getName().asString(), descriptor);
|
||||||
|
|||||||
+2
-6
@@ -170,9 +170,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
Arrays.asList(parameter),
|
Arrays.asList(parameter),
|
||||||
returnType,
|
returnType,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
samInterface.getVisibility(),
|
samInterface.getVisibility()
|
||||||
false,
|
|
||||||
false
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -208,9 +206,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
valueParameters,
|
valueParameters,
|
||||||
returnType,
|
returnType,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
original.getVisibility(),
|
original.getVisibility()
|
||||||
false,
|
|
||||||
false
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.serialization.deserialization.findClassAcrossModuleD
|
|||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
import org.jetbrains.kotlin.storage.get
|
import org.jetbrains.kotlin.storage.get
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there's no Kotlin reflection implementation found in the classpath, checks that there are no usages
|
* If there's no Kotlin reflection implementation found in the classpath, checks that there are no usages
|
||||||
@@ -58,7 +59,7 @@ class ReflectionAPICallChecker(private val module: ModuleDescriptor, storageMana
|
|||||||
// - 'get'/'set' on properties
|
// - 'get'/'set' on properties
|
||||||
val name = descriptor.getName()
|
val name = descriptor.getName()
|
||||||
when {
|
when {
|
||||||
name == OperatorConventions.INVOKE -> return
|
name == OperatorNameConventions.INVOKE -> return
|
||||||
name.asString() == "name" -> return
|
name.asString() == "name" -> return
|
||||||
(name.asString() == "get" || name.asString() == "set") &&
|
(name.asString() == "get" || name.asString() == "set") &&
|
||||||
kPropertyClasses.any { kProperty -> DescriptorUtils.isSubclass(containingClass, kProperty) } -> return
|
kPropertyClasses.any { kProperty -> DescriptorUtils.isSubclass(containingClass, kProperty) } -> return
|
||||||
|
|||||||
+1
-3
@@ -116,9 +116,7 @@ public class SignaturesPropagationData {
|
|||||||
autoValueParameters,
|
autoValueParameters,
|
||||||
autoReturnType,
|
autoReturnType,
|
||||||
Modality.OPEN,
|
Modality.OPEN,
|
||||||
Visibilities.PUBLIC,
|
Visibilities.PUBLIC
|
||||||
false,
|
|
||||||
false
|
|
||||||
);
|
);
|
||||||
return autoMethodDescriptor;
|
return autoMethodDescriptor;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -129,7 +129,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : JetScope by Jet
|
|||||||
val visibility = syntheticExtensionVisibility(sourceFunction)
|
val visibility = syntheticExtensionVisibility(sourceFunction)
|
||||||
|
|
||||||
descriptor.initialize(receiverType, null, typeParameters, valueParameters, returnType,
|
descriptor.initialize(receiverType, null, typeParameters, valueParameters, returnType,
|
||||||
Modality.FINAL, visibility, false, false)
|
Modality.FINAL, visibility)
|
||||||
|
|
||||||
return descriptor
|
return descriptor
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker.VarianceConf
|
|||||||
import org.jetbrains.kotlin.types.JetType;
|
import org.jetbrains.kotlin.types.JetType;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||||
import org.jetbrains.kotlin.util.MappedExtensionProvider;
|
import org.jetbrains.kotlin.util.MappedExtensionProvider;
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
@@ -560,7 +561,7 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(CONFLICTING_OVERLOADS, "''{0}'' is already defined in {1}", COMPACT_WITH_MODIFIERS, STRING);
|
MAP.put(CONFLICTING_OVERLOADS, "''{0}'' is already defined in {1}", COMPACT_WITH_MODIFIERS, STRING);
|
||||||
|
|
||||||
MAP.put(FUNCTION_EXPECTED, "Expression ''{0}''{1} cannot be invoked as a function. " +
|
MAP.put(FUNCTION_EXPECTED, "Expression ''{0}''{1} cannot be invoked as a function. " +
|
||||||
"The function '" + OperatorConventions.INVOKE.asString() + "()' is not found",
|
"The function '" + OperatorNameConventions.INVOKE.asString() + "()' is not found",
|
||||||
ELEMENT_TEXT, new Renderer<JetType>() {
|
ELEMENT_TEXT, new Renderer<JetType>() {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -242,10 +242,9 @@ public class DescriptorResolver {
|
|||||||
Collections.<ValueParameterDescriptor>emptyList(),
|
Collections.<ValueParameterDescriptor>emptyList(),
|
||||||
returnType,
|
returnType,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
property.getVisibility(),
|
property.getVisibility()
|
||||||
true,
|
|
||||||
false
|
|
||||||
);
|
);
|
||||||
|
functionDescriptor.setOperator(true);
|
||||||
|
|
||||||
trace.record(BindingContext.DATA_CLASS_COMPONENT_FUNCTION, parameter, functionDescriptor);
|
trace.record(BindingContext.DATA_CLASS_COMPONENT_FUNCTION, parameter, functionDescriptor);
|
||||||
|
|
||||||
@@ -292,9 +291,7 @@ public class DescriptorResolver {
|
|||||||
parameterDescriptors,
|
parameterDescriptors,
|
||||||
returnType,
|
returnType,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
Visibilities.PUBLIC,
|
Visibilities.PUBLIC
|
||||||
false,
|
|
||||||
false
|
|
||||||
);
|
);
|
||||||
|
|
||||||
trace.record(BindingContext.DATA_CLASS_COPY_FUNCTION, classDescriptor, functionDescriptor);
|
trace.record(BindingContext.DATA_CLASS_COPY_FUNCTION, classDescriptor, functionDescriptor);
|
||||||
|
|||||||
@@ -172,10 +172,10 @@ class FunctionDescriptorResolver(
|
|||||||
valueParameterDescriptors,
|
valueParameterDescriptors,
|
||||||
returnType,
|
returnType,
|
||||||
modality,
|
modality,
|
||||||
visibility,
|
visibility
|
||||||
function.hasModifier(JetTokens.OPERATOR_KEYWORD),
|
|
||||||
function.hasModifier(JetTokens.INFIX_KEYWORD)
|
|
||||||
)
|
)
|
||||||
|
functionDescriptor.isOperator = function.hasModifier(JetTokens.OPERATOR_KEYWORD)
|
||||||
|
functionDescriptor.isInfix = function.hasModifier(JetTokens.INFIX_KEYWORD)
|
||||||
receiverType?.let { ForceResolveUtil.forceResolveAllContents(it.getAnnotations()) }
|
receiverType?.let { ForceResolveUtil.forceResolveAllContents(it.getAnnotations()) }
|
||||||
for (valueParameterDescriptor in valueParameterDescriptors) {
|
for (valueParameterDescriptor in valueParameterDescriptors) {
|
||||||
ForceResolveUtil.forceResolveAllContents(valueParameterDescriptor.getType().getAnnotations())
|
ForceResolveUtil.forceResolveAllContents(valueParameterDescriptor.getType().getAnnotations())
|
||||||
|
|||||||
@@ -103,9 +103,7 @@ public class FunctionDescriptorUtil {
|
|||||||
KotlinBuiltIns.getValueParameters(functionDescriptor, functionType),
|
KotlinBuiltIns.getValueParameters(functionDescriptor, functionType),
|
||||||
KotlinBuiltIns.getReturnTypeFromFunctionType(functionType),
|
KotlinBuiltIns.getReturnTypeFromFunctionType(functionType),
|
||||||
modality,
|
modality,
|
||||||
visibility,
|
visibility);
|
||||||
false,
|
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <D extends CallableDescriptor> D alphaConvertTypeParameters(D candidate) {
|
public static <D extends CallableDescriptor> D alphaConvertTypeParameters(D candidate) {
|
||||||
@@ -157,9 +155,9 @@ public class FunctionDescriptorUtil {
|
|||||||
parameters,
|
parameters,
|
||||||
function.getReturnType(),
|
function.getReturnType(),
|
||||||
function.getModality(),
|
function.getModality(),
|
||||||
function.getVisibility(),
|
function.getVisibility());
|
||||||
function.isOperator(),
|
descriptor.setOperator(function.isOperator());
|
||||||
function.isInfix());
|
descriptor.setInfix(function.isInfix());
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
|||||||
import org.jetbrains.kotlin.diagnostics.Errors
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens
|
import org.jetbrains.kotlin.lexer.JetTokens
|
||||||
import org.jetbrains.kotlin.psi.JetDeclaration
|
import org.jetbrains.kotlin.psi.JetDeclaration
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions.*
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
public class OperatorModifierChecker : DeclarationChecker {
|
public class OperatorModifierChecker : DeclarationChecker {
|
||||||
override fun check(
|
override fun check(
|
||||||
@@ -51,23 +51,8 @@ public class OperatorModifierChecker : DeclarationChecker {
|
|||||||
if (!functionDescriptor.isOperator) return
|
if (!functionDescriptor.isOperator) return
|
||||||
val modifier = declaration.modifierList?.getModifier(JetTokens.OPERATOR_KEYWORD) ?: return
|
val modifier = declaration.modifierList?.getModifier(JetTokens.OPERATOR_KEYWORD) ?: return
|
||||||
|
|
||||||
val name = functionDescriptor.name
|
if (!OperatorNameConventions.canBeOperator(functionDescriptor)) {
|
||||||
|
diagnosticHolder.report(Errors.INAPPLICABLE_OPERATOR_MODIFIER.on(modifier))
|
||||||
when {
|
|
||||||
GET == name -> {}
|
|
||||||
SET == name -> {}
|
|
||||||
INVOKE == name -> {}
|
|
||||||
CONTAINS == name -> {}
|
|
||||||
ITERATOR == name -> {}
|
|
||||||
NEXT == name -> {}
|
|
||||||
HAS_NEXT == name -> {}
|
|
||||||
EQUALS == name -> {}
|
|
||||||
COMPARE_TO == name -> {}
|
|
||||||
UNARY_OPERATION_NAMES.any { it.value == name } && functionDescriptor.valueParameters.isEmpty() -> {}
|
|
||||||
BINARY_OPERATION_NAMES.any { it.value == name } && functionDescriptor.valueParameters.size() == 1 -> {}
|
|
||||||
ASSIGNMENT_OPERATIONS.any { it.value == name } -> {}
|
|
||||||
name.asString().matches(COMPONENT_REGEX) -> {}
|
|
||||||
else -> diagnosticHolder.report(Errors.INAPPLICABLE_OPERATOR_MODIFIER.on(modifier))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ import org.jetbrains.kotlin.types.TypeSubstitutor;
|
|||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
import org.jetbrains.kotlin.util.PerformanceCounter;
|
import org.jetbrains.kotlin.util.PerformanceCounter;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -183,7 +183,7 @@ public class CallResolver {
|
|||||||
@NotNull TracingStrategy tracing
|
@NotNull TracingStrategy tracing
|
||||||
) {
|
) {
|
||||||
return computeTasksAndResolveCall(
|
return computeTasksAndResolveCall(
|
||||||
context, OperatorConventions.INVOKE, tracing,
|
context, OperatorNameConventions.INVOKE, tracing,
|
||||||
CallableDescriptorCollectors.FUNCTIONS, CallTransformer.FUNCTION_CALL_TRANSFORMER);
|
CallableDescriptorCollectors.FUNCTIONS, CallTransformer.FUNCTION_CALL_TRANSFORMER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall;
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
import org.jetbrains.kotlin.types.JetType;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -277,7 +277,8 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
|
|||||||
this.explicitExtensionReceiver = explicitExtensionReceiver;
|
this.explicitExtensionReceiver = explicitExtensionReceiver;
|
||||||
this.calleeExpressionAsDispatchReceiver = calleeExpressionAsDispatchReceiver;
|
this.calleeExpressionAsDispatchReceiver = calleeExpressionAsDispatchReceiver;
|
||||||
this.fakeInvokeExpression =
|
this.fakeInvokeExpression =
|
||||||
(JetSimpleNameExpression) JetPsiFactory(call.getCallElement()).createExpression(OperatorConventions.INVOKE.asString());
|
(JetSimpleNameExpression) JetPsiFactory(call.getCallElement())
|
||||||
|
.createExpression(OperatorNameConventions.INVOKE.asString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
+2
-2
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.inline.InlineUtil;
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -228,7 +228,7 @@ class InlineChecker implements CallChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||||
boolean isInvoke = descriptor.getName().equals(OperatorConventions.INVOKE) &&
|
boolean isInvoke = descriptor.getName().equals(OperatorNameConventions.INVOKE) &&
|
||||||
containingDeclaration instanceof ClassDescriptor &&
|
containingDeclaration instanceof ClassDescriptor &&
|
||||||
KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(((ClassDescriptor) containingDeclaration).getDefaultType());
|
KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(((ClassDescriptor) containingDeclaration).getDefaultType());
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.collectAllFromMeAndParent
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.utils.getLocalVariable
|
import org.jetbrains.kotlin.resolve.scopes.utils.getLocalVariable
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils
|
import org.jetbrains.kotlin.types.ErrorUtils
|
||||||
import org.jetbrains.kotlin.types.JetType
|
import org.jetbrains.kotlin.types.JetType
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
||||||
|
|
||||||
public interface CallableDescriptorCollector<D : CallableDescriptor> {
|
public interface CallableDescriptorCollector<D : CallableDescriptor> {
|
||||||
@@ -97,7 +97,7 @@ private object FunctionCollector : CallableDescriptorCollector<FunctionDescripto
|
|||||||
val members = receiverScope.getFunctions(name, location)
|
val members = receiverScope.getFunctions(name, location)
|
||||||
val constructors = getConstructors(receiverScope, name, location, { !isStaticNestedClass(it) })
|
val constructors = getConstructors(receiverScope, name, location, { !isStaticNestedClass(it) })
|
||||||
|
|
||||||
if (name == OperatorConventions.INVOKE && KotlinBuiltIns.isExtensionFunctionType(receiver)) {
|
if (name == OperatorNameConventions.INVOKE && KotlinBuiltIns.isExtensionFunctionType(receiver)) {
|
||||||
// If we're looking for members of an extension function type, we ignore the non-extension "invoke"s
|
// If we're looking for members of an extension function type, we ignore the non-extension "invoke"s
|
||||||
// that originate from the Function{n} class and only consider the synthesized "invoke" extensions.
|
// that originate from the Function{n} class and only consider the synthesized "invoke" extensions.
|
||||||
// Otherwise confusing errors will be reported because the non-extension here beats the extension
|
// Otherwise confusing errors will be reported because the non-extension here beats the extension
|
||||||
@@ -119,7 +119,7 @@ private object FunctionCollector : CallableDescriptorCollector<FunctionDescripto
|
|||||||
val (extensions, nonExtensions) = functions.partition { it.extensionReceiverParameter != null }
|
val (extensions, nonExtensions) = functions.partition { it.extensionReceiverParameter != null }
|
||||||
val syntheticExtensions = scope.getSyntheticExtensionFunctions(receiverTypes, name, location)
|
val syntheticExtensions = scope.getSyntheticExtensionFunctions(receiverTypes, name, location)
|
||||||
|
|
||||||
if (name == OperatorConventions.INVOKE) {
|
if (name == OperatorNameConventions.INVOKE) {
|
||||||
// Create synthesized "invoke" extensions for each non-extension "invoke" found in the scope
|
// Create synthesized "invoke" extensions for each non-extension "invoke" found in the scope
|
||||||
return extensions + createSynthesizedInvokes(nonExtensions) + syntheticExtensions
|
return extensions + createSynthesizedInvokes(nonExtensions) + syntheticExtensions
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,9 +131,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
|
|||||||
createValueParameters(functionDescriptor, call),
|
createValueParameters(functionDescriptor, call),
|
||||||
dynamicType,
|
dynamicType,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
Visibilities.PUBLIC,
|
Visibilities.PUBLIC
|
||||||
false,
|
|
||||||
false
|
|
||||||
)
|
)
|
||||||
return functionDescriptor
|
return functionDescriptor
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
|||||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|
||||||
fun createSynthesizedInvokes(functions: Collection<FunctionDescriptor>): Collection<FunctionDescriptor> {
|
fun createSynthesizedInvokes(functions: Collection<FunctionDescriptor>): Collection<FunctionDescriptor> {
|
||||||
@@ -80,16 +80,16 @@ private fun createSynthesizedFunctionWithFirstParameterAsReceiver(descriptor: Fu
|
|||||||
},
|
},
|
||||||
original.getReturnType(),
|
original.getReturnType(),
|
||||||
original.getModality(),
|
original.getModality(),
|
||||||
original.getVisibility(),
|
original.getVisibility()
|
||||||
original.isOperator,
|
|
||||||
original.isInfix
|
|
||||||
)
|
)
|
||||||
|
result.isOperator = original.isOperator
|
||||||
|
result.isInfix = original.isInfix
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isSynthesizedInvoke(descriptor: DeclarationDescriptor): Boolean {
|
fun isSynthesizedInvoke(descriptor: DeclarationDescriptor): Boolean {
|
||||||
if (descriptor.getName() != OperatorConventions.INVOKE || descriptor !is FunctionDescriptor) return false
|
if (descriptor.getName() != OperatorNameConventions.INVOKE || descriptor !is FunctionDescriptor) return false
|
||||||
|
|
||||||
var real: FunctionDescriptor = descriptor
|
var real: FunctionDescriptor = descriptor
|
||||||
while (!real.getKind().isReal()) {
|
while (!real.getKind().isReal()) {
|
||||||
|
|||||||
+5
-4
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.types.JetType
|
|||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import java.math.BigInteger
|
import java.math.BigInteger
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -425,8 +426,8 @@ private class ConstantExpressionEvaluatorVisitor(
|
|||||||
val usesNonConstValAsConstant = usesNonConstValAsConstant(argumentForReceiver.expression) || usesNonConstValAsConstant(argumentForParameter.expression)
|
val usesNonConstValAsConstant = usesNonConstValAsConstant(argumentForReceiver.expression) || usesNonConstValAsConstant(argumentForParameter.expression)
|
||||||
val parameters = CompileTimeConstant.Parameters(canBeUsedInAnnotation, areArgumentsPure, usesVariableAsConstant, usesNonConstValAsConstant)
|
val parameters = CompileTimeConstant.Parameters(canBeUsedInAnnotation, areArgumentsPure, usesVariableAsConstant, usesNonConstValAsConstant)
|
||||||
return when (resultingDescriptorName) {
|
return when (resultingDescriptorName) {
|
||||||
OperatorConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression, factory)?.wrap(parameters)
|
OperatorNameConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression, factory)?.wrap(parameters)
|
||||||
OperatorConventions.EQUALS -> createCompileTimeConstantForEquals(result, callExpression, factory)?.wrap(parameters)
|
OperatorNameConventions.EQUALS -> createCompileTimeConstantForEquals(result, callExpression, factory)?.wrap(parameters)
|
||||||
else -> {
|
else -> {
|
||||||
createConstant(result, expectedType, parameters)
|
createConstant(result, expectedType, parameters)
|
||||||
}
|
}
|
||||||
@@ -796,7 +797,7 @@ private fun createCompileTimeConstantForEquals(result: Any?, operationReference:
|
|||||||
JetTokens.EQEQ -> result
|
JetTokens.EQEQ -> result
|
||||||
JetTokens.EXCLEQ -> !result
|
JetTokens.EXCLEQ -> !result
|
||||||
JetTokens.IDENTIFIER -> {
|
JetTokens.IDENTIFIER -> {
|
||||||
assert(operationReference.getReferencedNameAsName() == OperatorConventions.EQUALS) { "This method should be called only for equals operations" }
|
assert(operationReference.getReferencedNameAsName() == OperatorNameConventions.EQUALS) { "This method should be called only for equals operations" }
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
else -> throw IllegalStateException("Unknown equals operation token: $operationToken ${operationReference.getText()}")
|
else -> throw IllegalStateException("Unknown equals operation token: $operationToken ${operationReference.getText()}")
|
||||||
@@ -816,7 +817,7 @@ private fun createCompileTimeConstantForCompareTo(result: Any?, operationReferen
|
|||||||
JetTokens.GT -> factory.createBooleanValue(result > 0)
|
JetTokens.GT -> factory.createBooleanValue(result > 0)
|
||||||
JetTokens.GTEQ -> factory.createBooleanValue(result >= 0)
|
JetTokens.GTEQ -> factory.createBooleanValue(result >= 0)
|
||||||
JetTokens.IDENTIFIER -> {
|
JetTokens.IDENTIFIER -> {
|
||||||
assert(operationReference.getReferencedNameAsName() == OperatorConventions.COMPARE_TO) { "This method should be called only for compareTo operations" }
|
assert(operationReference.getReferencedNameAsName() == OperatorNameConventions.COMPARE_TO) { "This method should be called only for compareTo operations" }
|
||||||
return factory.createIntValue(result)
|
return factory.createIntValue(result)
|
||||||
}
|
}
|
||||||
else -> throw IllegalStateException("Unknown compareTo operation token: $operationToken")
|
else -> throw IllegalStateException("Unknown compareTo operation token: $operationToken")
|
||||||
|
|||||||
+6
-5
@@ -64,6 +64,7 @@ import org.jetbrains.kotlin.types.*;
|
|||||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
|
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryPackage;
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryPackage;
|
||||||
import org.jetbrains.kotlin.types.expressions.unqualifiedSuper.UnqualifiedSuperPackage;
|
import org.jetbrains.kotlin.types.expressions.unqualifiedSuper.UnqualifiedSuperPackage;
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -1066,7 +1067,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
Collections.singletonList(right)
|
Collections.singletonList(right)
|
||||||
);
|
);
|
||||||
OverloadResolutionResults<FunctionDescriptor> resolutionResults =
|
OverloadResolutionResults<FunctionDescriptor> resolutionResults =
|
||||||
components.callResolver.resolveCallWithGivenName(newContext, call, operationSign, OperatorConventions.EQUALS);
|
components.callResolver.resolveCallWithGivenName(newContext, call, operationSign, OperatorNameConventions.EQUALS);
|
||||||
|
|
||||||
traceInterpretingRightAsNullableAny.commit(new TraceEntryFilter() {
|
traceInterpretingRightAsNullableAny.commit(new TraceEntryFilter() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1085,7 +1086,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
|
|
||||||
if (resolutionResults.isSuccess()) {
|
if (resolutionResults.isSuccess()) {
|
||||||
FunctionDescriptor equals = resolutionResults.getResultingCall().getResultingDescriptor();
|
FunctionDescriptor equals = resolutionResults.getResultingCall().getResultingDescriptor();
|
||||||
if (ensureBooleanResult(operationSign, OperatorConventions.EQUALS, equals.getReturnType(),
|
if (ensureBooleanResult(operationSign, OperatorNameConventions.EQUALS, equals.getReturnType(),
|
||||||
context)) {
|
context)) {
|
||||||
ensureNonemptyIntersectionOfOperandTypes(expression, context);
|
ensureNonemptyIntersectionOfOperandTypes(expression, context);
|
||||||
}
|
}
|
||||||
@@ -1107,7 +1108,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
@NotNull ExpressionTypingContext context,
|
@NotNull ExpressionTypingContext context,
|
||||||
@NotNull JetSimpleNameExpression operationSign
|
@NotNull JetSimpleNameExpression operationSign
|
||||||
) {
|
) {
|
||||||
JetTypeInfo typeInfo = getTypeInfoForBinaryCall(OperatorConventions.COMPARE_TO, context, expression);
|
JetTypeInfo typeInfo = getTypeInfoForBinaryCall(OperatorNameConventions.COMPARE_TO, context, expression);
|
||||||
JetType compareToReturnType = typeInfo.getType();
|
JetType compareToReturnType = typeInfo.getType();
|
||||||
JetType type = null;
|
JetType type = null;
|
||||||
if (compareToReturnType != null && !compareToReturnType.isError()) {
|
if (compareToReturnType != null && !compareToReturnType.isError()) {
|
||||||
@@ -1237,9 +1238,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
contextWithDataFlow,
|
contextWithDataFlow,
|
||||||
CallMaker.makeCall(callElement, receiver, null, operationSign, Collections.singletonList(leftArgument)),
|
CallMaker.makeCall(callElement, receiver, null, operationSign, Collections.singletonList(leftArgument)),
|
||||||
operationSign,
|
operationSign,
|
||||||
OperatorConventions.CONTAINS);
|
OperatorNameConventions.CONTAINS);
|
||||||
JetType containsType = OverloadResolutionResultsUtil.getResultingType(resolutionResult, context.contextDependency);
|
JetType containsType = OverloadResolutionResultsUtil.getResultingType(resolutionResult, context.contextDependency);
|
||||||
ensureBooleanResult(operationSign, OperatorConventions.CONTAINS, containsType, context);
|
ensureBooleanResult(operationSign, OperatorNameConventions.CONTAINS, containsType, context);
|
||||||
|
|
||||||
if (left != null) {
|
if (left != null) {
|
||||||
dataFlowInfo = facade.getTypeInfo(left, contextWithDataFlow).getDataFlowInfo().and(dataFlowInfo);
|
dataFlowInfo = facade.getTypeInfo(left, contextWithDataFlow).getDataFlowInfo().and(dataFlowInfo);
|
||||||
|
|||||||
+1
-3
@@ -129,9 +129,7 @@ public class ControlStructureTypingUtils {
|
|||||||
valueParameters,
|
valueParameters,
|
||||||
type,
|
type,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
Visibilities.PUBLIC,
|
Visibilities.PUBLIC
|
||||||
false,
|
|
||||||
false
|
|
||||||
);
|
);
|
||||||
return function;
|
return function;
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-31
@@ -18,28 +18,16 @@ package org.jetbrains.kotlin.types.expressions;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableBiMap;
|
import com.google.common.collect.ImmutableBiMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import kotlin.text.Regex;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.lexer.JetSingleValueToken;
|
import org.jetbrains.kotlin.lexer.JetSingleValueToken;
|
||||||
import org.jetbrains.kotlin.lexer.JetToken;
|
import org.jetbrains.kotlin.lexer.JetToken;
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
|
import static org.jetbrains.kotlin.util.OperatorNameConventions.*;
|
||||||
|
|
||||||
public class OperatorConventions {
|
public class OperatorConventions {
|
||||||
|
|
||||||
public static final Name EQUALS = Name.identifier("equals");
|
|
||||||
public static final Name IDENTITY_EQUALS = Name.identifier("identityEquals");
|
|
||||||
public static final Name COMPARE_TO = Name.identifier("compareTo");
|
|
||||||
public static final Name CONTAINS = Name.identifier("contains");
|
|
||||||
public static final Name INVOKE = Name.identifier("invoke");
|
|
||||||
public static final Name ITERATOR = Name.identifier("iterator");
|
|
||||||
public static final Name GET = Name.identifier("get");
|
|
||||||
public static final Name SET = Name.identifier("set");
|
|
||||||
public static final Name NEXT = Name.identifier("next");
|
|
||||||
public static final Name HAS_NEXT = Name.identifier("hasNext");
|
|
||||||
public static final Regex COMPONENT_REGEX = new Regex("component\\d+");
|
|
||||||
|
|
||||||
private OperatorConventions() {}
|
private OperatorConventions() {}
|
||||||
|
|
||||||
// Names for primitive type conversion properties
|
// Names for primitive type conversion properties
|
||||||
@@ -56,21 +44,23 @@ public class OperatorConventions {
|
|||||||
DOUBLE, FLOAT, LONG, INT, SHORT, BYTE, CHAR
|
DOUBLE, FLOAT, LONG, INT, SHORT, BYTE, CHAR
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// If you add new unary, binary or assignment operators, add it to OperatorConventionNames as well
|
||||||
|
|
||||||
public static final ImmutableBiMap<JetSingleValueToken, Name> UNARY_OPERATION_NAMES = ImmutableBiMap.<JetSingleValueToken, Name>builder()
|
public static final ImmutableBiMap<JetSingleValueToken, Name> UNARY_OPERATION_NAMES = ImmutableBiMap.<JetSingleValueToken, Name>builder()
|
||||||
.put(JetTokens.PLUSPLUS, Name.identifier("inc"))
|
.put(JetTokens.PLUSPLUS, INC)
|
||||||
.put(JetTokens.MINUSMINUS, Name.identifier("dec"))
|
.put(JetTokens.MINUSMINUS, DEC)
|
||||||
.put(JetTokens.PLUS, Name.identifier("plus"))
|
.put(JetTokens.PLUS, PLUS)
|
||||||
.put(JetTokens.MINUS, Name.identifier("minus"))
|
.put(JetTokens.MINUS, MINUS)
|
||||||
.put(JetTokens.EXCL, Name.identifier("not"))
|
.put(JetTokens.EXCL, NOT)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static final ImmutableBiMap<JetSingleValueToken, Name> BINARY_OPERATION_NAMES = ImmutableBiMap.<JetSingleValueToken, Name>builder()
|
public static final ImmutableBiMap<JetSingleValueToken, Name> BINARY_OPERATION_NAMES = ImmutableBiMap.<JetSingleValueToken, Name>builder()
|
||||||
.put(JetTokens.MUL, Name.identifier("times"))
|
.put(JetTokens.MUL, TIMES)
|
||||||
.put(JetTokens.PLUS, Name.identifier("plus"))
|
.put(JetTokens.PLUS, PLUS)
|
||||||
.put(JetTokens.MINUS, Name.identifier("minus"))
|
.put(JetTokens.MINUS, MINUS)
|
||||||
.put(JetTokens.DIV, Name.identifier("div"))
|
.put(JetTokens.DIV, DIV)
|
||||||
.put(JetTokens.PERC, Name.identifier("mod"))
|
.put(JetTokens.PERC, MOD)
|
||||||
.put(JetTokens.RANGE, Name.identifier("rangeTo"))
|
.put(JetTokens.RANGE, RANGE_TO)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static final ImmutableSet<JetSingleValueToken> NOT_OVERLOADABLE =
|
public static final ImmutableSet<JetSingleValueToken> NOT_OVERLOADABLE =
|
||||||
@@ -92,11 +82,11 @@ public class OperatorConventions {
|
|||||||
ImmutableSet.<JetSingleValueToken>of(JetTokens.IN_KEYWORD, JetTokens.NOT_IN);
|
ImmutableSet.<JetSingleValueToken>of(JetTokens.IN_KEYWORD, JetTokens.NOT_IN);
|
||||||
|
|
||||||
public static final ImmutableBiMap<JetSingleValueToken, Name> ASSIGNMENT_OPERATIONS = ImmutableBiMap.<JetSingleValueToken, Name>builder()
|
public static final ImmutableBiMap<JetSingleValueToken, Name> ASSIGNMENT_OPERATIONS = ImmutableBiMap.<JetSingleValueToken, Name>builder()
|
||||||
.put(JetTokens.MULTEQ, Name.identifier("timesAssign"))
|
.put(JetTokens.MULTEQ, TIMES_ASSIGN)
|
||||||
.put(JetTokens.DIVEQ, Name.identifier("divAssign"))
|
.put(JetTokens.DIVEQ, DIV_ASSIGN)
|
||||||
.put(JetTokens.PERCEQ, Name.identifier("modAssign"))
|
.put(JetTokens.PERCEQ, MOD_ASSIGN)
|
||||||
.put(JetTokens.PLUSEQ, Name.identifier("plusAssign"))
|
.put(JetTokens.PLUSEQ, PLUS_ASSIGN)
|
||||||
.put(JetTokens.MINUSEQ, Name.identifier("minusAssign"))
|
.put(JetTokens.MINUSEQ, MINUS_ASSIGN)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static final ImmutableBiMap<JetSingleValueToken, JetSingleValueToken> ASSIGNMENT_OPERATION_COUNTERPARTS = ImmutableBiMap.<JetSingleValueToken, JetSingleValueToken>builder()
|
public static final ImmutableBiMap<JetSingleValueToken, JetSingleValueToken> ASSIGNMENT_OPERATION_COUNTERPARTS = ImmutableBiMap.<JetSingleValueToken, JetSingleValueToken>builder()
|
||||||
@@ -108,8 +98,8 @@ public class OperatorConventions {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static final ImmutableBiMap<JetSingleValueToken, Name> BOOLEAN_OPERATIONS = ImmutableBiMap.<JetSingleValueToken, Name>builder()
|
public static final ImmutableBiMap<JetSingleValueToken, Name> BOOLEAN_OPERATIONS = ImmutableBiMap.<JetSingleValueToken, Name>builder()
|
||||||
.put(JetTokens.ANDAND, Name.identifier("and"))
|
.put(JetTokens.ANDAND, AND)
|
||||||
.put(JetTokens.OROR, Name.identifier("or"))
|
.put(JetTokens.OROR, OR)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static final ImmutableSet<Name> CONVENTION_NAMES = ImmutableSet.<Name>builder()
|
public static final ImmutableSet<Name> CONVENTION_NAMES = ImmutableSet.<Name>builder()
|
||||||
|
|||||||
Vendored
+2
-2
@@ -12,9 +12,9 @@ public open class J {
|
|||||||
|
|
||||||
public interface DP {
|
public interface DP {
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public abstract fun get(/*0*/ a: kotlin.Any!, /*1*/ b: kotlin.Any!): kotlin.String!
|
public abstract operator fun get(/*0*/ a: kotlin.Any!, /*1*/ b: kotlin.Any!): kotlin.String!
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public abstract fun set(/*0*/ a: kotlin.Any!, /*1*/ b: kotlin.Any!, /*2*/ c: kotlin.Any!): kotlin.String!
|
public abstract operator fun set(/*0*/ a: kotlin.Any!, /*1*/ b: kotlin.Any!, /*2*/ c: kotlin.Any!): kotlin.String!
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -17,7 +17,7 @@ public class J {
|
|||||||
// FILE: k.kt
|
// FILE: k.kt
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
J.<!OPERATOR_MODIFIER_REQUIRED!>staticNN()<!>
|
J.staticNN()
|
||||||
J.<!OPERATOR_MODIFIER_REQUIRED!><!UNSAFE_CALL!>staticN<!>()<!>
|
J.<!UNSAFE_CALL!>staticN<!>()
|
||||||
J.<!OPERATOR_MODIFIER_REQUIRED!>staticJ()<!>
|
J.staticJ()
|
||||||
}
|
}
|
||||||
+1
-1
@@ -11,7 +11,7 @@ public open class J {
|
|||||||
public interface Invoke {
|
public interface Invoke {
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public abstract fun invoke(): kotlin.Unit
|
public abstract operator fun invoke(): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@ fun test() {
|
|||||||
// platform type with no annotation
|
// platform type with no annotation
|
||||||
val platformJ = J.staticJ
|
val platformJ = J.staticJ
|
||||||
|
|
||||||
val (<!OPERATOR_MODIFIER_REQUIRED!>a1<!>, <!OPERATOR_MODIFIER_REQUIRED!>b1<!>) = platformNN
|
val (a1, b1) = platformNN
|
||||||
val (a2, b2) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>platformN<!>
|
val (a2, b2) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>platformN<!>
|
||||||
val (<!OPERATOR_MODIFIER_REQUIRED!>a3<!>, <!OPERATOR_MODIFIER_REQUIRED!>b3<!>) = platformJ
|
val (a3, b3) = platformJ
|
||||||
}
|
}
|
||||||
+2
-2
@@ -9,8 +9,8 @@ public open class J {
|
|||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
public interface Multi {
|
public interface Multi {
|
||||||
public abstract fun component1(): kotlin.String!
|
public abstract operator fun component1(): kotlin.String!
|
||||||
public abstract fun component2(): kotlin.String!
|
public abstract operator fun component2(): kotlin.String!
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ public open class J {
|
|||||||
@org.jetbrains.annotations.NotNull() public final var nn: J
|
@org.jetbrains.annotations.NotNull() public final var nn: J
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open fun set(/*0*/ @org.jetbrains.annotations.NotNull() nn: J, /*1*/ @org.jetbrains.annotations.Nullable() n: J?, /*2*/ j: J!): kotlin.Unit
|
public open operator fun set(/*0*/ @org.jetbrains.annotations.NotNull() nn: J, /*1*/ @org.jetbrains.annotations.Nullable() n: J?, /*2*/ j: J!): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
// Static members
|
// Static members
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ public open class InnerClassesInGeneric</*0*/ P : kotlin.Any!, /*1*/ Q : kotlin.
|
|||||||
|
|
||||||
public open inner class Inner2 : test.InnerClassesInGeneric.Inner {
|
public open inner class Inner2 : test.InnerClassesInGeneric.Inner {
|
||||||
public constructor Inner2()
|
public constructor Inner2()
|
||||||
public open fun iterator(): kotlin.(Mutable)Iterator<P!>!
|
public open operator fun iterator(): kotlin.(Mutable)Iterator<P!>!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ public open class InnerOfGeneric {
|
|||||||
|
|
||||||
public open inner class S</*0*/ E : kotlin.Any!> {
|
public open inner class S</*0*/ E : kotlin.Any!> {
|
||||||
public constructor S</*0*/ E : kotlin.Any!>()
|
public constructor S</*0*/ E : kotlin.Any!>()
|
||||||
public open fun iterator(): kotlin.(Mutable)Iterator<E!>!
|
public open operator fun iterator(): kotlin.(Mutable)Iterator<E!>!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -16,7 +16,7 @@ public interface ReturnInnerSubclassOfSupersInner {
|
|||||||
|
|
||||||
public/*package*/ open inner class Inner {
|
public/*package*/ open inner class Inner {
|
||||||
public/*package*/ constructor Inner()
|
public/*package*/ constructor Inner()
|
||||||
public/*package*/ open fun get(): test.ReturnInnerSubclassOfSupersInner.Super<A!>!
|
public/*package*/ open operator fun get(): test.ReturnInnerSubclassOfSupersInner.Super<A!>!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public interface ReturnInnerSubclassOfSupersInner {
|
|||||||
|
|
||||||
public/*package*/ open inner class Inner {
|
public/*package*/ open inner class Inner {
|
||||||
public/*package*/ constructor Inner()
|
public/*package*/ constructor Inner()
|
||||||
public/*package*/ open fun get(): test.ReturnInnerSubclassOfSupersInner.Super<A!>!
|
public/*package*/ open operator fun get(): test.ReturnInnerSubclassOfSupersInner.Super<A!>!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -109,9 +109,7 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
|
|||||||
DescriptorsPackage.createEnhancedValueParameters(enhancedValueParametersTypes, getValueParameters(), enhanced),
|
DescriptorsPackage.createEnhancedValueParameters(enhancedValueParametersTypes, getValueParameters(), enhanced),
|
||||||
enhancedReturnType,
|
enhancedReturnType,
|
||||||
getModality(),
|
getModality(),
|
||||||
getVisibility(),
|
getVisibility()
|
||||||
false,
|
|
||||||
false
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return enhanced;
|
return enhanced;
|
||||||
|
|||||||
+20
-1
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
|||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
import org.jetbrains.kotlin.types.JetType;
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -73,6 +74,24 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
|||||||
return new JavaMethodDescriptor(containingDeclaration, null, annotations, name, Kind.DECLARATION, source);
|
return new JavaMethodDescriptor(containingDeclaration, null, annotations, name, Kind.DECLARATION, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public SimpleFunctionDescriptorImpl initialize(
|
||||||
|
@Nullable JetType receiverParameterType,
|
||||||
|
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||||
|
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||||
|
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||||
|
@Nullable JetType unsubstitutedReturnType,
|
||||||
|
@Nullable Modality modality,
|
||||||
|
@NotNull Visibility visibility
|
||||||
|
) {
|
||||||
|
SimpleFunctionDescriptorImpl descriptor = super.initialize(
|
||||||
|
receiverParameterType, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
|
||||||
|
unsubstitutedReturnType, modality, visibility);
|
||||||
|
setOperator(OperatorNameConventions.INSTANCE$.canBeOperator(descriptor));
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasStableParameterNames() {
|
public boolean hasStableParameterNames() {
|
||||||
assert parameterNamesStatus != null : "Parameter names status was not set: " + this;
|
assert parameterNamesStatus != null : "Parameter names status was not set: " + this;
|
||||||
@@ -122,7 +141,7 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
|||||||
// 1. creates full copy of descriptor
|
// 1. creates full copy of descriptor
|
||||||
// 2. copies method's type parameters (with new containing declaration) and properly substitute to them in value parameters, return type and etc.
|
// 2. copies method's type parameters (with new containing declaration) and properly substitute to them in value parameters, return type and etc.
|
||||||
JavaMethodDescriptor enhancedMethod = (JavaMethodDescriptor) doSubstitute(
|
JavaMethodDescriptor enhancedMethod = (JavaMethodDescriptor) doSubstitute(
|
||||||
TypeSubstitutor.EMPTY, getContainingDeclaration(), getModality(), getVisibility(), false, false, getOriginal(),
|
TypeSubstitutor.EMPTY, getContainingDeclaration(), getModality(), getVisibility(), isOperator(), isInfix(), getOriginal(),
|
||||||
/* copyOverrides = */ true, getKind(),
|
/* copyOverrides = */ true, getKind(),
|
||||||
enhancedValueParameters, enhancedReceiverType, enhancedReturnType
|
enhancedValueParameters, enhancedReceiverType, enhancedReturnType
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-3
@@ -131,9 +131,7 @@ public abstract class LazyJavaScope(
|
|||||||
effectiveSignature.getValueParameters(),
|
effectiveSignature.getValueParameters(),
|
||||||
effectiveSignature.getReturnType(),
|
effectiveSignature.getReturnType(),
|
||||||
Modality.convertFromFlags(method.isAbstract(), !method.isFinal()),
|
Modality.convertFromFlags(method.isAbstract(), !method.isFinal()),
|
||||||
method.getVisibility(),
|
method.getVisibility()
|
||||||
false,
|
|
||||||
false
|
|
||||||
)
|
)
|
||||||
|
|
||||||
functionDescriptorImpl.setParameterNamesStatus(effectiveSignature.hasStableParameterNames(), valueParameters.hasSynthesizedNames)
|
functionDescriptorImpl.setParameterNamesStatus(effectiveSignature.hasStableParameterNames(), valueParameters.hasSynthesizedNames)
|
||||||
|
|||||||
+2
-3
@@ -60,10 +60,9 @@ public class FunctionInvokeDescriptor private constructor(
|
|||||||
.map { createValueParameter(result, it.index, it.value) },
|
.map { createValueParameter(result, it.index, it.value) },
|
||||||
typeParameters.last().getDefaultType(),
|
typeParameters.last().getDefaultType(),
|
||||||
Modality.ABSTRACT,
|
Modality.ABSTRACT,
|
||||||
Visibilities.PUBLIC,
|
Visibilities.PUBLIC
|
||||||
true,
|
|
||||||
false
|
|
||||||
)
|
)
|
||||||
|
result.isOperator = true
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
|||||||
@NotNull Visibility visibility
|
@NotNull Visibility visibility
|
||||||
) {
|
) {
|
||||||
super.initialize(null, calculateDispatchReceiverParameter(), typeParameters, unsubstitutedValueParameters, null,
|
super.initialize(null, calculateDispatchReceiverParameter(), typeParameters, unsubstitutedValueParameters, null,
|
||||||
Modality.FINAL, visibility, false, false);
|
Modality.FINAL, visibility);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-10
@@ -42,8 +42,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
private ReceiverParameterDescriptor dispatchReceiverParameter;
|
private ReceiverParameterDescriptor dispatchReceiverParameter;
|
||||||
private Modality modality;
|
private Modality modality;
|
||||||
private Visibility visibility = Visibilities.UNKNOWN;
|
private Visibility visibility = Visibilities.UNKNOWN;
|
||||||
private boolean isOperator;
|
private boolean isOperator = false;
|
||||||
private boolean isInfix;
|
private boolean isInfix = false;
|
||||||
private final Set<FunctionDescriptor> overriddenFunctions = SmartSet.create();
|
private final Set<FunctionDescriptor> overriddenFunctions = SmartSet.create();
|
||||||
private final FunctionDescriptor original;
|
private final FunctionDescriptor original;
|
||||||
private final Kind kind;
|
private final Kind kind;
|
||||||
@@ -69,17 +69,13 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||||
@Nullable JetType unsubstitutedReturnType,
|
@Nullable JetType unsubstitutedReturnType,
|
||||||
@Nullable Modality modality,
|
@Nullable Modality modality,
|
||||||
@NotNull Visibility visibility,
|
@NotNull Visibility visibility
|
||||||
boolean isOperator,
|
|
||||||
boolean isInfix
|
|
||||||
) {
|
) {
|
||||||
this.typeParameters = UtilsPackage.toReadOnlyList(typeParameters);
|
this.typeParameters = UtilsPackage.toReadOnlyList(typeParameters);
|
||||||
this.unsubstitutedValueParameters = unsubstitutedValueParameters;
|
this.unsubstitutedValueParameters = unsubstitutedValueParameters;
|
||||||
this.unsubstitutedReturnType = unsubstitutedReturnType;
|
this.unsubstitutedReturnType = unsubstitutedReturnType;
|
||||||
this.modality = modality;
|
this.modality = modality;
|
||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
this.isOperator = isOperator;
|
|
||||||
this.isInfix = isInfix;
|
|
||||||
this.extensionReceiverParameter = DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverParameterType);
|
this.extensionReceiverParameter = DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverParameterType);
|
||||||
this.dispatchReceiverParameter = dispatchReceiverParameter;
|
this.dispatchReceiverParameter = dispatchReceiverParameter;
|
||||||
|
|
||||||
@@ -106,6 +102,14 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOperator(boolean isOperator) {
|
||||||
|
this.isOperator = isOperator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInfix(boolean isInfix) {
|
||||||
|
this.isInfix = isInfix;
|
||||||
|
}
|
||||||
|
|
||||||
public void setReturnType(@NotNull JetType unsubstitutedReturnType) {
|
public void setReturnType(@NotNull JetType unsubstitutedReturnType) {
|
||||||
if (this.unsubstitutedReturnType != null) {
|
if (this.unsubstitutedReturnType != null) {
|
||||||
// TODO: uncomment and fix tests
|
// TODO: uncomment and fix tests
|
||||||
@@ -309,10 +313,10 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
substitutedValueParameters,
|
substitutedValueParameters,
|
||||||
substitutedReturnType,
|
substitutedReturnType,
|
||||||
newModality,
|
newModality,
|
||||||
newVisibility,
|
newVisibility
|
||||||
isOperator,
|
|
||||||
isInfix
|
|
||||||
);
|
);
|
||||||
|
substitutedDescriptor.setOperator(isOperator);
|
||||||
|
substitutedDescriptor.setInfix(isInfix);
|
||||||
|
|
||||||
if (copyOverrides) {
|
if (copyOverrides) {
|
||||||
for (FunctionDescriptor overriddenFunction : overriddenFunctions) {
|
for (FunctionDescriptor overriddenFunction : overriddenFunctions) {
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ public class ScriptCodeDescriptor extends FunctionDescriptorImpl {
|
|||||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||||
@NotNull JetType returnType) {
|
@NotNull JetType returnType) {
|
||||||
super.initialize(null, dispatchReceiverParameter, Collections.<TypeParameterDescriptor>emptyList(), valueParameters, returnType,
|
super.initialize(null, dispatchReceiverParameter, Collections.<TypeParameterDescriptor>emptyList(), valueParameters, returnType,
|
||||||
Modality.FINAL, Visibilities.INTERNAL, false, false);
|
Modality.FINAL, Visibilities.INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+2
-4
@@ -58,12 +58,10 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
|||||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||||
@Nullable JetType unsubstitutedReturnType,
|
@Nullable JetType unsubstitutedReturnType,
|
||||||
@Nullable Modality modality,
|
@Nullable Modality modality,
|
||||||
@NotNull Visibility visibility,
|
@NotNull Visibility visibility
|
||||||
boolean isOperator,
|
|
||||||
boolean isInfix
|
|
||||||
) {
|
) {
|
||||||
super.initialize(receiverParameterType, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
|
super.initialize(receiverParameterType, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
|
||||||
unsubstitutedReturnType, modality, visibility, isOperator, isInfix);
|
unsubstitutedReturnType, modality, visibility);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class DescriptorFactory {
|
|||||||
return values.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
return values.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||||
Collections.<ValueParameterDescriptor>emptyList(),
|
Collections.<ValueParameterDescriptor>emptyList(),
|
||||||
getBuiltIns(enumClass).getArrayType(Variance.INVARIANT, enumClass.getDefaultType()),
|
getBuiltIns(enumClass).getArrayType(Variance.INVARIANT, enumClass.getDefaultType()),
|
||||||
Modality.FINAL, Visibilities.PUBLIC, false, false);
|
Modality.FINAL, Visibilities.PUBLIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -117,7 +117,7 @@ public class DescriptorFactory {
|
|||||||
);
|
);
|
||||||
return valueOf.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
return valueOf.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||||
Collections.singletonList(parameterDescriptor), enumClass.getDefaultType(),
|
Collections.singletonList(parameterDescriptor), enumClass.getDefaultType(),
|
||||||
Modality.FINAL, Visibilities.PUBLIC, false, false);
|
Modality.FINAL, Visibilities.PUBLIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -499,9 +499,7 @@ public class ErrorUtils {
|
|||||||
Collections.<ValueParameterDescriptor>emptyList(), // TODO
|
Collections.<ValueParameterDescriptor>emptyList(), // TODO
|
||||||
createErrorType("<ERROR FUNCTION RETURN TYPE>"),
|
createErrorType("<ERROR FUNCTION RETURN TYPE>"),
|
||||||
Modality.OPEN,
|
Modality.OPEN,
|
||||||
Visibilities.INTERNAL,
|
Visibilities.INTERNAL
|
||||||
false,
|
|
||||||
false
|
|
||||||
);
|
);
|
||||||
return function;
|
return function;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.util
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import kotlin.text.Regex
|
||||||
|
|
||||||
|
object OperatorNameConventions {
|
||||||
|
|
||||||
|
val EQUALS = Name.identifier("equals")
|
||||||
|
val IDENTITY_EQUALS = Name.identifier("identityEquals");
|
||||||
|
val COMPARE_TO = Name.identifier("compareTo")
|
||||||
|
val CONTAINS = Name.identifier("contains")
|
||||||
|
val INVOKE = Name.identifier("invoke")
|
||||||
|
val ITERATOR = Name.identifier("iterator")
|
||||||
|
val GET = Name.identifier("get")
|
||||||
|
val SET = Name.identifier("set")
|
||||||
|
val NEXT = Name.identifier("next")
|
||||||
|
val HAS_NEXT = Name.identifier("hasNext")
|
||||||
|
|
||||||
|
val COMPONENT_REGEX = Regex("component\\d+")
|
||||||
|
|
||||||
|
val AND = Name.identifier("and")
|
||||||
|
val OR = Name.identifier("or")
|
||||||
|
|
||||||
|
val INC = Name.identifier("inc")
|
||||||
|
val DEC = Name.identifier("dec")
|
||||||
|
val PLUS = Name.identifier("plus")
|
||||||
|
val MINUS = Name.identifier("minus")
|
||||||
|
val NOT = Name.identifier("not")
|
||||||
|
|
||||||
|
val TIMES = Name.identifier("times")
|
||||||
|
val DIV = Name.identifier("div")
|
||||||
|
val MOD = Name.identifier("mod")
|
||||||
|
val RANGE_TO = Name.identifier("rangeTo")
|
||||||
|
|
||||||
|
val TIMES_ASSIGN = Name.identifier("timesAssign")
|
||||||
|
val DIV_ASSIGN = Name.identifier("divAssign")
|
||||||
|
val MOD_ASSIGN = Name.identifier("modAssign")
|
||||||
|
val PLUS_ASSIGN = Name.identifier("plusAssign")
|
||||||
|
val MINUS_ASSIGN = Name.identifier("minusAssign")
|
||||||
|
|
||||||
|
// If you add new unary, binary or assignment operators, add it to OperatorConventions as well
|
||||||
|
|
||||||
|
private val UNARY_OPERATION_NAMES = setOf(INC, DEC, PLUS, MINUS, NOT)
|
||||||
|
private val BINARY_OPERATION_NAMES = setOf(TIMES, PLUS, MINUS, DIV, MOD, RANGE_TO)
|
||||||
|
private val ASSIGNMENT_OPERATIONS = setOf(TIMES_ASSIGN, DIV_ASSIGN, MOD_ASSIGN, PLUS_ASSIGN, MINUS_ASSIGN)
|
||||||
|
|
||||||
|
fun canBeOperator(functionDescriptor: FunctionDescriptor): Boolean {
|
||||||
|
val name = functionDescriptor.name
|
||||||
|
|
||||||
|
return when {
|
||||||
|
GET == name -> true
|
||||||
|
SET == name -> true
|
||||||
|
INVOKE == name -> true
|
||||||
|
CONTAINS == name -> true
|
||||||
|
ITERATOR == name -> true
|
||||||
|
NEXT == name -> true
|
||||||
|
HAS_NEXT == name -> true
|
||||||
|
EQUALS == name -> true
|
||||||
|
COMPARE_TO == name -> true
|
||||||
|
UNARY_OPERATION_NAMES.any { it == name } && functionDescriptor.valueParameters.isEmpty() -> true
|
||||||
|
BINARY_OPERATION_NAMES.any { it == name } && functionDescriptor.valueParameters.size() == 1 -> true
|
||||||
|
ASSIGNMENT_OPERATIONS.any { it == name } -> true
|
||||||
|
name.asString().matches(COMPONENT_REGEX) -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+3
-3
@@ -151,10 +151,10 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
local.memberDeserializer.valueParameters(proto, AnnotatedCallableKind.FUNCTION),
|
local.memberDeserializer.valueParameters(proto, AnnotatedCallableKind.FUNCTION),
|
||||||
local.typeDeserializer.type(proto.returnType),
|
local.typeDeserializer.type(proto.returnType),
|
||||||
Deserialization.modality(Flags.MODALITY.get(proto.flags)),
|
Deserialization.modality(Flags.MODALITY.get(proto.flags)),
|
||||||
Deserialization.visibility(Flags.VISIBILITY.get(proto.flags)),
|
Deserialization.visibility(Flags.VISIBILITY.get(proto.flags))
|
||||||
Flags.OLD_IS_OPERATOR.get(proto.flags),
|
|
||||||
Flags.OLD_IS_INFIX.get(proto.flags)
|
|
||||||
)
|
)
|
||||||
|
function.isOperator = Flags.OLD_IS_OPERATOR.get(proto.flags)
|
||||||
|
function.isInfix = Flags.OLD_IS_INFIX.get(proto.flags)
|
||||||
return function
|
return function
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector
|
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpression>(javaClass(), "Replace overloaded operator with function call") {
|
public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpression>(javaClass(), "Replace overloaded operator with function call") {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -72,9 +72,9 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpressi
|
|||||||
|
|
||||||
val resolvedCall = element.getResolvedCall(element.analyze())
|
val resolvedCall = element.getResolvedCall(element.analyze())
|
||||||
val descriptor = resolvedCall?.getResultingDescriptor()
|
val descriptor = resolvedCall?.getResultingDescriptor()
|
||||||
if (descriptor is FunctionDescriptor && descriptor.getName() == OperatorConventions.INVOKE) {
|
if (descriptor is FunctionDescriptor && descriptor.getName() == OperatorNameConventions.INVOKE) {
|
||||||
if (element.getParent() is JetDotQualifiedExpression &&
|
if (element.getParent() is JetDotQualifiedExpression &&
|
||||||
element.getCalleeExpression()?.getText() == OperatorConventions.INVOKE.asString()) return false
|
element.getCalleeExpression()?.getText() == OperatorNameConventions.INVOKE.asString()) return false
|
||||||
return element.getValueArgumentList() != null || element.getFunctionLiteralArguments().isNotEmpty()
|
return element.getValueArgumentList() != null || element.getFunctionLiteralArguments().isNotEmpty()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@@ -189,7 +189,7 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpressi
|
|||||||
val argumentString = arguments?.getText()?.removeSurrounding("(", ")")
|
val argumentString = arguments?.getText()?.removeSurrounding("(", ")")
|
||||||
val funcLitArgs = element.getFunctionLiteralArguments()
|
val funcLitArgs = element.getFunctionLiteralArguments()
|
||||||
val calleeText = callee.getText()
|
val calleeText = callee.getText()
|
||||||
val transformation = "$calleeText.${OperatorConventions.INVOKE.asString()}" +
|
val transformation = "$calleeText.${OperatorNameConventions.INVOKE.asString()}" +
|
||||||
(if (argumentString == null) "" else "($argumentString)")
|
(if (argumentString == null) "" else "($argumentString)")
|
||||||
val transformed = JetPsiFactory(element).createExpression(transformation)
|
val transformed = JetPsiFactory(element).createExpression(transformation)
|
||||||
funcLitArgs.forEach { transformed.add(it) }
|
funcLitArgs.forEach { transformed.add(it) }
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
import org.jetbrains.kotlin.resolve.DelegatedPropertyResolver
|
import org.jetbrains.kotlin.resolve.DelegatedPropertyResolver
|
||||||
import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike
|
import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions.*
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions.*
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
public val ALL_SEARCHABLE_OPERATIONS: ImmutableSet<JetToken> = ImmutableSet
|
public val ALL_SEARCHABLE_OPERATIONS: ImmutableSet<JetToken> = ImmutableSet
|
||||||
.builder<JetToken>()
|
.builder<JetToken>()
|
||||||
@@ -37,7 +38,7 @@ public val ALL_SEARCHABLE_OPERATIONS: ImmutableSet<JetToken> = ImmutableSet
|
|||||||
.add(JetTokens.BY_KEYWORD)
|
.add(JetTokens.BY_KEYWORD)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
public val INDEXING_OPERATION_NAMES = setOf(GET, SET)
|
public val INDEXING_OPERATION_NAMES = setOf(OperatorNameConventions.GET, OperatorNameConventions.SET)
|
||||||
|
|
||||||
public val IN_OPERATIONS_TO_SEARCH = setOf(JetTokens.IN_KEYWORD)
|
public val IN_OPERATIONS_TO_SEARCH = setOf(JetTokens.IN_KEYWORD)
|
||||||
|
|
||||||
@@ -45,11 +46,11 @@ public val COMPARISON_OPERATIONS_TO_SEARCH = setOf(JetTokens.LT, JetTokens.GT)
|
|||||||
|
|
||||||
public fun Name.getOperationSymbolsToSearch(): Set<JetToken> {
|
public fun Name.getOperationSymbolsToSearch(): Set<JetToken> {
|
||||||
when (this) {
|
when (this) {
|
||||||
COMPARE_TO -> return COMPARISON_OPERATIONS_TO_SEARCH
|
OperatorNameConventions.COMPARE_TO -> return COMPARISON_OPERATIONS_TO_SEARCH
|
||||||
EQUALS -> return EQUALS_OPERATIONS
|
OperatorNameConventions.EQUALS -> return EQUALS_OPERATIONS
|
||||||
IDENTITY_EQUALS -> return IDENTITY_EQUALS_OPERATIONS
|
OperatorNameConventions.IDENTITY_EQUALS -> return IDENTITY_EQUALS_OPERATIONS
|
||||||
CONTAINS -> return IN_OPERATIONS_TO_SEARCH
|
OperatorNameConventions.CONTAINS -> return IN_OPERATIONS_TO_SEARCH
|
||||||
ITERATOR -> return IN_OPERATIONS_TO_SEARCH
|
OperatorNameConventions.ITERATOR -> return IN_OPERATIONS_TO_SEARCH
|
||||||
in INDEXING_OPERATION_NAMES -> return setOf(JetTokens.LBRACKET, JetTokens.BY_KEYWORD)
|
in INDEXING_OPERATION_NAMES -> return setOf(JetTokens.LBRACKET, JetTokens.BY_KEYWORD)
|
||||||
DelegatedPropertyResolver.PROPERTY_DELEGATED_FUNCTION_NAME -> return setOf(JetTokens.BY_KEYWORD)
|
DelegatedPropertyResolver.PROPERTY_DELEGATED_FUNCTION_NAME -> return setOf(JetTokens.BY_KEYWORD)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import com.sun.jdi.Location
|
|||||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||||
import org.jetbrains.kotlin.psi.JetBlockExpression
|
import org.jetbrains.kotlin.psi.JetBlockExpression
|
||||||
import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression
|
import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
public class KotlinLambdaMethodFilter(
|
public class KotlinLambdaMethodFilter(
|
||||||
lambda: JetFunctionLiteralExpression,
|
lambda: JetFunctionLiteralExpression,
|
||||||
@@ -71,7 +71,7 @@ public class KotlinLambdaMethodFilter(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
public fun isLambdaName(name: String?): Boolean {
|
public fun isLambdaName(name: String?): Boolean {
|
||||||
return name == OperatorConventions.INVOKE.asString()
|
return name == OperatorNameConventions.INVOKE.asString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.idea.JetIcons
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.JetElement
|
import org.jetbrains.kotlin.psi.JetElement
|
||||||
import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression
|
import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import javax.swing.Icon
|
import javax.swing.Icon
|
||||||
|
|
||||||
public class KotlinLambdaSmartStepTarget(
|
public class KotlinLambdaSmartStepTarget(
|
||||||
@@ -40,7 +40,7 @@ public class KotlinLambdaSmartStepTarget(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun calcLabel(descriptor: DeclarationDescriptor, paramName: Name): String {
|
fun calcLabel(descriptor: DeclarationDescriptor, paramName: Name): String {
|
||||||
return "${descriptor.getName().asString()}: ${paramName.asString()}.${OperatorConventions.INVOKE.asString()}()"
|
return "${descriptor.getName().asString()}: ${paramName.asString()}.${OperatorNameConventions.INVOKE.asString()}()"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
|||||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import java.util.HashSet
|
import java.util.HashSet
|
||||||
|
|
||||||
public class KotlinRecursiveCallLineMarkerProvider() : LineMarkerProvider {
|
public class KotlinRecursiveCallLineMarkerProvider() : LineMarkerProvider {
|
||||||
@@ -155,7 +156,7 @@ private fun getCallNameFromPsi(element: JetElement): Name? {
|
|||||||
return Name.identifier("get")
|
return Name.identifier("get")
|
||||||
is JetThisExpression ->
|
is JetThisExpression ->
|
||||||
if (element.getParent() is JetCallExpression) {
|
if (element.getParent() is JetCallExpression) {
|
||||||
return OperatorConventions.INVOKE
|
return OperatorNameConventions.INVOKE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
|||||||
import org.jetbrains.kotlin.resolve.OverrideResolver
|
import org.jetbrains.kotlin.resolve.OverrideResolver
|
||||||
import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike
|
import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
public class OperatorModifierInspection : AbstractKotlinInspection() {
|
public class OperatorModifierInspection : AbstractKotlinInspection() {
|
||||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor {
|
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor {
|
||||||
@@ -67,25 +68,25 @@ public class OperatorModifierInspection : AbstractKotlinInspection() {
|
|||||||
val arity = valueParameters.size()
|
val arity = valueParameters.size()
|
||||||
if (arity == 0 &&
|
if (arity == 0 &&
|
||||||
(name in OperatorConventions.UNARY_OPERATION_NAMES.values() ||
|
(name in OperatorConventions.UNARY_OPERATION_NAMES.values() ||
|
||||||
name == OperatorConventions.ITERATOR ||
|
name == OperatorNameConventions.ITERATOR ||
|
||||||
isComponentLike(name) ||
|
isComponentLike(name) ||
|
||||||
name == OperatorConventions.NEXT ||
|
name == OperatorNameConventions.NEXT ||
|
||||||
(name == OperatorConventions.HAS_NEXT && isBooleanReturnType()))) {
|
(name == OperatorNameConventions.HAS_NEXT && isBooleanReturnType()))) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (arity == 1 && (name in OperatorConventions.BINARY_OPERATION_NAMES.values() ||
|
if (arity == 1 && (name in OperatorConventions.BINARY_OPERATION_NAMES.values() ||
|
||||||
name in OperatorConventions.ASSIGNMENT_OPERATIONS.values () ||
|
name in OperatorConventions.ASSIGNMENT_OPERATIONS.values () ||
|
||||||
(name == OperatorConventions.CONTAINS && isBooleanReturnType()) ||
|
(name == OperatorNameConventions.CONTAINS && isBooleanReturnType()) ||
|
||||||
(name == OperatorConventions.COMPARE_TO && isIntReturnType()))) {
|
(name == OperatorNameConventions.COMPARE_TO && isIntReturnType()))) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (name == OperatorConventions.INVOKE) {
|
if (name == OperatorNameConventions.INVOKE) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (arity >= 1 && name == OperatorConventions.GET) {
|
if (arity >= 1 && name == OperatorNameConventions.GET) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (arity >= 2 && name == OperatorConventions.SET) {
|
if (arity >= 2 && name == OperatorNameConventions.SET) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
||||||
import java.awt.GridBagConstraints
|
import java.awt.GridBagConstraints
|
||||||
import java.awt.GridBagLayout
|
import java.awt.GridBagLayout
|
||||||
@@ -213,7 +214,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() {
|
|||||||
|
|
||||||
private fun isConventionalName(namedDeclaration: JetNamedDeclaration): Boolean {
|
private fun isConventionalName(namedDeclaration: JetNamedDeclaration): Boolean {
|
||||||
val name = namedDeclaration.getNameAsName()
|
val name = namedDeclaration.getNameAsName()
|
||||||
return name!!.getOperationSymbolsToSearch().isNotEmpty() || name == OperatorConventions.INVOKE
|
return name!!.getOperationSymbolsToSearch().isNotEmpty() || name == OperatorNameConventions.INVOKE
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hasNonTrivialUsages(declaration: JetNamedDeclaration): Boolean {
|
private fun hasNonTrivialUsages(declaration: JetNamedDeclaration): Boolean {
|
||||||
|
|||||||
+2
-2
@@ -25,11 +25,11 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
|
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess
|
import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
public class ReplaceContainsIntention : JetSelfTargetingRangeIntention<JetDotQualifiedExpression>(javaClass(), "Replace 'contains' call with 'in' operator"), HighPriorityAction {
|
public class ReplaceContainsIntention : JetSelfTargetingRangeIntention<JetDotQualifiedExpression>(javaClass(), "Replace 'contains' call with 'in' operator"), HighPriorityAction {
|
||||||
override fun applicabilityRange(element: JetDotQualifiedExpression): TextRange? {
|
override fun applicabilityRange(element: JetDotQualifiedExpression): TextRange? {
|
||||||
if (element.calleeName != OperatorConventions.CONTAINS.asString()) return null
|
if (element.calleeName != OperatorNameConventions.CONTAINS.asString()) return null
|
||||||
|
|
||||||
val resolvedCall = element.toResolvedCall() ?: return null
|
val resolvedCall = element.toResolvedCall() ?: return null
|
||||||
if (!resolvedCall.isReallySuccess()) return null
|
if (!resolvedCall.isReallySuccess()) return null
|
||||||
|
|||||||
+2
-2
@@ -24,11 +24,11 @@ import org.jetbrains.kotlin.idea.intentions.callExpression
|
|||||||
import org.jetbrains.kotlin.idea.intentions.calleeName
|
import org.jetbrains.kotlin.idea.intentions.calleeName
|
||||||
import org.jetbrains.kotlin.psi.JetCallExpression
|
import org.jetbrains.kotlin.psi.JetCallExpression
|
||||||
import org.jetbrains.kotlin.psi.JetDotQualifiedExpression
|
import org.jetbrains.kotlin.psi.JetDotQualifiedExpression
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
public class ReplaceInvokeIntention : JetSelfTargetingRangeIntention<JetDotQualifiedExpression>(javaClass(), "Replace 'invoke' with direct call"), HighPriorityAction {
|
public class ReplaceInvokeIntention : JetSelfTargetingRangeIntention<JetDotQualifiedExpression>(javaClass(), "Replace 'invoke' with direct call"), HighPriorityAction {
|
||||||
override fun applicabilityRange(element: JetDotQualifiedExpression): TextRange? {
|
override fun applicabilityRange(element: JetDotQualifiedExpression): TextRange? {
|
||||||
if (element.calleeName != OperatorConventions.INVOKE.asString()) return null
|
if (element.calleeName != OperatorNameConventions.INVOKE.asString()) return null
|
||||||
return element.callExpression!!.getCalleeExpression()!!.getTextRange()
|
return element.callExpression!!.getCalleeExpression()!!.getTextRange()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -416,7 +416,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return fakeFunction.initialize(null, null, typeParameters, Collections.emptyList(), null,
|
return fakeFunction.initialize(null, null, typeParameters, Collections.emptyList(), null,
|
||||||
null, Visibilities.INTERNAL, false, false)
|
null, Visibilities.INTERNAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderTypeCandidates(
|
private fun renderTypeCandidates(
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.Functi
|
|||||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
|
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
|
||||||
import org.jetbrains.kotlin.psi.JetForExpression
|
import org.jetbrains.kotlin.psi.JetForExpression
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
object CreateHasNextFunctionActionFactory : CreateCallableMemberFromUsageFactory<JetForExpression>() {
|
object CreateHasNextFunctionActionFactory : CreateCallableMemberFromUsageFactory<JetForExpression>() {
|
||||||
override fun getElementOfInterest(diagnostic: Diagnostic): JetForExpression? {
|
override fun getElementOfInterest(diagnostic: Diagnostic): JetForExpression? {
|
||||||
@@ -38,6 +38,6 @@ object CreateHasNextFunctionActionFactory : CreateCallableMemberFromUsageFactory
|
|||||||
DiagnosticFactory.cast(diagnostic, Errors.HAS_NEXT_MISSING, Errors.HAS_NEXT_FUNCTION_NONE_APPLICABLE)
|
DiagnosticFactory.cast(diagnostic, Errors.HAS_NEXT_MISSING, Errors.HAS_NEXT_FUNCTION_NONE_APPLICABLE)
|
||||||
val ownerType = TypeInfo(diagnosticWithParameters.a, Variance.IN_VARIANCE)
|
val ownerType = TypeInfo(diagnosticWithParameters.a, Variance.IN_VARIANCE)
|
||||||
val returnType = TypeInfo(element.platform.builtIns.booleanType, Variance.OUT_VARIANCE)
|
val returnType = TypeInfo(element.platform.builtIns.booleanType, Variance.OUT_VARIANCE)
|
||||||
return FunctionInfo(OperatorConventions.HAS_NEXT.asString(), ownerType, returnType, isOperator = true)
|
return FunctionInfo(OperatorNameConventions.HAS_NEXT.asString(), ownerType, returnType, isOperator = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.Parame
|
|||||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
|
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
|
||||||
import org.jetbrains.kotlin.psi.JetCallExpression
|
import org.jetbrains.kotlin.psi.JetCallExpression
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
object CreateInvokeFunctionActionFactory : CreateCallableMemberFromUsageFactory<JetCallExpression>() {
|
object CreateInvokeFunctionActionFactory : CreateCallableMemberFromUsageFactory<JetCallExpression>() {
|
||||||
override fun getElementOfInterest(diagnostic: Diagnostic): JetCallExpression? {
|
override fun getElementOfInterest(diagnostic: Diagnostic): JetCallExpression? {
|
||||||
@@ -47,6 +47,6 @@ object CreateInvokeFunctionActionFactory : CreateCallableMemberFromUsageFactory<
|
|||||||
}
|
}
|
||||||
|
|
||||||
val returnType = TypeInfo(element, Variance.OUT_VARIANCE)
|
val returnType = TypeInfo(element, Variance.OUT_VARIANCE)
|
||||||
return FunctionInfo(OperatorConventions.INVOKE.asString(), receiverType, returnType, parameterInfos = parameters, isOperator = true)
|
return FunctionInfo(OperatorNameConventions.INVOKE.asString(), receiverType, returnType, parameterInfos = parameters, isOperator = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.JetForExpression
|
|||||||
import org.jetbrains.kotlin.types.JetTypeImpl
|
import org.jetbrains.kotlin.types.JetTypeImpl
|
||||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object CreateIteratorFunctionActionFactory : CreateCallableMemberFromUsageFactory<JetForExpression>() {
|
object CreateIteratorFunctionActionFactory : CreateCallableMemberFromUsageFactory<JetForExpression>() {
|
||||||
@@ -58,6 +58,6 @@ object CreateIteratorFunctionActionFactory : CreateCallableMemberFromUsageFactor
|
|||||||
returnJetTypeArguments,
|
returnJetTypeArguments,
|
||||||
returnJetType.memberScope)
|
returnJetType.memberScope)
|
||||||
val returnType = TypeInfo(newReturnJetType, Variance.OUT_VARIANCE)
|
val returnType = TypeInfo(newReturnJetType, Variance.OUT_VARIANCE)
|
||||||
return FunctionInfo(OperatorConventions.ITERATOR.asString(), iterableType, returnType, isOperator = true)
|
return FunctionInfo(OperatorNameConventions.ITERATOR.asString(), iterableType, returnType, isOperator = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeIn
|
|||||||
import org.jetbrains.kotlin.psi.JetExpression
|
import org.jetbrains.kotlin.psi.JetExpression
|
||||||
import org.jetbrains.kotlin.psi.JetForExpression
|
import org.jetbrains.kotlin.psi.JetForExpression
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
object CreateNextFunctionActionFactory : CreateCallableMemberFromUsageFactory<JetForExpression>() {
|
object CreateNextFunctionActionFactory : CreateCallableMemberFromUsageFactory<JetForExpression>() {
|
||||||
override fun getElementOfInterest(diagnostic: Diagnostic): JetForExpression? {
|
override fun getElementOfInterest(diagnostic: Diagnostic): JetForExpression? {
|
||||||
@@ -39,6 +39,6 @@ object CreateNextFunctionActionFactory : CreateCallableMemberFromUsageFactory<Je
|
|||||||
|
|
||||||
val variableExpr = element.loopParameter ?: element.multiParameter ?: return null
|
val variableExpr = element.loopParameter ?: element.multiParameter ?: return null
|
||||||
val returnType = TypeInfo(variableExpr as JetExpression, Variance.OUT_VARIANCE)
|
val returnType = TypeInfo(variableExpr as JetExpression, Variance.OUT_VARIANCE)
|
||||||
return FunctionInfo(OperatorConventions.NEXT.asString(), ownerType, returnType, isOperator = true)
|
return FunctionInfo(OperatorNameConventions.NEXT.asString(), ownerType, returnType, isOperator = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.lexer.JetTokens
|
|||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
|
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|
||||||
public fun CallArgumentTranslator.ArgumentsInfo.argsWithReceiver(receiver: JsExpression): List<JsExpression> {
|
public fun CallArgumentTranslator.ArgumentsInfo.argsWithReceiver(receiver: JsExpression): List<JsExpression> {
|
||||||
@@ -163,7 +163,7 @@ object NativeSetterCallCase : AnnotatedAsNativeXCallCase(PredefinedAnnotation.NA
|
|||||||
object InvokeIntrinsic : FunctionCallCase() {
|
object InvokeIntrinsic : FunctionCallCase() {
|
||||||
fun canApply(callInfo: FunctionCallInfo): Boolean {
|
fun canApply(callInfo: FunctionCallInfo): Boolean {
|
||||||
val callableDescriptor = callInfo.callableDescriptor
|
val callableDescriptor = callInfo.callableDescriptor
|
||||||
if (callableDescriptor.getName() != OperatorConventions.INVOKE)
|
if (callableDescriptor.getName() != OperatorNameConventions.INVOKE)
|
||||||
return false
|
return false
|
||||||
val parameterCount = callableDescriptor.getValueParameters().size()
|
val parameterCount = callableDescriptor.getValueParameters().size()
|
||||||
val funDeclaration = callableDescriptor.getContainingDeclaration()
|
val funDeclaration = callableDescriptor.getContainingDeclaration()
|
||||||
|
|||||||
+2
-1
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils;
|
|||||||
import org.jetbrains.kotlin.lexer.JetToken;
|
import org.jetbrains.kotlin.lexer.JetToken;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -143,7 +144,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (JsDescriptorUtils.isBuiltin(descriptor) && descriptor.getName().equals(OperatorConventions.COMPARE_TO)) {
|
if (JsDescriptorUtils.isBuiltin(descriptor) && descriptor.getName().equals(OperatorNameConventions.COMPARE_TO)) {
|
||||||
return BUILTINS_COMPARE_TO_INTRINSIC;
|
return BUILTINS_COMPARE_TO_INTRINSIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.kotlin.js.translate.context.Namer;
|
import org.jetbrains.kotlin.js.translate.context.Namer;
|
||||||
import org.jetbrains.kotlin.js.translate.context.TranslationContext;
|
import org.jetbrains.kotlin.js.translate.context.TranslationContext;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -160,7 +161,7 @@ public final class JsAstUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JsExpression compareTo(@NotNull JsExpression left, @NotNull JsExpression right) {
|
public static JsExpression compareTo(@NotNull JsExpression left, @NotNull JsExpression right) {
|
||||||
return invokeKotlinFunction(OperatorConventions.COMPARE_TO.getIdentifier(), left, right);
|
return invokeKotlinFunction(OperatorNameConventions.COMPARE_TO.getIdentifier(), left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
import org.jetbrains.kotlin.types.JetType;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -62,7 +62,7 @@ public final class JsDescriptorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCompareTo(@NotNull CallableDescriptor descriptor) {
|
public static boolean isCompareTo(@NotNull CallableDescriptor descriptor) {
|
||||||
return descriptor.getName().equals(OperatorConventions.COMPARE_TO);
|
return descriptor.getName().equals(OperatorNameConventions.COMPARE_TO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
Reference in New Issue
Block a user