From 9d1af5a17ecce95c90724ba343b0ba8313748983 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Thu, 26 Nov 2015 15:56:56 +0300 Subject: [PATCH] Fix tests: "infix modifier required" and "operator modifier required" errors --- .../arrays/collectionAssignGetMultiIndex.kt | 4 +- .../box/arrays/collectionGetMultiIndex.kt | 4 +- .../testData/codegen/box/arrays/hashMap.kt | 2 +- compiler/testData/codegen/box/arrays/kt238.kt | 8 +- .../testData/codegen/box/arrays/kt4348.kt | 4 +- compiler/testData/codegen/box/arrays/kt950.kt | 2 +- .../codegen/box/arrays/longAsIndex.kt | 4 +- .../codegen/box/binaryOp/infixCall.kt | 21 -- .../codegen/box/binaryOp/infixCallAny.kt | 21 -- .../codegen/box/binaryOp/infixCallNullable.kt | 21 -- compiler/testData/codegen/box/casts/as.kt | 2 +- compiler/testData/codegen/box/casts/asSafe.kt | 2 +- .../testData/codegen/box/classes/kt1891.kt | 4 +- .../testData/codegen/box/classes/kt2711.kt | 4 +- .../testData/codegen/box/classes/kt504.kt | 2 +- .../testData/codegen/box/classes/kt723.kt | 2 +- .../testData/codegen/box/classes/kt725.kt | 2 +- .../testData/codegen/box/classes/kt903.kt | 2 +- .../box/classes/overloadBinaryOperator.kt | 2 +- .../codegen/box/classes/overloadPlusAssign.kt | 4 +- .../box/classes/overloadPlusAssignReturn.kt | 4 +- .../box/classes/overloadPlusToPlusAssign.kt | 4 +- .../box/classes/overloadUnaryOperator.kt | 4 +- .../testData/codegen/box/closures/kt4137.kt | 2 +- .../codegen/box/controlStructures/emptyFor.kt | 2 +- .../forLoopMemberExtensionAll.kt | 6 +- .../forLoopMemberExtensionHasNext.kt | 6 +- .../forLoopMemberExtensionNext.kt | 6 +- .../box/controlStructures/forUserType.kt | 12 +- .../inRangeConditionsInWhen.kt | 2 +- .../codegen/box/controlStructures/kt299.kt | 2 +- .../codegen/box/controlStructures/kt513.kt | 6 +- .../codegen/box/controlStructures/kt628.kt | 2 +- .../function/augmentedAssignment.kt | 2 +- .../augmentedAssignmentViaBinaryExpression.kt | 2 +- .../defaultArguments/function/binaryCall.kt | 2 +- .../function/binaryExpression.kt | 2 +- .../box/defaultArguments/function/contains.kt | 2 +- ...accessTopLevelDelegatedPropertyInClinit.kt | 2 +- .../capturePropertyInClosure.kt | 4 +- .../delegatedProperty/castGetReturnType.kt | 2 +- .../box/delegatedProperty/castSetParameter.kt | 4 +- .../box/delegatedProperty/defaultArgs.kt | 2 +- .../delegatedProperty/delegateAsInnerClass.kt | 4 +- .../delegateByOtherProperty.kt | 4 +- .../delegateByTopLevelFun.kt | 4 +- .../delegateByTopLevelProperty.kt | 4 +- .../delegateForExtProperty.kt | 2 +- .../delegateForExtPropertyInClass.kt | 2 +- .../box/delegatedProperty/genericDelegate.kt | 4 +- .../delegatedProperty/getAsExtensionFun.kt | 2 +- .../getAsExtensionFunInClass.kt | 2 +- .../box/delegatedProperty/inClassVal.kt | 2 +- .../box/delegatedProperty/inClassVar.kt | 4 +- .../codegen/box/delegatedProperty/inTrait.kt | 2 +- .../delegatedProperty/inferredPropertyType.kt | 4 +- .../codegen/box/delegatedProperty/kt4138.kt | 4 +- .../box/delegatedProperty/privateVar.kt | 4 +- .../propertyMetadataShouldBeCached.kt | 12 +- .../delegatedProperty/setAsExtensionFun.kt | 4 +- .../setAsExtensionFunInClass.kt | 4 +- .../box/delegatedProperty/topLevelVal.kt | 2 +- .../box/delegatedProperty/topLevelVar.kt | 4 +- .../delegatedProperty/twoPropByOneDelegete.kt | 2 +- .../useReflectionOnKProperty.kt | 2 +- .../box/delegatedProperty/valInInnerClass.kt | 2 +- .../box/delegatedProperty/varInInnerClass.kt | 4 +- .../codegen/box/delegatedProperty/vararg.kt | 2 +- .../codegen/box/extensionFunctions/kt1953.kt | 2 +- .../box/extensionFunctions/kt1953_class.kt | 2 +- .../codegen/box/extensionFunctions/kt3298.kt | 2 +- .../codegen/box/extensionFunctions/kt3969.kt | 2 +- .../codegen/box/extensionFunctions/kt865.kt | 4 +- .../codegen/box/extensionFunctions/shared.kt | 2 +- .../genericValForPrimitiveType.kt | 2 +- .../genericVarForPrimitiveType.kt | 2 +- .../codegen/box/fieldRename/delegates.kt | 4 +- .../codegen/box/finally/finallyAndFinally.kt | 2 +- .../testData/codegen/box/finally/kt3894.kt | 2 +- .../codegen/box/finally/loopAndFinally.kt | 2 +- .../codegen/box/finally/tryLoopTry.kt | 2 +- .../testData/codegen/box/functions/ea33909.kt | 2 +- .../box/functions/infixRecursiveCall.kt | 2 +- .../functions/invoke/extensionInvokeOnExpr.kt | 4 +- .../codegen/box/functions/invoke/invoke.kt | 4 +- .../invoke/invokeOnExprByConvention.kt | 4 +- .../codegen/box/functions/invoke/kt3189.kt | 2 +- .../codegen/box/functions/invoke/kt3297.kt | 2 +- .../functions/invoke/kt3450getAndInvoke.kt | 4 +- .../functions/invoke/kt3631invokeOnString.kt | 2 +- .../codegen/box/functions/invoke/kt3772.kt | 2 +- .../functions/invoke/kt3821invokeOnThis.kt | 2 +- .../testData/codegen/box/functions/kt1038.kt | 4 +- .../testData/codegen/box/functions/kt1199.kt | 6 +- .../testData/codegen/box/functions/kt2929.kt | 2 +- .../testData/codegen/box/functions/kt3214.kt | 6 +- .../box/functions/localFunctions/kt4119.kt | 6 +- .../box/functions/localFunctions/kt4119_2.kt | 2 +- .../box/functions/localFunctions/kt4783.kt | 2 +- .../box/functions/localFunctions/kt4784.kt | 4 +- .../box/functions/localFunctions/kt4989.kt | 2 +- .../localFunctions/localWithDefault.kt | 2 +- .../box/functions/prefixRecursiveCall.kt | 2 +- .../box/functions/recursiveCompareTo.kt | 2 +- .../box/functions/recursiveIncrementCall.kt | 2 +- .../box/increment/postfixIncrementOnClass.kt | 2 +- .../postfixIncrementOnClassSmartCast.kt | 2 +- .../increment/postfixNotnullClassIncrement.kt | 2 +- .../postfixNullableClassIncrement.kt | 2 +- .../box/increment/postfixNullableIncrement.kt | 2 +- .../box/increment/prefixIncrementOnClass.kt | 2 +- .../prefixIncrementOnClassSmartCast.kt | 2 +- .../increment/prefixNotnullClassIncrement.kt | 2 +- .../increment/prefixNullableClassIncrement.kt | 2 +- .../box/increment/prefixNullableIncrement.kt | 2 +- .../codegen/box/innerNested/innerInfixCall.kt | 15 -- .../codegen/box/intrinsics/compareTo.kt | 16 -- .../codegen/box/intrinsics/ea35953.kt | 2 +- .../codegen/box/intrinsics/infixCall.kt | 8 - .../objectMethods/cloneCallsConstructor.kt | 2 +- .../objectMethods/cloneCallsSuper.kt | 2 +- .../cloneCallsSuperAndModifies.kt | 2 +- .../javaInterop/objectMethods/cloneHashSet.kt | 2 +- .../objectMethods/cloneHierarchy.kt | 4 +- .../cloneableClassWithoutClone.kt | 2 +- .../box/multiDecl/ComplexInitializer.kt | 5 +- .../codegen/box/multiDecl/SimpleVals.kt | 4 +- .../box/multiDecl/SimpleValsExtensions.kt | 4 +- .../box/multiDecl/SimpleVarsExtensions.kt | 4 +- .../multiDecl/ValCapturedInFunctionLiteral.kt | 4 +- .../multiDecl/ValCapturedInLocalFunction.kt | 4 +- .../multiDecl/ValCapturedInObjectLiteral.kt | 4 +- .../multiDecl/VarCapturedInFunctionLiteral.kt | 4 +- .../multiDecl/VarCapturedInLocalFunction.kt | 4 +- .../multiDecl/VarCapturedInObjectLiteral.kt | 4 +- .../codegen/box/multiDecl/component.kt | 8 +- .../box/multiDecl/forIterator/MultiDeclFor.kt | 4 +- .../MultiDeclForComponentExtensions.kt | 4 +- .../MultiDeclForComponentMemberExtensions.kt | 4 +- ...nentMemberExtensionsInExtensionFunction.kt | 4 +- .../forIterator/MultiDeclForValCaptured.kt | 4 +- .../MultiDeclForComponentExtensions.kt | 4 +- ...tiDeclForComponentExtensionsValCaptured.kt | 4 +- .../MultiDeclForComponentMemberExtensions.kt | 4 +- ...nentMemberExtensionsInExtensionFunction.kt | 4 +- .../box/multiDecl/forRange/MultiDeclFor.kt | 12 +- .../MultiDeclForComponentExtensions.kt | 12 +- .../MultiDeclForComponentMemberExtensions.kt | 12 +- ...nentMemberExtensionsInExtensionFunction.kt | 12 +- .../forRange/MultiDeclForValCaptured.kt | 12 +- .../forRange/explicitRangeTo/MultiDeclFor.kt | 12 +- .../MultiDeclForComponentExtensions.kt | 12 +- .../MultiDeclForComponentMemberExtensions.kt | 14 +- ...nentMemberExtensionsInExtensionFunction.kt | 12 +- .../MultiDeclForValCaptured.kt | 12 +- .../int/MultiDeclForComponentExtensions.kt | 6 +- ...tiDeclForComponentExtensionsValCaptured.kt | 6 +- .../MultiDeclForComponentMemberExtensions.kt | 6 +- ...nentMemberExtensionsInExtensionFunction.kt | 6 +- .../long/MultiDeclForComponentExtensions.kt | 6 +- ...tiDeclForComponentExtensionsValCaptured.kt | 6 +- .../MultiDeclForComponentMemberExtensions.kt | 6 +- ...nentMemberExtensionsInExtensionFunction.kt | 6 +- .../explicitRangeToWithDot/MultiDeclFor.kt | 10 +- .../MultiDeclForComponentExtensions.kt | 10 +- .../MultiDeclForComponentMemberExtensions.kt | 10 +- ...nentMemberExtensionsInExtensionFunction.kt | 10 +- .../MultiDeclForValCaptured.kt | 10 +- .../int/MultiDeclForComponentExtensions.kt | 4 +- ...tiDeclForComponentExtensionsValCaptured.kt | 4 +- .../MultiDeclForComponentMemberExtensions.kt | 4 +- ...nentMemberExtensionsInExtensionFunction.kt | 4 +- .../long/MultiDeclForComponentExtensions.kt | 6 +- ...tiDeclForComponentExtensionsValCaptured.kt | 4 +- .../MultiDeclForComponentMemberExtensions.kt | 4 +- ...nentMemberExtensionsInExtensionFunction.kt | 4 +- .../int/MultiDeclForComponentExtensions.kt | 4 +- ...tiDeclForComponentExtensionsValCaptured.kt | 4 +- .../MultiDeclForComponentMemberExtensions.kt | 4 +- ...nentMemberExtensionsInExtensionFunction.kt | 4 +- .../long/MultiDeclForComponentExtensions.kt | 4 +- ...tiDeclForComponentExtensionsValCaptured.kt | 4 +- .../MultiDeclForComponentMemberExtensions.kt | 4 +- ...nentMemberExtensionsInExtensionFunction.kt | 4 +- .../testData/codegen/box/objects/flist.kt | 4 +- .../objects/useAnonymousObjectAsIterator.kt | 2 +- .../assignmentOperations.kt | 20 +- .../operatorConventions/compareTo/boolean.kt | 1 - .../compareTo/extensionArray.kt | 2 +- .../compareTo/extensionObject.kt | 2 +- .../box/operatorConventions/incDecOnObject.kt | 4 +- .../codegen/box/operatorConventions/kt4987.kt | 2 +- .../box/platformTypes/primitives/compareTo.kt | 2 +- .../primitives/identityEquals.kt | 6 +- .../primitiveTypes/equalsHashCodeToString.kt | 8 - .../codegen/box/primitiveTypes/kt1055.kt | 2 +- .../codegen/box/primitiveTypes/kt1093.kt | 4 +- .../codegen/box/primitiveTypes/kt752.kt | 2 +- .../codegen/box/primitiveTypes/kt756.kt | 10 +- .../codegen/box/primitiveTypes/kt935.kt | 2 +- .../codegen/box/primitiveTypes/rangeTo.kt | 18 -- .../testData/codegen/box/properties/kt4383.kt | 2 +- .../primitiveOverrideDelegateAccessor.kt | 4 +- .../codegen/box/regressions/kt3173.kt | 4 - .../codegen/box/regressions/kt3421.kt | 2 +- .../codegen/box/regressions/kt3999.kt | 17 -- .../testData/codegen/box/strings/kt889.kt | 2 +- .../codegen/box/typeMapping/kt3863.kt | 4 +- .../codegen/box/typeMapping/kt3976.kt | 4 +- .../testData/codegen/box/vararg/kt796_797.kt | 2 +- .../testData/codegen/box/when/longInRange.kt | 2 +- .../callableReference/publicMutableField.kt | 2 +- .../sam/adapters/operators/infixCall.java | 5 - .../sam/adapters/operators/infixCall.kt | 7 - .../callSite/exceptionTableSplit.2.kt | 2 +- .../callSite/exceptionTableSplitNoReturn.2.kt | 2 +- .../exceptionTable/exceptionInFinally.1.kt | 2 +- .../exceptionTable/tryCatchInFinally.2.kt | 2 +- .../smap/resolve/inlineComponent.2.kt | 4 +- .../smap/resolve/inlineIterator.2.kt | 2 +- .../codegen/boxInline/special/plusAssign.2.kt | 2 +- .../kotlinPropertyInheritedInJava/K.kt | 8 +- .../mutatePrivateJavaInstanceField/K.kt | 4 +- .../referenceToJavaFieldOfKotlinSubclass/K.kt | 2 +- .../annotations/delegatedPropertySetter.kt | 4 +- .../arrays/arrayGetAssignMultiIndex.kt | 4 +- .../arrays/arrayGetMultiIndex.kt | 4 +- .../boxWithStdlib/arrays/cloneArray.kt | 4 +- .../arrays/clonePrimitiveArrays.kt | 16 +- .../codegen/boxWithStdlib/arrays/kt4357.kt | 4 +- .../codegen/boxWithStdlib/arrays/stdlib.kt | 6 +- .../function/sortListOfStrings.kt | 2 +- .../callableReference/property/delegated.kt | 2 +- .../property/delegatedMutable.kt | 4 +- .../property/genericProperty.kt | 2 +- .../property/simpleExtension.kt | 2 +- .../property/simpleMutableExtension.kt | 4 +- .../property/simpleMutableMember.kt | 4 +- .../codegen/boxWithStdlib/classes/kt471.kt | 6 +- .../codegen/boxWithStdlib/classes/kt633.kt | 8 +- .../dataClasses/equals/alreadyDeclared.kt | 2 +- .../stackOverflowOnCallFromGetValue.kt | 4 +- .../delegatedProperty/useKPropertyLater.kt | 4 +- .../boxWithStdlib/evaluate/infixCallBinary.kt | 20 -- .../fullJdk/regressions/kt1202.kt | 4 +- .../boxWithStdlib/fullJdk/smap/infixCalls.kt | 2 +- .../exceptionInMonitorExpression.kt | 2 +- .../fullJdk/synchronized/finally.kt | 2 +- .../boxWithStdlib/jvmStatic/convention.kt | 2 +- .../boxWithStdlib/lazyCodegen/increment.kt | 2 +- .../optimizations/noOptimization.kt | 4 +- .../multiDeclForArray/MultiDeclFor.kt | 4 +- .../MultiDeclForComponentExtensions.kt | 4 +- .../MultiDeclForComponentMemberExtensions.kt | 4 +- ...nentMemberExtensionsInExtensionFunction.kt | 4 +- .../MultiDeclForValCaptured.kt | 4 +- .../int/MultiDeclForComponentExtensions.kt | 4 +- ...tiDeclForComponentExtensionsValCaptured.kt | 4 +- .../MultiDeclForComponentMemberExtensions.kt | 4 +- ...nentMemberExtensionsInExtensionFunction.kt | 4 +- .../long/MultiDeclForComponentExtensions.kt | 4 +- ...tiDeclForComponentExtensionsValCaptured.kt | 4 +- .../MultiDeclForComponentMemberExtensions.kt | 4 +- ...nentMemberExtensionsInExtensionFunction.kt | 4 +- .../boxWithStdlib/nonLocalReturns/use.kt | 2 +- .../nonLocalReturns/useWithException.kt | 2 +- .../multiAssignmentIterationOverIntRange.kt | 4 +- ...getExtensionPropertiesMutableVsReadonly.kt | 4 +- .../getPropertiesMutableVsReadonly.kt | 4 +- .../memberAndMemberExtensionWithSameName.kt | 4 +- .../privatePlatformStaticVarInObject.kt | 8 +- .../properties/protectedClassVar.kt | 2 +- .../boxWithStdlib/reified/DIExample.kt | 2 +- .../componentEvaluatesOnlyOnce.kt | 8 +- .../stringOperations/infixPlus.kt | 17 -- .../notNullAssertions/AssertionChecker.kt | 6 +- .../privateClassPropertyAccessors.kt | 4 +- .../tests/incompleteCode/plusOnTheRight.kt | 4 +- .../tests/incompleteCode/plusOnTheRight.txt | 2 +- .../redeclarations/ScriptAndClassConflict.txt | 14 +- .../diagnostics/tests/scopes/kt250.617.10.kt | 2 +- .../diagnostics/tests/scopes/kt250.617.10.txt | 8 +- .../lineNumber/custom/multilineInfixCall.kt | 2 +- .../custom/smapInlineAsInfixArgument.kt | 2 +- .../classMembers/DelegatedProperty.kt | 2 +- .../packageMembers/DelegatedProperty.kt | 2 +- .../fromLoadJava/library/Max.kt | 2 +- .../compiledKotlin/prop/VarWithDelegated.kt | 4 +- .../compiledKotlin/prop/VarWithDelegated.txt | 4 +- .../parameters/expressions/infixCallBinary.kt | 13 -- .../realExamples/stringPlusInBuilders.kt | 2 +- .../realExamples/stringPlusInBuilders.txt | 4 +- .../visibility/privateSet.kt | 4 +- .../class/delegatedProtectedVar.kt | 4 +- .../classObject/class/delegatedPublicVal.kt | 2 +- .../rename/delegatedAndDelegated.kt | 4 +- .../rename/delegatedAndProperty.kt | 4 +- .../trait/delegatedProtectedVar.kt | 4 +- .../classObject/trait/delegatedPublicVal.kt | 2 +- .../codegen/BytecodeTextTestGenerated.java | 6 - ...ackBoxAgainstJavaCodegenTestGenerated.java | 6 - .../BlackBoxCodegenTestGenerated.java | 48 ----- ...lackBoxWithStdlibCodegenTestGenerated.java | 6 - .../AnnotationParameterTestGenerated.java | 6 - .../recursiveCall/conventionCall.kt | 16 +- .../imports/ExtensionAsInfixOrOperator.kt | 4 +- .../imports/ExtensionConflict.expected.kt | 14 +- .../imports/ExtensionConflict.expected.names | 2 +- .../copyPaste/imports/ExtensionConflict.kt | 6 +- .../copyPaste/imports/ExtensionConflict.to.kt | 6 +- idea/testData/copyPaste/imports/ForLoop.kt | 6 +- .../copyPaste/imports/GetExpression.kt | 2 +- idea/testData/copyPaste/imports/Invoke.kt | 2 +- .../copyPaste/imports/MultiDeclaration.kt | 4 +- .../MultiReferencePartiallyCopied.expected.kt | 2 +- .../imports/MultiReferencePartiallyCopied.kt | 6 +- idea/testData/debugger/smartStepInto/unary.kt | 8 +- .../tinyApp/outs/delegatedPropertyInClass.out | 4 +- .../delegatedPropertyInClassWoRenderer.out | 2 +- .../withoutBodyTypeParameters.kt | 2 +- .../singleBreakpoint/dependentOnFile.kt | 2 +- .../extractVariablesFromCall.kt | 2 +- .../frame/delegatedPropertyInClass.kt | 4 +- .../delegatedPropertyInClassWoRenderer.kt | 2 +- .../singleBreakpoint/typeParameterRef.kt | 4 +- .../kotlin/conventions/unaryMinus.0.kt | 4 +- .../kotlin/conventions/unaryMinus.results.txt | 2 +- .../conditionInvalidBinaryExp.kt | 2 +- .../conditionInvalidBinaryExp.kt | 2 +- .../conditionInvalidBinaryExp.kt | 2 +- .../conditionNotBinaryExpr.kt | 2 +- .../complexPlus.kt | 8 +- .../complexPlus.kt.after | 8 +- .../extensionFunction.kt | 2 +- .../extensionFunction.kt.after | 2 +- .../minusSanityTest.kt | 2 +- .../minusSanityTest.kt.after | 2 +- .../replaceCallWithUnaryOperator/plusPlus.kt | 2 +- .../plusPlus.kt.after | 2 +- .../plusSanityTest.kt | 2 +- .../plusSanityTest.kt.after | 2 +- .../replaceCallWithUnaryOperator/qualifier.kt | 2 +- .../qualifier.kt.after | 2 +- .../replaceCallWithUnaryOperator/super.kt | 2 +- .../typeArguments.kt | 2 +- .../convertForEachToForLoop/infixCall.kt | 2 +- .../infixCallNotAvailable.kt | 2 +- .../parenthesizedExpression.kt | 5 +- .../parenthesizedExpression.kt.after | 5 +- .../convertFunctionToProperty/invoke.kt | 2 +- .../convertFunctionToProperty/iterator.kt | 2 +- .../convertFunctionToProperty/unaryOp.kt | 2 +- .../doubleNegation.kt | 2 +- .../doubleNegation.kt.after | 2 +- .../nonstandardPrefixOperator.kt | 2 +- .../nonstandardPrefixOperator.kt.after | 2 +- .../binaryExpressionLoopRange.kt | 2 +- .../binaryExpressionLoopRange.kt.after | 2 +- .../functionLiteralArgument.kt | 2 +- .../functionLiteralArgument.kt.after | 2 +- .../infixCallToOrdinary/nullAssertedCall.kt | 2 + .../nullAssertedCall.kt.after | 2 + .../parenthesesAroundRightHandArgument.kt | 4 +- ...arenthesesAroundRightHandArgument.kt.after | 4 +- .../simpleInfixFunctionCall.kt | 2 + .../simpleInfixFunctionCall.kt.after | 2 + .../arrayAccessMultipleIndex.kt | 2 +- .../arrayAccessMultipleIndex.kt.after | 2 +- .../operatorToFunction/binaryPlusEquals.kt | 2 +- .../binaryPlusEquals.kt.after | 2 +- .../functionCallMultipleArgument.kt | 2 +- .../functionCallMultipleArgument.kt.after | 2 +- ...allWithMultipleArgumentsAndSingleLambda.kt | 2 +- ...hMultipleArgumentsAndSingleLambda.kt.after | 2 +- .../functionCallWithSingleLambda.kt | 2 +- .../functionCallWithSingleLambda.kt.after | 2 +- .../necessaryParentheses5.kt | 4 +- .../unnecessaryParentheses3.kt | 2 +- .../unnecessaryParentheses3.kt.after | 2 +- .../unnecessaryParentheses4.kt | 4 +- .../unnecessaryParentheses4.kt.after | 4 +- .../unnecessaryParentheses8.kt | 2 +- .../unnecessaryParentheses8.kt.after | 2 +- .../simplifyNegatedBinaryExpression/in.kt | 2 +- .../in.kt.after | 2 +- .../inapplicableBinaryOperation.kt | 2 +- .../simplifyNegatedBinaryExpression/notIn.kt | 2 +- .../notIn.kt.after | 2 +- .../swapBinaryExpression/compareTo.kt | 4 - .../swapBinaryExpression/divideLiteral.kt | 4 - .../swapBinaryExpression/equalsLiteral.kt | 3 - .../equalsLiteral.kt.after | 3 - .../identityEqualsLiteral.kt | 3 - .../identityEqualsLiteral.kt.after | 3 - .../swapBinaryExpression/infixFunction.kt | 2 +- .../swapBinaryExpression/minusLiteral.kt | 4 - .../swapBinaryExpression/plusLiteral.kt | 3 - .../swapBinaryExpression/plusLiteral.kt.after | 3 - .../swapBinaryExpression/rangeTo.kt | 2 +- .../swapBinaryExpression/rangeToLiteral.kt | 8 - .../swapBinaryExpression/timesLiteral.kt | 3 - .../timesLiteral.kt.after | 3 - .../autoImports/delegateExtensionSet.test | 4 +- ...ExtensionImportGetOnNoOperatorWarning.test | 2 + ...ExtensionImportSetOnNoOperatorWarning.test | 2 + .../addNameToArgument/invokeOnString.kt | 2 +- .../addNameToArgument/invokeOnString.kt.after | 2 +- .../customOperationOnUserType.kt | 1 + .../customOperationOnUserType.kt.after | 1 + .../binaryOperations/quotedName.kt | 2 + .../binaryOperations/quotedName.kt.after | 2 + .../component/createComponentFromUsage1.kt | 4 +- .../createComponentFromUsage1.kt.after | 4 +- .../component/createComponentFromUsage2.kt | 4 +- .../createComponentFromUsage2.kt.after | 4 +- .../component/createComponentFromUsage3.kt | 8 +- .../createComponentFromUsage3.kt.after | 8 +- .../delegateAccessors/varMissingGet.kt | 2 +- .../delegateAccessors/varMissingGet.kt.after | 2 +- .../delegateAccessors/varMissingSet.kt | 2 +- .../delegateAccessors/varMissingSet.kt.after | 2 +- .../createFunction/get/createGetFromUsage1.kt | 2 + .../get/createGetFromUsage1.kt.after | 2 + .../get/createGetFromUsage10.kt | 2 + .../get/createGetFromUsage10.kt.after | 2 + .../get/createGetFromUsage11.kt | 2 + .../get/createGetFromUsage11.kt.after | 2 + .../get/createGetFromUsage12.kt | 2 + .../get/createGetFromUsage12.kt.after | 2 + .../get/createGetFromUsage13.kt | 2 + .../get/createGetFromUsage13.kt.after | 2 + .../createFunction/get/createGetFromUsage2.kt | 2 + .../get/createGetFromUsage2.kt.after | 2 + .../createFunction/get/createGetFromUsage3.kt | 2 + .../get/createGetFromUsage3.kt.after | 2 + .../createFunction/get/createGetFromUsage4.kt | 2 + .../get/createGetFromUsage4.kt.after | 2 + .../createFunction/get/createGetFromUsage5.kt | 2 + .../get/createGetFromUsage5.kt.after | 2 + .../createFunction/get/createGetFromUsage7.kt | 2 + .../get/createGetFromUsage7.kt.after | 2 + .../createFunction/get/createGetFromUsage8.kt | 2 + .../get/createGetFromUsage8.kt.after | 2 + .../createFunction/get/createGetFromUsage9.kt | 2 + .../get/createGetFromUsage9.kt.after | 2 + .../hasNext/createHasNextFromUsage1.kt | 4 +- .../hasNext/createHasNextFromUsage1.kt.after | 4 +- .../hasNext/createHasNextFromUsage2.kt | 4 +- .../hasNext/createHasNextFromUsage2.kt.after | 4 +- .../iterator/createIteratorFromUsage3.kt | 8 +- .../createIteratorFromUsage3.kt.after | 8 +- .../next/createNextFromUsage1.kt | 4 +- .../next/createNextFromUsage1.kt.after | 4 +- .../next/createNextFromUsage2.kt | 4 +- .../next/createNextFromUsage2.kt.after | 4 +- .../createFunction/set/createSetFromUsage1.kt | 2 + .../set/createSetFromUsage1.kt.after | 2 + .../createFunction/set/createSetFromUsage2.kt | 1 + .../set/createSetFromUsage2.kt.after | 1 + .../createFunction/set/setterForIncrement.kt | 2 +- .../set/setterForIncrement.kt.after | 2 +- .../deprecatedSymbolUsage/infixCall.kt | 4 +- .../deprecatedSymbolUsage/infixCall.kt.after | 4 +- .../deprecatedSymbolUsage/keepInfixCall.kt | 4 +- .../keepInfixCall.kt.after | 4 +- .../deprecatedSymbolUsage/operatorCall.kt | 2 +- .../operatorCall.kt.after | 2 +- .../deprecatedSymbolUsage/operatorCall2.kt | 2 +- .../operatorCall2.kt.after | 2 +- .../changeThisSafeCallWithValue4Runtime.kt | 2 +- ...angeThisSafeCallWithValue4Runtime.kt.after | 2 +- .../deprecatedDelegatesGetSetMember.kt | 2 + .../deprecatedDelegatesGetSetMember.kt.after | 2 + .../modifiers/operatorModifierComponent.kt | 2 + .../operatorModifierComponent.kt.after | 2 + .../quickfix/suppress/forStatement/infix.kt | 4 +- .../suppress/forStatement/infix.kt.after | 4 +- .../anonymousObjectInInfixCall.kt | 2 +- .../anonymousObjectInInfixCall.kt.after | 2 +- .../casts/smartcastImpossible1.kt | 2 +- .../casts/smartcastImpossible1.kt.after | 2 +- .../casts/smartcastImpossible2.kt | 2 +- .../casts/smartcastImpossible2.kt.after | 2 +- .../typeMismatch/casts/typeMismatch3.kt | 2 +- .../typeMismatch/casts/typeMismatch3.kt.after | 4 +- ...eturnTypeWhenValueParameterListIsAbsent.kt | 6 +- ...ypeWhenValueParameterListIsAbsent.kt.after | 6 +- .../typeMismatch/compareToTypeMismatch.kt | 2 +- .../compareToTypeMismatch.kt.after | 2 +- .../componentFunctionReturnTypeMismatch1.kt | 4 +- ...ponentFunctionReturnTypeMismatch1.kt.after | 4 +- .../componentFunctionReturnTypeMismatch2.kt | 4 +- ...ponentFunctionReturnTypeMismatch2.kt.after | 4 +- .../componentFunctionReturnTypeMismatch3.kt | 4 +- ...ponentFunctionReturnTypeMismatch3.kt.after | 4 +- .../componentFunctionReturnTypeMismatch4.kt | 4 +- ...ponentFunctionReturnTypeMismatch4.kt.after | 4 +- .../componentFunctionReturnTypeMismatch5.kt | 6 +- ...ponentFunctionReturnTypeMismatch5.kt.after | 6 +- .../changeNotFunctionReturnType.kt | 4 +- .../changeNotFunctionReturnType.kt.after | 4 +- .../changePlusFunctionReturnType.kt | 2 +- .../changePlusFunctionReturnType.kt.after | 2 +- .../changeTimesFunctionParameterType.kt | 2 +- .../changeTimesFunctionParameterType.kt.after | 2 +- .../hasNextFunctionReturnTypeMismatch.kt | 6 +- ...hasNextFunctionReturnTypeMismatch.kt.after | 6 +- .../multiFakeOverrideForOperatorConvention.kt | 4 +- .../renameUnaryMinus/before/unaryMinus.kt | 4 +- .../rename/renameUnaryMinus/unaryMinus.test | 2 +- .../localCallables/multiDeclaration.kt | 2 +- .../calls/externalArgumentsRuntime.kt | 2 +- .../expressions/conventions/inc.kt | 2 +- .../expressions/conventions/infixCall.kt | 4 +- .../conventions/infixCall.kt.match | 4 +- .../intentions/IntentionTestGenerated.java | 48 ----- .../jps/build/AbstractLookupTrackerTest.kt | 2 +- .../lookupTracker/conventions/comparison.kt | 16 +- .../lookupTracker/conventions/declarations.kt | 42 ++-- .../conventions/delegateProperty.kt | 22 +-- .../conventions/mathematicalLike.kt | 26 +-- .../lookupTracker/conventions/other.kt | 14 +- .../inlineGet.kt | 2 +- .../inlineGet.kt.new.1 | 2 +- .../inlineSet.kt | 2 +- .../inlineSet.kt.new.2 | 2 +- .../inline.kt | 4 +- .../inline.kt.new.1 | 4 +- .../inline.kt.new.2 | 4 +- .../js/test/semantics/FunctionTest.java | 4 - .../test/semantics/InvokeConventionTest.java | 4 - .../property/cases/delegated.kt | 2 +- .../property/cases/delegatedMutable.kt | 4 +- .../property/cases/simpleExtension.kt | 2 +- .../property/cases/simpleMutableExtension.kt | 4 +- .../property/cases/simpleMutableMember.kt | 4 +- .../cases/delegateByExtensionProperty.kt | 4 +- .../cases/delegateByTopLevelFun.kt | 4 +- .../cases/delegateByTopLevelProperty.kt | 4 +- .../cases/delegateWithPropertyAccess.kt | 4 +- .../cases/getAsExtensionFun.kt | 2 +- .../cases/propertyMetadata.kt | 4 +- .../cases/setAsExtensionFun.kt | 4 +- .../testData/delegateProperty/cases/simple.kt | 4 +- .../delegateProperty/cases/topLevelVal.kt | 2 +- .../delegateProperty/cases/topLevelVar.kt | 4 +- .../delegateProperty/cases/withGenerics.kt | 4 +- .../delegationExtensionPropertyDelegated.kt | 4 +- .../testData/dynamic/cases/equals.kt | 5 - .../examples/cases/overloadBinaryOperator.kt | 2 +- .../cases/overloadPlusAssignReturn.kt | 2 +- .../cases/overloadPlusToPlusAssign.kt | 2 +- .../examples/cases/overloadUnaryOperator.kt | 4 +- .../compareTo/cases/customCompareToMethod.kt | 10 +- .../equals/cases/explicitEqualsMethod.kt | 10 +- .../explicitEqualsMethodForPrimitives.kt | 20 +- .../forIteratesOverSomethingWithIterator.kt | 6 +- ...deEffectImElementAccessAndWithEmptyBody.kt | 6 +- .../expression/function/cases/infixCall.kt | 19 -- .../cases/identityEqualsMethod.kt | 6 +- .../identityEqualsMethodForPrimitives.kt | 10 +- .../expression/invoke/cases/infixCall.kt | 22 --- .../invoke/cases/inheritFromFunctionTraits.kt | 8 +- .../expression/invoke/cases/invokeMethod.kt | 2 +- .../invoke/cases/invokeOnExprByConvention.kt | 4 +- .../cases/invokeWithDispatchReceiver.kt | 2 +- .../cases/invokeWithExtensionReceiver.kt | 2 +- .../expression/misc/cases/KT-1361-2.kt | 4 +- .../testData/expression/misc/cases/KT-2314.kt | 2 +- .../expression/misc/cases/KT-740-2.kt | 4 +- .../expression/misc/cases/KT-740-3.kt | 4 +- .../expression/misc/cases/intRange.kt | 6 +- .../cases/extensionFunctionCalledFromFor.kt | 6 +- .../inheritance/cases/overrideAnyMethods.kt | 2 +- .../testData/inline/cases/identityEquals.kt | 4 +- .../testData/inline/cases/multiDeclaration.kt | 4 +- .../cases/multiDeclaration.kt | 5 +- .../cases/multiDeclarationComplex.kt | 13 +- .../cases/builders/builders.2.kt | 4 +- .../buildersAndLambdaCapturing.2.kt | 4 +- .../inlineMultiFile/cases/with/with.2.kt | 2 +- .../cases/callableReference/lib/lib.kt | 2 +- .../cases/extensionLambda/lib/lib.kt | 2 +- .../inlineMultiModule/cases/lambda/lib/lib.kt | 2 +- .../lambdaCalledInObjectLiteral/lib/lib.kt | 2 +- .../cases/lambdaWithClosure/lib/lib.kt | 2 +- .../cases/localNameClash/lib/lib.kt | 2 +- .../cases/simpleReturnFunction.kt | 2 +- .../cases/multiValForArray.kt | 4 +- .../multideclaration/cases/multiValForMap.kt | 6 +- .../cases/multiValForRange.kt | 4 +- .../multideclaration/cases/multiValInFor.kt | 4 +- .../cases/multiValInIntFor.kt | 4 +- .../cases/multiValInIntRangeFor.kt | 4 +- .../multideclaration/cases/multiValOrVar.kt | 12 +- .../testData/native/cases/kt2323.kt | 4 +- .../cases/nativeGetterAndNativeSetter.kt | 8 +- .../testData/native/cases/nativeInvoke.kt | 4 +- .../testData/number/cases/numberCompareTo.kt | 186 +++++++++--------- .../cases/binaryDivOverload.kt | 2 +- .../operatorOverloading/cases/compareTo.kt | 2 +- .../cases/compareToByName.kt | 2 +- .../operatorOverloading/cases/notOverload.kt | 2 +- ...adOnPropertyCallGetterAndSetterOnlyOnce.kt | 2 +- .../cases/overloadPlusAssignArrayList.kt | 2 +- .../overloadPlusAssignViaExtensionFunction.kt | 2 +- ...rloadPlusAssignViaPlusExtensionFunction.kt | 4 +- .../cases/overloadPlusViaExtensionFunction.kt | 2 +- ...oadUnaryOperationsViaExtensionFunctions.kt | 4 +- .../cases/overloadedCallOnProperty.kt | 2 +- .../cases/plusAndMinusAsAnExpression.kt | 4 +- .../cases/plusAssignNoReassign.kt | 2 +- .../operatorOverloading/cases/plusOverload.kt | 2 +- .../operatorOverloading/cases/postfixInc.kt | 2 +- .../cases/postfixOnProperty.kt | 2 +- .../cases/prefixDecOverload.kt | 2 +- .../cases/prefixIncReturnsCorrectValue.kt | 2 +- .../cases/unaryOnIntProperty.kt | 2 +- .../cases/unaryOnIntPropertyAsStatement.kt | 2 +- .../usingModInCaseModAssignNotAvailable.kt | 2 +- .../testData/range/cases/intUpTo.kt | 2 +- .../range/cases/rangeToDoesNotIterate.kt | 2 +- .../reified/_commonFiles/isInstance.kt | 2 +- .../safeCall/cases/safeCallAndSideEffect.kt | 2 +- .../cases/Traffic light.kt | 8 +- .../testData/webDemoExamples2/cases/life.kt | 2 +- libraries/stdlib/test/MathTest.kt | 2 +- .../stdlib/test/collections/MapJVMTest.kt | 2 +- .../stdlib/test/concurrent/ThreadTest.kt | 2 +- libraries/stdlib/test/numbers/CoercionTest.kt | 20 +- libraries/tools/idl2k/src/main/kotlin/gen.kt | 15 +- libraries/tools/idl2k/src/main/kotlin/main.kt | 2 +- .../kotlin/gradle/plugin/KotlinPlugin.kt | 10 +- .../kotlin/js/qunit/SeleniumQUnit.kt | 2 +- .../src/main/kotlin/main/main.kt | 2 +- 635 files changed, 1283 insertions(+), 1617 deletions(-) delete mode 100644 compiler/testData/codegen/box/binaryOp/infixCall.kt delete mode 100644 compiler/testData/codegen/box/binaryOp/infixCallAny.kt delete mode 100644 compiler/testData/codegen/box/binaryOp/infixCallNullable.kt delete mode 100644 compiler/testData/codegen/box/innerNested/innerInfixCall.kt delete mode 100644 compiler/testData/codegen/box/intrinsics/compareTo.kt delete mode 100644 compiler/testData/codegen/box/intrinsics/infixCall.kt delete mode 100644 compiler/testData/codegen/box/regressions/kt3173.kt delete mode 100644 compiler/testData/codegen/box/regressions/kt3999.kt delete mode 100644 compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.java delete mode 100644 compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.kt delete mode 100644 compiler/testData/codegen/boxWithStdlib/evaluate/infixCallBinary.kt delete mode 100644 compiler/testData/codegen/bytecodeText/stringOperations/infixPlus.kt delete mode 100644 compiler/testData/resolveAnnotations/parameters/expressions/infixCallBinary.kt delete mode 100644 idea/testData/intentions/swapBinaryExpression/compareTo.kt delete mode 100644 idea/testData/intentions/swapBinaryExpression/divideLiteral.kt delete mode 100644 idea/testData/intentions/swapBinaryExpression/equalsLiteral.kt delete mode 100644 idea/testData/intentions/swapBinaryExpression/equalsLiteral.kt.after delete mode 100644 idea/testData/intentions/swapBinaryExpression/identityEqualsLiteral.kt delete mode 100644 idea/testData/intentions/swapBinaryExpression/identityEqualsLiteral.kt.after delete mode 100644 idea/testData/intentions/swapBinaryExpression/minusLiteral.kt delete mode 100644 idea/testData/intentions/swapBinaryExpression/plusLiteral.kt delete mode 100644 idea/testData/intentions/swapBinaryExpression/plusLiteral.kt.after delete mode 100644 idea/testData/intentions/swapBinaryExpression/rangeToLiteral.kt delete mode 100644 idea/testData/intentions/swapBinaryExpression/timesLiteral.kt delete mode 100644 idea/testData/intentions/swapBinaryExpression/timesLiteral.kt.after delete mode 100644 js/js.translator/testData/expression/function/cases/infixCall.kt delete mode 100644 js/js.translator/testData/expression/invoke/cases/infixCall.kt diff --git a/compiler/testData/codegen/box/arrays/collectionAssignGetMultiIndex.kt b/compiler/testData/codegen/box/arrays/collectionAssignGetMultiIndex.kt index dac0cc4ee79..2683bc64379 100644 --- a/compiler/testData/codegen/box/arrays/collectionAssignGetMultiIndex.kt +++ b/compiler/testData/codegen/box/arrays/collectionAssignGetMultiIndex.kt @@ -1,7 +1,7 @@ import java.util.ArrayList -fun ArrayList.get(index1: Int, index2: Int) = this[index1 + index2] -fun ArrayList.set(index1: Int, index2: Int, elem: String) { +operator fun ArrayList.get(index1: Int, index2: Int) = this[index1 + index2] +operator fun ArrayList.set(index1: Int, index2: Int, elem: String) { this[index1 + index2] = elem } diff --git a/compiler/testData/codegen/box/arrays/collectionGetMultiIndex.kt b/compiler/testData/codegen/box/arrays/collectionGetMultiIndex.kt index 33766188e6b..471574c442d 100644 --- a/compiler/testData/codegen/box/arrays/collectionGetMultiIndex.kt +++ b/compiler/testData/codegen/box/arrays/collectionGetMultiIndex.kt @@ -1,7 +1,7 @@ import java.util.ArrayList -fun ArrayList.get(index1: Int, index2: Int) = this[index1 + index2] -fun ArrayList.set(index1: Int, index2: Int, elem: String) { +operator fun ArrayList.get(index1: Int, index2: Int) = this[index1 + index2] +operator fun ArrayList.set(index1: Int, index2: Int, elem: String) { this[index1 + index2] = elem } diff --git a/compiler/testData/codegen/box/arrays/hashMap.kt b/compiler/testData/codegen/box/arrays/hashMap.kt index 9c344c50d00..cfc6843a144 100644 --- a/compiler/testData/codegen/box/arrays/hashMap.kt +++ b/compiler/testData/codegen/box/arrays/hashMap.kt @@ -1,6 +1,6 @@ import java.util.HashMap -fun HashMap.set(index: String, elem: Int?) { +operator fun HashMap.set(index: String, elem: Int?) { this.put(index, elem) } diff --git a/compiler/testData/codegen/box/arrays/kt238.kt b/compiler/testData/codegen/box/arrays/kt238.kt index a3b6a6f4719..71c935d5c9d 100644 --- a/compiler/testData/codegen/box/arrays/kt238.kt +++ b/compiler/testData/codegen/box/arrays/kt238.kt @@ -43,16 +43,16 @@ fun box() : String { } class StrangeArray(size: Int, private var defaultValue: T) { - fun get(index: Int): T = defaultValue - fun set(index: Int, v: T) { + operator fun get(index: Int): T = defaultValue + operator fun set(index: Int, v: T) { defaultValue = v } } class StrangeIntArray(size: Int) { private var defaultValue = 0 - fun get(index: Int): Int = defaultValue - fun set(index: Int, v: Int) { + operator fun get(index: Int): Int = defaultValue + operator fun set(index: Int, v: Int) { defaultValue = v } } diff --git a/compiler/testData/codegen/box/arrays/kt4348.kt b/compiler/testData/codegen/box/arrays/kt4348.kt index 8952fd00a70..4ea639148ca 100644 --- a/compiler/testData/codegen/box/arrays/kt4348.kt +++ b/compiler/testData/codegen/box/arrays/kt4348.kt @@ -1,8 +1,8 @@ -fun String.get(vararg value: Any) : String { +operator fun String.get(vararg value: Any) : String { return if (value[0] == 44 && value[1] == "example") "OK" else "fail" } -fun Int.get(vararg value: Any) : Int { +operator fun Int.get(vararg value: Any) : Int { return if (value[0] == 44 && value[1] == "example") 1 else 0 } fun main(args: Array) { diff --git a/compiler/testData/codegen/box/arrays/kt950.kt b/compiler/testData/codegen/box/arrays/kt950.kt index adb6c062f11..aa8a03ce3c5 100644 --- a/compiler/testData/codegen/box/arrays/kt950.kt +++ b/compiler/testData/codegen/box/arrays/kt950.kt @@ -1,6 +1,6 @@ import java.util.* -fun MutableMap.set(k : K, v : V) = put(k, v) +operator fun MutableMap.set(k : K, v : V) = put(k, v) fun box() : String { val map = HashMap() diff --git a/compiler/testData/codegen/box/arrays/longAsIndex.kt b/compiler/testData/codegen/box/arrays/longAsIndex.kt index 1d815615d16..c12d4dca9a4 100644 --- a/compiler/testData/codegen/box/arrays/longAsIndex.kt +++ b/compiler/testData/codegen/box/arrays/longAsIndex.kt @@ -1,5 +1,5 @@ -fun IntArray.set(index: Long, elem: Int) { this[index.toInt()] = elem } -fun IntArray.get(index: Long) = this[index.toInt()] +operator fun IntArray.set(index: Long, elem: Int) { this[index.toInt()] = elem } +operator fun IntArray.get(index: Long) = this[index.toInt()] fun box(): String { var l = IntArray(1) diff --git a/compiler/testData/codegen/box/binaryOp/infixCall.kt b/compiler/testData/codegen/box/binaryOp/infixCall.kt deleted file mode 100644 index 76c0d070d01..00000000000 --- a/compiler/testData/codegen/box/binaryOp/infixCall.kt +++ /dev/null @@ -1,21 +0,0 @@ -fun box(): String { - val a1: Byte = 1 plus 1 - val a2: Short = 1 plus 1 - val a3: Int = 1 plus 1 - val a4: Long = 1 plus 1 - val a5: Double = 1.0 plus 1 - val a6: Float = 1f plus 1 - val a7: Char = 'A' plus 1 - val a8: Int = 'B' minus 'A' - - if (a1 != 2.toByte()) return "fail 1" - if (a2 != 2.toShort()) return "fail 2" - if (a3 != 2) return "fail 3" - if (a4 != 2L) return "fail 4" - if (a5 != 2.0) return "fail 5" - if (a6 != 2f) return "fail 6" - if (a7 != 'B') return "fail 7" - if (a8 != 1) return "fail 8" - - return "OK" -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/binaryOp/infixCallAny.kt b/compiler/testData/codegen/box/binaryOp/infixCallAny.kt deleted file mode 100644 index 6056e74e00e..00000000000 --- a/compiler/testData/codegen/box/binaryOp/infixCallAny.kt +++ /dev/null @@ -1,21 +0,0 @@ -fun box(): String { - val a1: Any = 1.toByte() plus 1 - val a2: Any = 1.toShort() plus 1 - val a3: Any = 1 plus 1 - val a4: Any = 1L plus 1 - val a5: Any = 1.0 plus 1 - val a6: Any = 1f plus 1 - val a7: Any = 'A' plus 1 - val a8: Any = 'B' minus 'A' - - if (a1 !is Int || a1 != 2) return "fail 1" - if (a2 !is Int || a2 != 2) return "fail 2" - if (a3 !is Int || a3 != 2) return "fail 3" - if (a4 !is Long || a4 != 2L) return "fail 4" - if (a5 !is Double || a5 != 2.0) return "fail 5" - if (a6 !is Float || a6 != 2f) return "fail 6" - if (a7 !is Char || a7 != 'B') return "fail 7" - if (a8 !is Int || a8 != 1) return "fail 8" - - return "OK" -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/binaryOp/infixCallNullable.kt b/compiler/testData/codegen/box/binaryOp/infixCallNullable.kt deleted file mode 100644 index 9fbd75a5c27..00000000000 --- a/compiler/testData/codegen/box/binaryOp/infixCallNullable.kt +++ /dev/null @@ -1,21 +0,0 @@ -fun box(): String { - val a1: Byte? = 1 plus 1 - val a2: Short? = 1 plus 1 - val a3: Int? = 1 plus 1 - val a4: Long? = 1 plus 1 - val a5: Double? = 1.0 plus 1 - val a6: Float? = 1f plus 1 - val a7: Char? = 'A' plus 1 - val a8: Int? = 'B' minus 'A' - - if (a1!! != 2.toByte()) return "fail 1" - if (a2!! != 2.toShort()) return "fail 2" - if (a3!! != 2) return "fail 3" - if (a4!! != 2L) return "fail 4" - if (a5!! != 2.0) return "fail 5" - if (a6!! != 2f) return "fail 6" - if (a7!! != 'B') return "fail 7" - if (a8!! != 1) return "fail 8" - - return "OK" -} diff --git a/compiler/testData/codegen/box/casts/as.kt b/compiler/testData/codegen/box/casts/as.kt index 7392e121bbe..93f47e7c68c 100644 --- a/compiler/testData/codegen/box/casts/as.kt +++ b/compiler/testData/codegen/box/casts/as.kt @@ -4,5 +4,5 @@ fun box(): String { val r = object : Runnable { override fun run() {} } - return if (foo(r) identityEquals r) "OK" else "Fail" + return if (foo(r).identityEquals(r)) "OK" else "Fail" } diff --git a/compiler/testData/codegen/box/casts/asSafe.kt b/compiler/testData/codegen/box/casts/asSafe.kt index 348925891c7..530877735b9 100644 --- a/compiler/testData/codegen/box/casts/asSafe.kt +++ b/compiler/testData/codegen/box/casts/asSafe.kt @@ -4,5 +4,5 @@ fun box(): String { val r = object : Runnable { override fun run() {} } - return if (foo(r) identityEquals r) "OK" else "Fail" + return if (foo(r).identityEquals(r)) "OK" else "Fail" } diff --git a/compiler/testData/codegen/box/classes/kt1891.kt b/compiler/testData/codegen/box/classes/kt1891.kt index ead834aedfd..e9183589db3 100644 --- a/compiler/testData/codegen/box/classes/kt1891.kt +++ b/compiler/testData/codegen/box/classes/kt1891.kt @@ -1,9 +1,9 @@ class MyList() { var value: T? = null - fun get(index: Int): T = value!! + operator fun get(index: Int): T = value!! - fun set(index: Int, value: T) { this.value = value } + operator fun set(index: Int, value: T) { this.value = value } } fun box(): String { diff --git a/compiler/testData/codegen/box/classes/kt2711.kt b/compiler/testData/codegen/box/classes/kt2711.kt index e6cddd8b42f..409537ae567 100644 --- a/compiler/testData/codegen/box/classes/kt2711.kt +++ b/compiler/testData/codegen/box/classes/kt2711.kt @@ -1,9 +1,9 @@ class IntRange { - fun contains(a: Int) = (1..2).contains(a) + operator fun contains(a: Int) = (1..2).contains(a) } class C() { - fun rangeTo(i: Int) = IntRange() + operator fun rangeTo(i: Int) = IntRange() } diff --git a/compiler/testData/codegen/box/classes/kt504.kt b/compiler/testData/codegen/box/classes/kt504.kt index 1a634bcf793..da261142cb7 100644 --- a/compiler/testData/codegen/box/classes/kt504.kt +++ b/compiler/testData/codegen/box/classes/kt504.kt @@ -1,7 +1,7 @@ import java.util.HashMap import java.io.* -fun MutableMap.set(key : K, value : V) = put(key, value) +operator fun MutableMap.set(key : K, value : V) = put(key, value) fun box() : String { diff --git a/compiler/testData/codegen/box/classes/kt723.kt b/compiler/testData/codegen/box/classes/kt723.kt index 10198d070bf..6d020a0bc99 100644 --- a/compiler/testData/codegen/box/classes/kt723.kt +++ b/compiler/testData/codegen/box/classes/kt723.kt @@ -1,4 +1,4 @@ -fun Int?.inc() : Int { if (this != null) return this.inc() else throw NullPointerException() } +operator fun Int?.inc() : Int { if (this != null) return this.inc() else throw NullPointerException() } public fun box() : String { var i : Int? = 10 diff --git a/compiler/testData/codegen/box/classes/kt725.kt b/compiler/testData/codegen/box/classes/kt725.kt index 3a0bc425693..3aea020f890 100644 --- a/compiler/testData/codegen/box/classes/kt725.kt +++ b/compiler/testData/codegen/box/classes/kt725.kt @@ -1,4 +1,4 @@ -fun Int?.inc() = this!!.inc() +operator fun Int?.inc() = this!!.inc() public fun box() : String { var i : Int? = 10 diff --git a/compiler/testData/codegen/box/classes/kt903.kt b/compiler/testData/codegen/box/classes/kt903.kt index e80afe38dca..58e6e5e53e5 100644 --- a/compiler/testData/codegen/box/classes/kt903.kt +++ b/compiler/testData/codegen/box/classes/kt903.kt @@ -1,6 +1,6 @@ import java.util.ArrayList -fun Int.plus(a: Int?) = this + a!! +operator fun Int.plus(a: Int?) = this + a!! public open class PerfectNumberFinder() { open public fun isPerfect(number : Int) : Boolean { diff --git a/compiler/testData/codegen/box/classes/overloadBinaryOperator.kt b/compiler/testData/codegen/box/classes/overloadBinaryOperator.kt index 4432afe92ec..551d1cd67ca 100644 --- a/compiler/testData/codegen/box/classes/overloadBinaryOperator.kt +++ b/compiler/testData/codegen/box/classes/overloadBinaryOperator.kt @@ -7,7 +7,7 @@ class ArrayWrapper() { contents.add(item) } - fun plus(b: ArrayWrapper): ArrayWrapper { + operator fun plus(b: ArrayWrapper): ArrayWrapper { val result = ArrayWrapper() result.contents.addAll(contents) result.contents.addAll(b.contents) diff --git a/compiler/testData/codegen/box/classes/overloadPlusAssign.kt b/compiler/testData/codegen/box/classes/overloadPlusAssign.kt index 528a3e88704..b37640eac0c 100644 --- a/compiler/testData/codegen/box/classes/overloadPlusAssign.kt +++ b/compiler/testData/codegen/box/classes/overloadPlusAssign.kt @@ -7,11 +7,11 @@ class ArrayWrapper() { contents.add(item) } - fun plusAssign(rhs: ArrayWrapper) { + operator fun plusAssign(rhs: ArrayWrapper) { contents.addAll(rhs.contents) } - fun get(index: Int): T { + operator fun get(index: Int): T { return contents.get(index)!! } } diff --git a/compiler/testData/codegen/box/classes/overloadPlusAssignReturn.kt b/compiler/testData/codegen/box/classes/overloadPlusAssignReturn.kt index 0419b444049..48368b15dfb 100644 --- a/compiler/testData/codegen/box/classes/overloadPlusAssignReturn.kt +++ b/compiler/testData/codegen/box/classes/overloadPlusAssignReturn.kt @@ -7,14 +7,14 @@ class ArrayWrapper() { contents.add(item) } - fun plus(rhs: ArrayWrapper): ArrayWrapper { + operator fun plus(rhs: ArrayWrapper): ArrayWrapper { val result = ArrayWrapper() result.contents.addAll(contents) result.contents.addAll(rhs.contents) return result } - fun get(index: Int): T { + operator fun get(index: Int): T { return contents.get(index)!! } } diff --git a/compiler/testData/codegen/box/classes/overloadPlusToPlusAssign.kt b/compiler/testData/codegen/box/classes/overloadPlusToPlusAssign.kt index 0419b444049..48368b15dfb 100644 --- a/compiler/testData/codegen/box/classes/overloadPlusToPlusAssign.kt +++ b/compiler/testData/codegen/box/classes/overloadPlusToPlusAssign.kt @@ -7,14 +7,14 @@ class ArrayWrapper() { contents.add(item) } - fun plus(rhs: ArrayWrapper): ArrayWrapper { + operator fun plus(rhs: ArrayWrapper): ArrayWrapper { val result = ArrayWrapper() result.contents.addAll(contents) result.contents.addAll(rhs.contents) return result } - fun get(index: Int): T { + operator fun get(index: Int): T { return contents.get(index)!! } } diff --git a/compiler/testData/codegen/box/classes/overloadUnaryOperator.kt b/compiler/testData/codegen/box/classes/overloadUnaryOperator.kt index 79197f3600b..1ff10d69216 100644 --- a/compiler/testData/codegen/box/classes/overloadUnaryOperator.kt +++ b/compiler/testData/codegen/box/classes/overloadUnaryOperator.kt @@ -7,14 +7,14 @@ class ArrayWrapper() { contents.add(item) } - fun minus(): ArrayWrapper { + operator fun unaryMinus(): ArrayWrapper { val result = ArrayWrapper() result.contents.addAll(contents) Collections.reverse(result.contents) return result } - fun get(index: Int): T { + operator fun get(index: Int): T { return contents.get(index)!! } } diff --git a/compiler/testData/codegen/box/closures/kt4137.kt b/compiler/testData/codegen/box/closures/kt4137.kt index d438c28788f..ea401a6fe80 100644 --- a/compiler/testData/codegen/box/closures/kt4137.kt +++ b/compiler/testData/codegen/box/closures/kt4137.kt @@ -2,7 +2,7 @@ open class A(val s: Int) { } -fun Int.foo(s: Int): Int { +infix fun Int.foo(s: Int): Int { return this + s } diff --git a/compiler/testData/codegen/box/controlStructures/emptyFor.kt b/compiler/testData/codegen/box/controlStructures/emptyFor.kt index e39e3997923..6a09c1b3b43 100644 --- a/compiler/testData/codegen/box/controlStructures/emptyFor.kt +++ b/compiler/testData/codegen/box/controlStructures/emptyFor.kt @@ -1,7 +1,7 @@ var index = 0 interface IterableIterator : Iterator { - fun iterator(): Iterator = this + operator fun iterator(): Iterator = this } val iterator = object : IterableIterator { diff --git a/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionAll.kt b/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionAll.kt index 95b87de7b86..bd701f507a2 100644 --- a/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionAll.kt +++ b/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionAll.kt @@ -6,9 +6,9 @@ class C { class X { var hasNext = true - fun It.hasNext() = if (hasNext) {hasNext = false; true} else false - fun It.next() = 5 - fun C.iterator(): It = It() + operator fun It.hasNext() = if (hasNext) {hasNext = false; true} else false + operator fun It.next() = 5 + operator fun C.iterator(): It = It() fun test() { for (i in C()) { diff --git a/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionHasNext.kt b/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionHasNext.kt index c51b317da02..fd0e52ec3f8 100644 --- a/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionHasNext.kt +++ b/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionHasNext.kt @@ -1,14 +1,14 @@ class It { - fun next() = 5 + operator fun next() = 5 } class C { - fun iterator(): It = It() + operator fun iterator(): It = It() } class X { var hasNext = true - fun It.hasNext() = if (hasNext) {hasNext = false; true} else false + operator fun It.hasNext() = if (hasNext) {hasNext = false; true} else false fun test() { for (i in C()) { diff --git a/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionNext.kt b/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionNext.kt index 1987d8f7936..29415f77a79 100644 --- a/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionNext.kt +++ b/compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionNext.kt @@ -1,14 +1,14 @@ class It { var hasNext = true - fun hasNext() = if (hasNext) {hasNext = false; true} else false + operator fun hasNext() = if (hasNext) {hasNext = false; true} else false } class C { - fun iterator(): It = It() + operator fun iterator(): It = It() } class X { - fun It.next() = 5 + operator fun It.next() = 5 fun test() { for (i in C()) { diff --git a/compiler/testData/codegen/box/controlStructures/forUserType.kt b/compiler/testData/codegen/box/controlStructures/forUserType.kt index aff6e3ad88d..54f53159f95 100644 --- a/compiler/testData/codegen/box/controlStructures/forUserType.kt +++ b/compiler/testData/codegen/box/controlStructures/forUserType.kt @@ -92,23 +92,23 @@ class MyCollection2(): Iterable { } class MyCollection3() { - fun iterator() = MyIterator() + operator fun iterator() = MyIterator() class MyIterator() { var k : Int = 5 - fun next() : Int? = k-- - fun hasNext() : Boolean = k > 0 + operator fun next() : Int? = k-- + operator fun hasNext() : Boolean = k > 0 } } class MyCollection4() { - fun iterator() = MyIterator() + operator fun iterator() = MyIterator() class MyIterator() { var k : Int = 5 - fun next() : Int = k-- - fun hasNext() = k > 0 + operator fun next() : Int = k-- + operator fun hasNext() = k > 0 } } diff --git a/compiler/testData/codegen/box/controlStructures/inRangeConditionsInWhen.kt b/compiler/testData/codegen/box/controlStructures/inRangeConditionsInWhen.kt index edc2a762d9d..09f2faa5557 100644 --- a/compiler/testData/codegen/box/controlStructures/inRangeConditionsInWhen.kt +++ b/compiler/testData/codegen/box/controlStructures/inRangeConditionsInWhen.kt @@ -1,4 +1,4 @@ -fun Int.contains(i : Int) = true +operator fun Int.contains(i : Int) = true fun box(): String { when (1) { diff --git a/compiler/testData/codegen/box/controlStructures/kt299.kt b/compiler/testData/codegen/box/controlStructures/kt299.kt index 677ca49025a..d96a0551680 100644 --- a/compiler/testData/codegen/box/controlStructures/kt299.kt +++ b/compiler/testData/codegen/box/controlStructures/kt299.kt @@ -7,7 +7,7 @@ class MyRange1() : Range { } class MyRange2() { - fun contains(item: Int) = true + operator fun contains(item: Int) = true } fun box(): String { diff --git a/compiler/testData/codegen/box/controlStructures/kt513.kt b/compiler/testData/codegen/box/controlStructures/kt513.kt index 9f463f327d4..6e0516a325e 100644 --- a/compiler/testData/codegen/box/controlStructures/kt513.kt +++ b/compiler/testData/codegen/box/controlStructures/kt513.kt @@ -1,7 +1,7 @@ import java.util.* class A() { - fun ArrayList.add3(el: T) = add(el) + infix fun ArrayList.add3(el: T) = add(el) fun test(list: ArrayList) { for (i in 1..10) { @@ -10,12 +10,12 @@ class A() { } } -fun ArrayList.add2(el: T) = add(el) +infix fun ArrayList.add2(el: T) = add(el) fun box() : String{ var list = ArrayList() for (i in 1..10) { - list add i + list.add(i) list add2 i } A().test(list) diff --git a/compiler/testData/codegen/box/controlStructures/kt628.kt b/compiler/testData/codegen/box/controlStructures/kt628.kt index c801c62fbaf..234e336e5a7 100644 --- a/compiler/testData/codegen/box/controlStructures/kt628.kt +++ b/compiler/testData/codegen/box/controlStructures/kt628.kt @@ -1,7 +1,7 @@ class A() { fun action() = "OK" - fun infix(a: String) = "O" + a + infix fun infix(a: String) = "O" + a val property = "OK" diff --git a/compiler/testData/codegen/box/defaultArguments/function/augmentedAssignment.kt b/compiler/testData/codegen/box/defaultArguments/function/augmentedAssignment.kt index e7ca1f76678..f6da5e4f385 100644 --- a/compiler/testData/codegen/box/defaultArguments/function/augmentedAssignment.kt +++ b/compiler/testData/codegen/box/defaultArguments/function/augmentedAssignment.kt @@ -2,7 +2,7 @@ var result = "Fail" class A -fun A.plusAssign(a: A, s: String = "OK") { +operator fun A.plusAssign(a: A, s: String = "OK") { result = s } diff --git a/compiler/testData/codegen/box/defaultArguments/function/augmentedAssignmentViaBinaryExpression.kt b/compiler/testData/codegen/box/defaultArguments/function/augmentedAssignmentViaBinaryExpression.kt index 98e53dc3d14..42b2de54467 100644 --- a/compiler/testData/codegen/box/defaultArguments/function/augmentedAssignmentViaBinaryExpression.kt +++ b/compiler/testData/codegen/box/defaultArguments/function/augmentedAssignmentViaBinaryExpression.kt @@ -2,7 +2,7 @@ var result = "Fail" class A -fun A.plus(a: A, s: String = "OK"): A { +operator fun A.plus(a: A, s: String = "OK"): A { result = s return this } diff --git a/compiler/testData/codegen/box/defaultArguments/function/binaryCall.kt b/compiler/testData/codegen/box/defaultArguments/function/binaryCall.kt index f134ad32173..32b905ceddb 100644 --- a/compiler/testData/codegen/box/defaultArguments/function/binaryCall.kt +++ b/compiler/testData/codegen/box/defaultArguments/function/binaryCall.kt @@ -1,3 +1,3 @@ -fun Int.foo(o: String, k: String = "K") = o + k +infix fun Int.foo(o: String, k: String = "K") = o + k fun box() = 42 foo "O" diff --git a/compiler/testData/codegen/box/defaultArguments/function/binaryExpression.kt b/compiler/testData/codegen/box/defaultArguments/function/binaryExpression.kt index b6f36740e89..695c674d29c 100644 --- a/compiler/testData/codegen/box/defaultArguments/function/binaryExpression.kt +++ b/compiler/testData/codegen/box/defaultArguments/function/binaryExpression.kt @@ -1,5 +1,5 @@ class A -fun A.plus(i: A, ok: String = "OK") = ok +operator fun A.plus(i: A, ok: String = "OK") = ok fun box() = A() + A() diff --git a/compiler/testData/codegen/box/defaultArguments/function/contains.kt b/compiler/testData/codegen/box/defaultArguments/function/contains.kt index 42d089e40fb..287991e0e56 100644 --- a/compiler/testData/codegen/box/defaultArguments/function/contains.kt +++ b/compiler/testData/codegen/box/defaultArguments/function/contains.kt @@ -1,5 +1,5 @@ class A -fun A.contains(i: A, actual: Boolean = true) = actual +operator fun A.contains(i: A, actual: Boolean = true) = actual fun box() = if (A() in A()) "OK" else "Fail" diff --git a/compiler/testData/codegen/box/delegatedProperty/accessTopLevelDelegatedPropertyInClinit.kt b/compiler/testData/codegen/box/delegatedProperty/accessTopLevelDelegatedPropertyInClinit.kt index 60f3eb0b05f..b409bd753ab 100644 --- a/compiler/testData/codegen/box/delegatedProperty/accessTopLevelDelegatedPropertyInClinit.kt +++ b/compiler/testData/codegen/box/delegatedProperty/accessTopLevelDelegatedPropertyInClinit.kt @@ -3,7 +3,7 @@ import kotlin.reflect.KProperty // KT-5612 class Delegate { - public fun getValue(thisRef: Any?, prop: KProperty<*>): String { + operator fun getValue(thisRef: Any?, prop: KProperty<*>): String { return "OK" } } diff --git a/compiler/testData/codegen/box/delegatedProperty/capturePropertyInClosure.kt b/compiler/testData/codegen/box/delegatedProperty/capturePropertyInClosure.kt index ff7b8bf939e..3c03bc94ca8 100644 --- a/compiler/testData/codegen/box/delegatedProperty/capturePropertyInClosure.kt +++ b/compiler/testData/codegen/box/delegatedProperty/capturePropertyInClosure.kt @@ -2,8 +2,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } class B { diff --git a/compiler/testData/codegen/box/delegatedProperty/castGetReturnType.kt b/compiler/testData/codegen/box/delegatedProperty/castGetReturnType.kt index c1e78edb560..cc106890792 100644 --- a/compiler/testData/codegen/box/delegatedProperty/castGetReturnType.kt +++ b/compiler/testData/codegen/box/delegatedProperty/castGetReturnType.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class Delegate { - fun getValue(t: Any?, p: KProperty<*>): Int = 1 + operator fun getValue(t: Any?, p: KProperty<*>): Int = 1 } class AImpl { diff --git a/compiler/testData/codegen/box/delegatedProperty/castSetParameter.kt b/compiler/testData/codegen/box/delegatedProperty/castSetParameter.kt index 93d271bd903..3d3e7a7806a 100644 --- a/compiler/testData/codegen/box/delegatedProperty/castSetParameter.kt +++ b/compiler/testData/codegen/box/delegatedProperty/castSetParameter.kt @@ -2,11 +2,11 @@ import kotlin.reflect.KProperty class Delegate { var inner = Derived() - fun getValue(t: Any?, p: KProperty<*>): Derived { + operator fun getValue(t: Any?, p: KProperty<*>): Derived { inner = Derived(inner.a + "-get") return inner } - fun setValue(t: Any?, p: KProperty<*>, i: Base) { inner = Derived(inner.a + "-" + i.a + "-set") } + operator fun setValue(t: Any?, p: KProperty<*>, i: Base) { inner = Derived(inner.a + "-" + i.a + "-set") } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/defaultArgs.kt b/compiler/testData/codegen/box/delegatedProperty/defaultArgs.kt index dd06f6bbe9a..3f258938abf 100644 --- a/compiler/testData/codegen/box/delegatedProperty/defaultArgs.kt +++ b/compiler/testData/codegen/box/delegatedProperty/defaultArgs.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class Delegate { - fun getValue(t: Any?, p: KProperty<*>, s: String = ""): Int = 1 + operator fun getValue(t: Any?, p: KProperty<*>, s: String = ""): Int = 1 } val prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateAsInnerClass.kt b/compiler/testData/codegen/box/delegatedProperty/delegateAsInnerClass.kt index 20e0e2ac60e..9b503ccce83 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateAsInnerClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateAsInnerClass.kt @@ -5,8 +5,8 @@ class A { class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } } diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateByOtherProperty.kt b/compiler/testData/codegen/box/delegatedProperty/delegateByOtherProperty.kt index c974b3957fa..7ec7f0c9151 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateByOtherProperty.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateByOtherProperty.kt @@ -2,8 +2,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelFun.kt b/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelFun.kt index b113719bf59..5900d71c985 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelFun.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelFun.kt @@ -2,8 +2,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } fun foo() = Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelProperty.kt b/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelProperty.kt index bd498bbe028..22f7b1b2ed3 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelProperty.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelProperty.kt @@ -2,8 +2,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } val p = Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateForExtProperty.kt b/compiler/testData/codegen/box/delegatedProperty/delegateForExtProperty.kt index 80265c007d1..4eac9e2dc73 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateForExtProperty.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateForExtProperty.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class Delegate { - fun getValue(t: A, p: KProperty<*>): Int = 1 + operator fun getValue(t: A, p: KProperty<*>): Int = 1 } val A.prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt b/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt index 0ef38849d9d..7cdaca652eb 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class Delegate { - fun getValue(t: F.A, p: KProperty<*>): Int = 1 + operator fun getValue(t: F.A, p: KProperty<*>): Int = 1 } class F { diff --git a/compiler/testData/codegen/box/delegatedProperty/genericDelegate.kt b/compiler/testData/codegen/box/delegatedProperty/genericDelegate.kt index 50955394f65..f1072a6c339 100644 --- a/compiler/testData/codegen/box/delegatedProperty/genericDelegate.kt +++ b/compiler/testData/codegen/box/delegatedProperty/genericDelegate.kt @@ -1,8 +1,8 @@ import kotlin.reflect.KProperty class Delegate(var inner: T) { - fun getValue(t: Any?, p: KProperty<*>): T = inner - fun setValue(t: Any?, p: KProperty<*>, i: T) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): T = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: T) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt b/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt index 08d2ac986c8..c08af8aeca2 100644 --- a/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt +++ b/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt @@ -3,7 +3,7 @@ import kotlin.reflect.KProperty class Delegate { } -fun Delegate.getValue(t: Any?, p: KProperty<*>): Int = 1 +operator fun Delegate.getValue(t: Any?, p: KProperty<*>): Int = 1 class A { val prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFunInClass.kt b/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFunInClass.kt index 2d714cede7d..653c844066e 100644 --- a/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFunInClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFunInClass.kt @@ -4,7 +4,7 @@ class Delegate { } class A { - fun Delegate.getValue(t: Any?, p: KProperty<*>): Int = 1 + operator fun Delegate.getValue(t: Any?, p: KProperty<*>): Int = 1 val prop: Int by Delegate() } diff --git a/compiler/testData/codegen/box/delegatedProperty/inClassVal.kt b/compiler/testData/codegen/box/delegatedProperty/inClassVal.kt index 44d732f474f..0878fe18868 100644 --- a/compiler/testData/codegen/box/delegatedProperty/inClassVal.kt +++ b/compiler/testData/codegen/box/delegatedProperty/inClassVal.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class Delegate { - fun getValue(t: Any?, p: KProperty<*>): Int = 1 + operator fun getValue(t: Any?, p: KProperty<*>): Int = 1 } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/inClassVar.kt b/compiler/testData/codegen/box/delegatedProperty/inClassVar.kt index 48010fd7329..4541763a721 100644 --- a/compiler/testData/codegen/box/delegatedProperty/inClassVar.kt +++ b/compiler/testData/codegen/box/delegatedProperty/inClassVar.kt @@ -2,8 +2,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/inTrait.kt b/compiler/testData/codegen/box/delegatedProperty/inTrait.kt index 58787c02eff..10a1746e561 100644 --- a/compiler/testData/codegen/box/delegatedProperty/inTrait.kt +++ b/compiler/testData/codegen/box/delegatedProperty/inTrait.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class Delegate { - fun getValue(t: Any?, p: KProperty<*>): Int = 1 + operator fun getValue(t: Any?, p: KProperty<*>): Int = 1 } interface A { diff --git a/compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt b/compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt index b8842733341..50d8ad91411 100644 --- a/compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt +++ b/compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt @@ -1,8 +1,8 @@ import kotlin.reflect.KProperty class Delegate(var inner: T) { - fun getValue(t: Any?, p: KProperty<*>): T = inner - fun setValue(t: Any?, p: KProperty<*>, i: T) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): T = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: T) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/kt4138.kt b/compiler/testData/codegen/box/delegatedProperty/kt4138.kt index ff13ac6ea22..f4535dd82e7 100644 --- a/compiler/testData/codegen/box/delegatedProperty/kt4138.kt +++ b/compiler/testData/codegen/box/delegatedProperty/kt4138.kt @@ -1,8 +1,8 @@ import kotlin.reflect.KProperty class Delegate(var inner: T) { - fun getValue(t: Any?, p: KProperty<*>): T = inner - fun setValue(t: Any?, p: KProperty<*>, i: T) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): T = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: T) { inner = i } } diff --git a/compiler/testData/codegen/box/delegatedProperty/privateVar.kt b/compiler/testData/codegen/box/delegatedProperty/privateVar.kt index e9be079ae79..33faef3e3b1 100644 --- a/compiler/testData/codegen/box/delegatedProperty/privateVar.kt +++ b/compiler/testData/codegen/box/delegatedProperty/privateVar.kt @@ -2,8 +2,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/propertyMetadataShouldBeCached.kt b/compiler/testData/codegen/box/delegatedProperty/propertyMetadataShouldBeCached.kt index f0d15c42425..a7c2ba23a9a 100644 --- a/compiler/testData/codegen/box/delegatedProperty/propertyMetadataShouldBeCached.kt +++ b/compiler/testData/codegen/box/delegatedProperty/propertyMetadataShouldBeCached.kt @@ -18,18 +18,18 @@ val metadatas = IdentityHashMap, Unit>() fun record(p: KProperty<*>) = metadatas.put(p, Unit) object IntHandler { - fun getValue(t: Any?, p: KProperty<*>): Int { record(p); return 42 } - fun setValue(t: Any?, p: KProperty<*>, value: Int) { record(p) } + operator fun getValue(t: Any?, p: KProperty<*>): Int { record(p); return 42 } + operator fun setValue(t: Any?, p: KProperty<*>, value: Int) { record(p) } } object AnyHandler { - fun getValue(t: Any?, p: KProperty<*>): Any? { record(p); return 3.14 } - fun setValue(t: Any?, p: KProperty<*>, value: Any?) { record(p) } + operator fun getValue(t: Any?, p: KProperty<*>): Any? { record(p); return 3.14 } + operator fun setValue(t: Any?, p: KProperty<*>, value: Any?) { record(p) } } object StringHandler { - fun getValue(t: Any?, p: KProperty<*>): String { record(p); return p.name } - fun setValue(t: Any?, p: KProperty<*>, value: String) { record(p) } + operator fun getValue(t: Any?, p: KProperty<*>): String { record(p); return p.name } + operator fun setValue(t: Any?, p: KProperty<*>, value: String) { record(p) } } fun box(): String { diff --git a/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt b/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt index 33d0bbbe168..69924d135ff 100644 --- a/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt +++ b/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt @@ -2,10 +2,10 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner } -fun Delegate.setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } +operator fun Delegate.setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } class A { var prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFunInClass.kt b/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFunInClass.kt index 2dee3b1b6ff..ef2ddccf0f6 100644 --- a/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFunInClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFunInClass.kt @@ -2,11 +2,11 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner } class A { - fun Delegate.setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } + operator fun Delegate.setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } var prop: Int by Delegate() } diff --git a/compiler/testData/codegen/box/delegatedProperty/topLevelVal.kt b/compiler/testData/codegen/box/delegatedProperty/topLevelVal.kt index ee0535cb774..e28913fabbe 100644 --- a/compiler/testData/codegen/box/delegatedProperty/topLevelVal.kt +++ b/compiler/testData/codegen/box/delegatedProperty/topLevelVal.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class Delegate { - fun getValue(t: Any?, p: KProperty<*>): Int = 1 + operator fun getValue(t: Any?, p: KProperty<*>): Int = 1 } val prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/topLevelVar.kt b/compiler/testData/codegen/box/delegatedProperty/topLevelVar.kt index e4bbea617a1..688405e32de 100644 --- a/compiler/testData/codegen/box/delegatedProperty/topLevelVar.kt +++ b/compiler/testData/codegen/box/delegatedProperty/topLevelVar.kt @@ -2,8 +2,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } var prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt b/compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt index f130f96d06b..d73aadaf604 100644 --- a/compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt +++ b/compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class Delegate(val f: (T) -> Int) { - fun getValue(t: T, p: KProperty<*>): Int = f(t) + operator fun getValue(t: T, p: KProperty<*>): Int = f(t) } val p = Delegate { t -> t.foo() } diff --git a/compiler/testData/codegen/box/delegatedProperty/useReflectionOnKProperty.kt b/compiler/testData/codegen/box/delegatedProperty/useReflectionOnKProperty.kt index 006e0a96be4..19b6f5cea08 100644 --- a/compiler/testData/codegen/box/delegatedProperty/useReflectionOnKProperty.kt +++ b/compiler/testData/codegen/box/delegatedProperty/useReflectionOnKProperty.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class Delegate { - fun getValue(t: Any?, p: KProperty<*>): String { + operator fun getValue(t: Any?, p: KProperty<*>): String { p.parameters p.returnType p.annotations diff --git a/compiler/testData/codegen/box/delegatedProperty/valInInnerClass.kt b/compiler/testData/codegen/box/delegatedProperty/valInInnerClass.kt index 305e9b65062..43cda384acc 100644 --- a/compiler/testData/codegen/box/delegatedProperty/valInInnerClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/valInInnerClass.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class Delegate { - fun getValue(t: Any?, p: KProperty<*>): Int = 1 + operator fun getValue(t: Any?, p: KProperty<*>): Int = 1 } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/varInInnerClass.kt b/compiler/testData/codegen/box/delegatedProperty/varInInnerClass.kt index d08f50dbdd9..4b99bb19003 100644 --- a/compiler/testData/codegen/box/delegatedProperty/varInInnerClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/varInInnerClass.kt @@ -2,8 +2,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/vararg.kt b/compiler/testData/codegen/box/delegatedProperty/vararg.kt index 70a5e39bc0c..1a5ae662854 100644 --- a/compiler/testData/codegen/box/delegatedProperty/vararg.kt +++ b/compiler/testData/codegen/box/delegatedProperty/vararg.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class Delegate { - fun getValue(t: Any?, vararg p: KProperty<*>): Int = 1 + operator fun getValue(t: Any?, vararg p: KProperty<*>): Int = 1 } val prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/extensionFunctions/kt1953.kt b/compiler/testData/codegen/box/extensionFunctions/kt1953.kt index 6403f7f8c11..c7f72f666f5 100644 --- a/compiler/testData/codegen/box/extensionFunctions/kt1953.kt +++ b/compiler/testData/codegen/box/extensionFunctions/kt1953.kt @@ -1,6 +1,6 @@ fun box(): String { val sb = StringBuilder() - fun String.plus() { + operator fun String.unaryPlus() { sb.append(this) } diff --git a/compiler/testData/codegen/box/extensionFunctions/kt1953_class.kt b/compiler/testData/codegen/box/extensionFunctions/kt1953_class.kt index 97a8bb34b02..e2feab63b56 100644 --- a/compiler/testData/codegen/box/extensionFunctions/kt1953_class.kt +++ b/compiler/testData/codegen/box/extensionFunctions/kt1953_class.kt @@ -1,7 +1,7 @@ class A { private val sb: StringBuilder = StringBuilder() - fun String.plus() { + operator fun String.unaryPlus() { sb.append(this) } diff --git a/compiler/testData/codegen/box/extensionFunctions/kt3298.kt b/compiler/testData/codegen/box/extensionFunctions/kt3298.kt index 24aba423880..d0f83531a69 100644 --- a/compiler/testData/codegen/box/extensionFunctions/kt3298.kt +++ b/compiler/testData/codegen/box/extensionFunctions/kt3298.kt @@ -2,7 +2,7 @@ var result = "" fun result(r: String) { result = r } object Foo { - private fun String.plus() = "(" + this + ")" + private operator fun String.unaryPlus() = "(" + this + ")" fun foo() = { result(+"Stuff") }() } diff --git a/compiler/testData/codegen/box/extensionFunctions/kt3969.kt b/compiler/testData/codegen/box/extensionFunctions/kt3969.kt index 95930acb52a..1e34286ea50 100644 --- a/compiler/testData/codegen/box/extensionFunctions/kt3969.kt +++ b/compiler/testData/codegen/box/extensionFunctions/kt3969.kt @@ -2,7 +2,7 @@ var result = "Fail" class A -fun A.inc(s: String = "OK"): A { +operator fun A.inc(s: String = "OK"): A { result = s return this } diff --git a/compiler/testData/codegen/box/extensionFunctions/kt865.kt b/compiler/testData/codegen/box/extensionFunctions/kt865.kt index c9a575f7238..e47732b2c73 100644 --- a/compiler/testData/codegen/box/extensionFunctions/kt865.kt +++ b/compiler/testData/codegen/box/extensionFunctions/kt865.kt @@ -3,8 +3,8 @@ import java.util.* class Template() { val collected = ArrayList() - fun String.plus() { - collected.add(this@plus) + operator fun String.unaryPlus() { + collected.add(this@unaryPlus) } fun test() { diff --git a/compiler/testData/codegen/box/extensionFunctions/shared.kt b/compiler/testData/codegen/box/extensionFunctions/shared.kt index 977376ca391..3cf651590a4 100644 --- a/compiler/testData/codegen/box/extensionFunctions/shared.kt +++ b/compiler/testData/codegen/box/extensionFunctions/shared.kt @@ -1,4 +1,4 @@ -fun T.mustBe(t : T) { +infix fun T.mustBe(t : T) { assert("$this must be $t") {this == t} } diff --git a/compiler/testData/codegen/box/extensionProperties/genericValForPrimitiveType.kt b/compiler/testData/codegen/box/extensionProperties/genericValForPrimitiveType.kt index bed63ea51cb..787ea1c0245 100644 --- a/compiler/testData/codegen/box/extensionProperties/genericValForPrimitiveType.kt +++ b/compiler/testData/codegen/box/extensionProperties/genericValForPrimitiveType.kt @@ -11,7 +11,7 @@ class A { val char: Char = '0' val bool: Boolean = false - fun invoke() { + operator fun invoke() { int.valProp long.valProp short.valProp diff --git a/compiler/testData/codegen/box/extensionProperties/genericVarForPrimitiveType.kt b/compiler/testData/codegen/box/extensionProperties/genericVarForPrimitiveType.kt index 313606e56e0..a96514698c8 100644 --- a/compiler/testData/codegen/box/extensionProperties/genericVarForPrimitiveType.kt +++ b/compiler/testData/codegen/box/extensionProperties/genericVarForPrimitiveType.kt @@ -12,7 +12,7 @@ class A { var char: Char = '0' var bool: Boolean = false - fun invoke() { + operator fun invoke() { int.varProp = int long.varProp = long short.varProp = short diff --git a/compiler/testData/codegen/box/fieldRename/delegates.kt b/compiler/testData/codegen/box/fieldRename/delegates.kt index 04b12640c14..83501722a0e 100644 --- a/compiler/testData/codegen/box/fieldRename/delegates.kt +++ b/compiler/testData/codegen/box/fieldRename/delegates.kt @@ -3,14 +3,14 @@ import kotlin.reflect.KProperty public open class TestDelegate(private val initializer: () -> T) { private var value: T? = null - public open fun getValue(thisRef: Any?, desc: KProperty<*>): T { + operator open fun getValue(thisRef: Any?, desc: KProperty<*>): T { if (value == null) { value = initializer() } return value!! } - public open fun setValue(thisRef: Any?, desc: KProperty<*>, svalue : T) { + operator open fun setValue(thisRef: Any?, desc: KProperty<*>, svalue : T) { value = svalue } } diff --git a/compiler/testData/codegen/box/finally/finallyAndFinally.kt b/compiler/testData/codegen/box/finally/finallyAndFinally.kt index 340dec49541..e902bc8746f 100644 --- a/compiler/testData/codegen/box/finally/finallyAndFinally.kt +++ b/compiler/testData/codegen/box/finally/finallyAndFinally.kt @@ -1,6 +1,6 @@ class MyString { var s = "" - fun plus(x : String) : MyString { + operator fun plus(x : String) : MyString { s += x return this } diff --git a/compiler/testData/codegen/box/finally/kt3894.kt b/compiler/testData/codegen/box/finally/kt3894.kt index c5422168c30..83930d88fbd 100644 --- a/compiler/testData/codegen/box/finally/kt3894.kt +++ b/compiler/testData/codegen/box/finally/kt3894.kt @@ -1,6 +1,6 @@ class MyString { var s = "" - fun plus(x : String) : MyString { + operator fun plus(x : String) : MyString { s += x return this } diff --git a/compiler/testData/codegen/box/finally/loopAndFinally.kt b/compiler/testData/codegen/box/finally/loopAndFinally.kt index a091d152bab..88425e55ac0 100644 --- a/compiler/testData/codegen/box/finally/loopAndFinally.kt +++ b/compiler/testData/codegen/box/finally/loopAndFinally.kt @@ -2,7 +2,7 @@ class MyString { var s = "" - fun plus(x : String) : MyString { + operator fun plus(x : String) : MyString { s += x return this } diff --git a/compiler/testData/codegen/box/finally/tryLoopTry.kt b/compiler/testData/codegen/box/finally/tryLoopTry.kt index 59a1b071b61..0a969975070 100644 --- a/compiler/testData/codegen/box/finally/tryLoopTry.kt +++ b/compiler/testData/codegen/box/finally/tryLoopTry.kt @@ -2,7 +2,7 @@ class MyString { var s = "" - fun plus(x : String) : MyString { + operator fun plus(x : String) : MyString { s += x return this } diff --git a/compiler/testData/codegen/box/functions/ea33909.kt b/compiler/testData/codegen/box/functions/ea33909.kt index 91701ce012f..f4022e8ba28 100644 --- a/compiler/testData/codegen/box/functions/ea33909.kt +++ b/compiler/testData/codegen/box/functions/ea33909.kt @@ -1,5 +1,5 @@ fun box(): String { - return justPrint(9 compareTo 4) + return justPrint(9.compareTo(4)) } fun justPrint(value: Int): String { diff --git a/compiler/testData/codegen/box/functions/infixRecursiveCall.kt b/compiler/testData/codegen/box/functions/infixRecursiveCall.kt index 72c3f985204..6670cdc54b0 100644 --- a/compiler/testData/codegen/box/functions/infixRecursiveCall.kt +++ b/compiler/testData/codegen/box/functions/infixRecursiveCall.kt @@ -1,4 +1,4 @@ -fun Int.test(x : Int) : Int { +infix fun Int.test(x : Int) : Int { if (this > 1) { return (this - 1) test x } diff --git a/compiler/testData/codegen/box/functions/invoke/extensionInvokeOnExpr.kt b/compiler/testData/codegen/box/functions/invoke/extensionInvokeOnExpr.kt index d1d98a6826b..35496700fd7 100644 --- a/compiler/testData/codegen/box/functions/invoke/extensionInvokeOnExpr.kt +++ b/compiler/testData/codegen/box/functions/invoke/extensionInvokeOnExpr.kt @@ -1,8 +1,8 @@ class A class B { - fun A.invoke() = "##" - fun A.invoke(i: Int) = "#${i}" + operator fun A.invoke() = "##" + operator fun A.invoke(i: Int) = "#${i}" } fun foo() = A() diff --git a/compiler/testData/codegen/box/functions/invoke/invoke.kt b/compiler/testData/codegen/box/functions/invoke/invoke.kt index 13126ec2b83..15b6c093721 100644 --- a/compiler/testData/codegen/box/functions/invoke/invoke.kt +++ b/compiler/testData/codegen/box/functions/invoke/invoke.kt @@ -5,7 +5,7 @@ fun test1(predicate: (Int) -> Int, i: Int) = predicate(i) fun test2(predicate: (Int) -> Int, i: Int) = predicate.invoke(i) class Method { - fun invoke(i: Int) = i + operator fun invoke(i: Int) = i } fun test3(method: Method, i: Int) = method.invoke(i) @@ -14,7 +14,7 @@ fun test4(method: Method, i: Int) = method(i) class Method2 {} -fun Method2.invoke(s: String) = s +operator fun Method2.invoke(s: String) = s fun test5(method2: Method2, s: String) = method2(s) diff --git a/compiler/testData/codegen/box/functions/invoke/invokeOnExprByConvention.kt b/compiler/testData/codegen/box/functions/invoke/invokeOnExprByConvention.kt index 19ebda7ef19..16e174b8db5 100644 --- a/compiler/testData/codegen/box/functions/invoke/invokeOnExprByConvention.kt +++ b/compiler/testData/codegen/box/functions/invoke/invokeOnExprByConvention.kt @@ -2,8 +2,8 @@ //KT-2728 Can't compile A()() class A { - fun invoke() = "##" - fun invoke(i: Int) = "#${i}" + operator fun invoke() = "##" + operator fun invoke(i: Int) = "#${i}" } fun foo() = A() diff --git a/compiler/testData/codegen/box/functions/invoke/kt3189.kt b/compiler/testData/codegen/box/functions/invoke/kt3189.kt index 149606d0e51..be9a0f42107 100644 --- a/compiler/testData/codegen/box/functions/invoke/kt3189.kt +++ b/compiler/testData/codegen/box/functions/invoke/kt3189.kt @@ -11,5 +11,5 @@ class Bad(val a: () -> Int) { fun test(): Int = a() - fun invoke(): Int = 2 + operator fun invoke(): Int = 2 } \ No newline at end of file diff --git a/compiler/testData/codegen/box/functions/invoke/kt3297.kt b/compiler/testData/codegen/box/functions/invoke/kt3297.kt index bfa9d55a77a..026ac7a3b37 100644 --- a/compiler/testData/codegen/box/functions/invoke/kt3297.kt +++ b/compiler/testData/codegen/box/functions/invoke/kt3297.kt @@ -1,6 +1,6 @@ //KT-3297 Calling the wrong function inside an extension method to the Function0 class -fun Function0.or(alt: () -> R): R { +infix fun Function0.or(alt: () -> R): R { try { return this() } catch (e: Exception) { diff --git a/compiler/testData/codegen/box/functions/invoke/kt3450getAndInvoke.kt b/compiler/testData/codegen/box/functions/invoke/kt3450getAndInvoke.kt index c77194ff40d..012853d3a69 100644 --- a/compiler/testData/codegen/box/functions/invoke/kt3450getAndInvoke.kt +++ b/compiler/testData/codegen/box/functions/invoke/kt3450getAndInvoke.kt @@ -2,9 +2,9 @@ public class A(val s: String) { - public fun get(i: Int) : A = A("$s + $i") + operator fun get(i: Int) : A = A("$s + $i") - public fun invoke(builder : A.() -> String): String = builder() + operator fun invoke(builder : A.() -> String): String = builder() } fun x(y : String) : A = A(y) diff --git a/compiler/testData/codegen/box/functions/invoke/kt3631invokeOnString.kt b/compiler/testData/codegen/box/functions/invoke/kt3631invokeOnString.kt index 2bb2623e0ac..8f18fbcb585 100644 --- a/compiler/testData/codegen/box/functions/invoke/kt3631invokeOnString.kt +++ b/compiler/testData/codegen/box/functions/invoke/kt3631invokeOnString.kt @@ -1,5 +1,5 @@ //KT-3631 String.invoke doesn't work with literals -fun String.invoke(i: Int) = "$this$i" +operator fun String.invoke(i: Int) = "$this$i" fun box() = if ("a"(12) == "a12") "OK" else "fail" \ No newline at end of file diff --git a/compiler/testData/codegen/box/functions/invoke/kt3772.kt b/compiler/testData/codegen/box/functions/invoke/kt3772.kt index 687ad27032c..622f571b489 100644 --- a/compiler/testData/codegen/box/functions/invoke/kt3772.kt +++ b/compiler/testData/codegen/box/functions/invoke/kt3772.kt @@ -5,7 +5,7 @@ open class A { } class B { - fun invoke(f: B.() -> Unit) = 2 + operator fun invoke(f: B.() -> Unit) = 2 } open class C diff --git a/compiler/testData/codegen/box/functions/invoke/kt3821invokeOnThis.kt b/compiler/testData/codegen/box/functions/invoke/kt3821invokeOnThis.kt index 15b2926ab2c..d15d396965a 100644 --- a/compiler/testData/codegen/box/functions/invoke/kt3821invokeOnThis.kt +++ b/compiler/testData/codegen/box/functions/invoke/kt3821invokeOnThis.kt @@ -1,7 +1,7 @@ //KT-3821 Invoke convention doesn't work for `this` class A() { - fun invoke() = 42 + operator fun invoke() = 42 fun foo() = this() // Expecting a function type, but found A } diff --git a/compiler/testData/codegen/box/functions/kt1038.kt b/compiler/testData/codegen/box/functions/kt1038.kt index e3681113efe..36770408c78 100644 --- a/compiler/testData/codegen/box/functions/kt1038.kt +++ b/compiler/testData/codegen/box/functions/kt1038.kt @@ -28,7 +28,7 @@ public fun Iterable.lazy() : Iterable } } -fun Iterable.where(predicate : (TItem)->Boolean) : Iterable +infix fun Iterable.where(predicate : (TItem)->Boolean) : Iterable { return YieldingIterable { val iterator = this.iterator() @@ -45,7 +45,7 @@ fun Iterable.where(predicate : (TItem)->Boolean) : Iterable } } -fun Iterable.select(selector : (TItem)->TResult) : Iterable +infix fun Iterable.select(selector : (TItem)->TResult) : Iterable { return YieldingIterable { val iterator = this.iterator(); diff --git a/compiler/testData/codegen/box/functions/kt1199.kt b/compiler/testData/codegen/box/functions/kt1199.kt index b29953c4862..cda81be9969 100644 --- a/compiler/testData/codegen/box/functions/kt1199.kt +++ b/compiler/testData/codegen/box/functions/kt1199.kt @@ -1,10 +1,10 @@ interface MyIterator { - fun hasNext() : Boolean - fun next() : T + operator fun hasNext() : Boolean + operator fun next() : T } -fun T?.iterator() = object : MyIterator { +operator fun T?.iterator() = object : MyIterator { var hasNext = this@iterator != null private set override fun hasNext() = hasNext diff --git a/compiler/testData/codegen/box/functions/kt2929.kt b/compiler/testData/codegen/box/functions/kt2929.kt index 5e015e65900..4367923fc29 100644 --- a/compiler/testData/codegen/box/functions/kt2929.kt +++ b/compiler/testData/codegen/box/functions/kt2929.kt @@ -1,7 +1,7 @@ fun foo(): Int { val a = "test" val b = "test" - return a compareTo b + return a.compareTo(b) } fun box(): String = if(foo() == 0) "OK" else "Fail" diff --git a/compiler/testData/codegen/box/functions/kt3214.kt b/compiler/testData/codegen/box/functions/kt3214.kt index b675ae4f3cd..8ff33fcad23 100644 --- a/compiler/testData/codegen/box/functions/kt3214.kt +++ b/compiler/testData/codegen/box/functions/kt3214.kt @@ -7,15 +7,15 @@ class B { } fun test1(a: A): Int { - return a[1] + return a.get(1) } fun test2(a: A): Int { - return a[1, 2] + return a.get(1, 2) } fun test3(b: B): Int { - return b[Unit, Unit] + return b.get(Unit, Unit) } diff --git a/compiler/testData/codegen/box/functions/localFunctions/kt4119.kt b/compiler/testData/codegen/box/functions/localFunctions/kt4119.kt index 2231bb57f8b..746e41ee392 100644 --- a/compiler/testData/codegen/box/functions/localFunctions/kt4119.kt +++ b/compiler/testData/codegen/box/functions/localFunctions/kt4119.kt @@ -3,10 +3,10 @@ fun foo(f: (Int?) -> Int): Int { } fun box() : String { - fun Int?.plus(a:Int) : Int = a!! + 2 + infix operator fun Int?.plus(a: Int) : Int = a!! + 2 - if (foo { it + 1} != 3) return "Fail 1" - if (foo { it plus 1} != 3) return "Fail 2" + if (foo { it + 1 } != 3) return "Fail 1" + if (foo { it plus 1 } != 3) return "Fail 2" return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/functions/localFunctions/kt4119_2.kt b/compiler/testData/codegen/box/functions/localFunctions/kt4119_2.kt index 30fe4a286dd..edb647f84a9 100644 --- a/compiler/testData/codegen/box/functions/localFunctions/kt4119_2.kt +++ b/compiler/testData/codegen/box/functions/localFunctions/kt4119_2.kt @@ -1,5 +1,5 @@ fun box(): String { - fun Int.foo(a: Int): Int = a + 2 + infix fun Int.foo(a: Int): Int = a + 2 val s = object { fun test(): Int { diff --git a/compiler/testData/codegen/box/functions/localFunctions/kt4783.kt b/compiler/testData/codegen/box/functions/localFunctions/kt4783.kt index 99902449e22..5d5d9d55f6a 100644 --- a/compiler/testData/codegen/box/functions/localFunctions/kt4783.kt +++ b/compiler/testData/codegen/box/functions/localFunctions/kt4783.kt @@ -3,7 +3,7 @@ class T(val value: Int) { fun local() : Int { - fun T.get(s: Int): Int { + operator fun T.get(s: Int): Int { return s * this.value } diff --git a/compiler/testData/codegen/box/functions/localFunctions/kt4784.kt b/compiler/testData/codegen/box/functions/localFunctions/kt4784.kt index 7e1b45ef5ff..ce3ebfd4d27 100644 --- a/compiler/testData/codegen/box/functions/localFunctions/kt4784.kt +++ b/compiler/testData/codegen/box/functions/localFunctions/kt4784.kt @@ -1,8 +1,8 @@ open class T(var value: Int) {} -fun plusAssign(): T { +operator fun plusAssign(): T { - fun T.plusAssign(s: Int) { + operator fun T.plusAssign(s: Int) { value += s } diff --git a/compiler/testData/codegen/box/functions/localFunctions/kt4989.kt b/compiler/testData/codegen/box/functions/localFunctions/kt4989.kt index 6f71e73c9b9..24b06993d4b 100644 --- a/compiler/testData/codegen/box/functions/localFunctions/kt4989.kt +++ b/compiler/testData/codegen/box/functions/localFunctions/kt4989.kt @@ -6,7 +6,7 @@ fun box(): String { fun selectMetaRunnerId(): String { - fun Int?.inc() = (this ?: 0) + 1 + operator fun Int?.inc() = (this ?: 0) + 1 var counter: Int? = null fun path(metaRunnerId: String) = counter != 2 diff --git a/compiler/testData/codegen/box/functions/localFunctions/localWithDefault.kt b/compiler/testData/codegen/box/functions/localFunctions/localWithDefault.kt index 4792a9ce2b9..04be137c798 100644 --- a/compiler/testData/codegen/box/functions/localFunctions/localWithDefault.kt +++ b/compiler/testData/codegen/box/functions/localFunctions/localWithDefault.kt @@ -1,7 +1,7 @@ class Z {} fun box(): String { - fun Z.plus(s : String, d : String = "K") : String { + operator fun Z.plus(s : String, d : String = "K") : String { return s + d } return Z() + "O" diff --git a/compiler/testData/codegen/box/functions/prefixRecursiveCall.kt b/compiler/testData/codegen/box/functions/prefixRecursiveCall.kt index 9fe7c720e05..7fe750fc4ec 100644 --- a/compiler/testData/codegen/box/functions/prefixRecursiveCall.kt +++ b/compiler/testData/codegen/box/functions/prefixRecursiveCall.kt @@ -1,4 +1,4 @@ -fun String.plus() : String { +operator fun String.unaryPlus() : String { if (this == "") { return "done" } diff --git a/compiler/testData/codegen/box/functions/recursiveCompareTo.kt b/compiler/testData/codegen/box/functions/recursiveCompareTo.kt index 2feebcc715d..aeafd27f6e0 100644 --- a/compiler/testData/codegen/box/functions/recursiveCompareTo.kt +++ b/compiler/testData/codegen/box/functions/recursiveCompareTo.kt @@ -1,6 +1,6 @@ class C -fun C.compareTo(o: C) : Int { +operator fun C.compareTo(o: C) : Int { if (this == o) return 0 if (o >= o) { return 1 diff --git a/compiler/testData/codegen/box/functions/recursiveIncrementCall.kt b/compiler/testData/codegen/box/functions/recursiveIncrementCall.kt index cf09fc54cc7..b5985d5606c 100644 --- a/compiler/testData/codegen/box/functions/recursiveIncrementCall.kt +++ b/compiler/testData/codegen/box/functions/recursiveIncrementCall.kt @@ -1,4 +1,4 @@ -fun String.inc() : String { +operator fun String.inc() : String { if (this == "") { return "done" } diff --git a/compiler/testData/codegen/box/increment/postfixIncrementOnClass.kt b/compiler/testData/codegen/box/increment/postfixIncrementOnClass.kt index e8a48162aed..deb8df65d80 100644 --- a/compiler/testData/codegen/box/increment/postfixIncrementOnClass.kt +++ b/compiler/testData/codegen/box/increment/postfixIncrementOnClass.kt @@ -1,7 +1,7 @@ interface Base class Derived: Base class Another: Base -fun Base.inc(): Derived { return Derived() } +operator fun Base.inc(): Derived { return Derived() } public fun box() : String { var i : Base diff --git a/compiler/testData/codegen/box/increment/postfixIncrementOnClassSmartCast.kt b/compiler/testData/codegen/box/increment/postfixIncrementOnClassSmartCast.kt index cb0a9dff50a..3bc2442a3be 100644 --- a/compiler/testData/codegen/box/increment/postfixIncrementOnClassSmartCast.kt +++ b/compiler/testData/codegen/box/increment/postfixIncrementOnClassSmartCast.kt @@ -1,6 +1,6 @@ open class Base class Derived: Base() -fun Derived.inc(): Derived { return Derived() } +operator fun Derived.inc(): Derived { return Derived() } public fun box() : String { var i : Base diff --git a/compiler/testData/codegen/box/increment/postfixNotnullClassIncrement.kt b/compiler/testData/codegen/box/increment/postfixNotnullClassIncrement.kt index 29be526adf1..c5e7fe070e6 100644 --- a/compiler/testData/codegen/box/increment/postfixNotnullClassIncrement.kt +++ b/compiler/testData/codegen/box/increment/postfixNotnullClassIncrement.kt @@ -1,7 +1,7 @@ class MyClass // In principle it is not correct, MyClass? is not a subtype of MyClass -fun MyClass.inc(): MyClass? = null +operator fun MyClass.inc(): MyClass? = null public fun box() : String { var i : MyClass? diff --git a/compiler/testData/codegen/box/increment/postfixNullableClassIncrement.kt b/compiler/testData/codegen/box/increment/postfixNullableClassIncrement.kt index 56fc4da33e1..b6d22b07a1b 100644 --- a/compiler/testData/codegen/box/increment/postfixNullableClassIncrement.kt +++ b/compiler/testData/codegen/box/increment/postfixNullableClassIncrement.kt @@ -1,6 +1,6 @@ class MyClass -fun MyClass?.inc(): MyClass? = null +operator fun MyClass?.inc(): MyClass? = null public fun box() : String { var i : MyClass? diff --git a/compiler/testData/codegen/box/increment/postfixNullableIncrement.kt b/compiler/testData/codegen/box/increment/postfixNullableIncrement.kt index 9e5783719d2..2564e3ed898 100644 --- a/compiler/testData/codegen/box/increment/postfixNullableIncrement.kt +++ b/compiler/testData/codegen/box/increment/postfixNullableIncrement.kt @@ -1,4 +1,4 @@ -fun Int?.inc(): Int? = this +operator fun Int?.inc(): Int? = this fun init(): Int? { return 10 } diff --git a/compiler/testData/codegen/box/increment/prefixIncrementOnClass.kt b/compiler/testData/codegen/box/increment/prefixIncrementOnClass.kt index c732ac67ac8..6bc75ad060e 100644 --- a/compiler/testData/codegen/box/increment/prefixIncrementOnClass.kt +++ b/compiler/testData/codegen/box/increment/prefixIncrementOnClass.kt @@ -1,7 +1,7 @@ interface Base class Derived: Base class Another: Base -fun Base.inc(): Derived { return Derived() } +operator fun Base.inc(): Derived { return Derived() } public fun box() : String { var i : Base diff --git a/compiler/testData/codegen/box/increment/prefixIncrementOnClassSmartCast.kt b/compiler/testData/codegen/box/increment/prefixIncrementOnClassSmartCast.kt index 624155ce7af..c51f6d1d816 100644 --- a/compiler/testData/codegen/box/increment/prefixIncrementOnClassSmartCast.kt +++ b/compiler/testData/codegen/box/increment/prefixIncrementOnClassSmartCast.kt @@ -1,6 +1,6 @@ open class Base class Derived: Base() -fun Derived.inc(): Derived { return Derived() } +operator fun Derived.inc(): Derived { return Derived() } public fun box() : String { var i : Base diff --git a/compiler/testData/codegen/box/increment/prefixNotnullClassIncrement.kt b/compiler/testData/codegen/box/increment/prefixNotnullClassIncrement.kt index 0f71c9d6177..8e5cd3401d9 100644 --- a/compiler/testData/codegen/box/increment/prefixNotnullClassIncrement.kt +++ b/compiler/testData/codegen/box/increment/prefixNotnullClassIncrement.kt @@ -1,7 +1,7 @@ class MyClass // In principle it is not correct, MyClass? is not a subtype of MyClass -fun MyClass.inc(): MyClass? = null +operator fun MyClass.inc(): MyClass? = null public fun box() : String { var i : MyClass? diff --git a/compiler/testData/codegen/box/increment/prefixNullableClassIncrement.kt b/compiler/testData/codegen/box/increment/prefixNullableClassIncrement.kt index d51bd20a364..e8c98d7bce6 100644 --- a/compiler/testData/codegen/box/increment/prefixNullableClassIncrement.kt +++ b/compiler/testData/codegen/box/increment/prefixNullableClassIncrement.kt @@ -1,6 +1,6 @@ class MyClass -fun MyClass?.inc(): MyClass? = null +operator fun MyClass?.inc(): MyClass? = null public fun box() : String { var i : MyClass? diff --git a/compiler/testData/codegen/box/increment/prefixNullableIncrement.kt b/compiler/testData/codegen/box/increment/prefixNullableIncrement.kt index 49034d27036..2c28b62ff11 100644 --- a/compiler/testData/codegen/box/increment/prefixNullableIncrement.kt +++ b/compiler/testData/codegen/box/increment/prefixNullableIncrement.kt @@ -1,4 +1,4 @@ -fun Int?.inc(): Int? = this +operator fun Int?.inc(): Int? = this fun init(): Int? { return 10 } diff --git a/compiler/testData/codegen/box/innerNested/innerInfixCall.kt b/compiler/testData/codegen/box/innerNested/innerInfixCall.kt deleted file mode 100644 index 97441a3b1bc..00000000000 --- a/compiler/testData/codegen/box/innerNested/innerInfixCall.kt +++ /dev/null @@ -1,15 +0,0 @@ -class Z() { - - inner class Z2(val s: String) { - - } - - fun a(): String { - val s = Z() Z2 "OK" - return s.s - } -} - -fun box(): String { - return Z().a() -} diff --git a/compiler/testData/codegen/box/intrinsics/compareTo.kt b/compiler/testData/codegen/box/intrinsics/compareTo.kt deleted file mode 100644 index ae6fe3f4ef0..00000000000 --- a/compiler/testData/codegen/box/intrinsics/compareTo.kt +++ /dev/null @@ -1,16 +0,0 @@ -fun box(): String { - val sb = StringBuilder() - - for (i in -1..1) { - for (j in -1..1) { - val a = i compareTo j - val b = i.compareTo(j) - if (a != b) { - sb.append("$i compareTo $j: $a != $b\n") - } - } - } - - if (sb.length == 0) return "OK" - return "Fail:\n$sb" -} diff --git a/compiler/testData/codegen/box/intrinsics/ea35953.kt b/compiler/testData/codegen/box/intrinsics/ea35953.kt index 122782f4faf..a1acb1d7481 100644 --- a/compiler/testData/codegen/box/intrinsics/ea35953.kt +++ b/compiler/testData/codegen/box/intrinsics/ea35953.kt @@ -1,5 +1,5 @@ fun box(): String { - if (12.toString() equals "13") { + if (12.toString().equals("13")) { return "Fail" } return "OK" diff --git a/compiler/testData/codegen/box/intrinsics/infixCall.kt b/compiler/testData/codegen/box/intrinsics/infixCall.kt deleted file mode 100644 index e385f75688d..00000000000 --- a/compiler/testData/codegen/box/intrinsics/infixCall.kt +++ /dev/null @@ -1,8 +0,0 @@ -fun box(): String { - val o = "OK" get 0 - val array = CharArray(2) - array[1] = 'K' - val k = array get 1 - - return "$o$k" -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsConstructor.kt b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsConstructor.kt index b1fa6ed8434..873ae27f02e 100644 --- a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsConstructor.kt +++ b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsConstructor.kt @@ -6,6 +6,6 @@ fun box(): String { val a = A(42) val b = a.clone() if (b != a) return "Fail equals" - if (b identityEquals a) return "Fail identity" + if (b.identityEquals(a)) return "Fail identity" return "OK" } diff --git a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsSuper.kt b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsSuper.kt index d225016bc2a..b6350c535e2 100644 --- a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsSuper.kt +++ b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsSuper.kt @@ -6,6 +6,6 @@ fun box(): String { val a = A(42) val b = a.clone() if (a != b) return "Fail equals" - if (a identityEquals b) return "Fail identity" + if (a.identityEquals(b)) return "Fail identity" return "OK" } diff --git a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsSuperAndModifies.kt b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsSuperAndModifies.kt index f9ed0541f5e..9f1ebf72b05 100644 --- a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsSuperAndModifies.kt +++ b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneCallsSuperAndModifies.kt @@ -10,7 +10,7 @@ fun box(): String { val a = A(42) val b = a.clone() if (a == b) return "Fail: $a == $b" - if (a identityEquals b) return "Fail: $a identityEquals $b" + if (a.identityEquals(b)) return "Fail: $a identityEquals $b" if (b.x != 239) return "Fail: b.x = ${b.x}" return "OK" } diff --git a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneHashSet.kt b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneHashSet.kt index 8b912dde27f..44339d6282a 100644 --- a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneHashSet.kt +++ b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneHashSet.kt @@ -7,6 +7,6 @@ fun box(): String { a.add("prosper") val b = a.clone() if (a != b) return "Fail equals" - if (a identityEquals b) return "Fail identity" + if (a.identityEquals(b)) return "Fail identity" return "OK" } diff --git a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneHierarchy.kt b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneHierarchy.kt index 59ebd371d4d..6ac83454881 100644 --- a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneHierarchy.kt +++ b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneHierarchy.kt @@ -25,8 +25,8 @@ fun box(): String { if (c.s != d.s) return "Fail s: ${d.s}" if (c.l != d.l) return "Fail l: ${d.l}" - if (c.l identityEquals d.l) return "Fail list identity" - if (c identityEquals d) return "Fail identity" + if (c.l.identityEquals(d.l)) return "Fail list identity" + if (c.identityEquals(d)) return "Fail identity" return "OK" } diff --git a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneableClassWithoutClone.kt b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneableClassWithoutClone.kt index 0c5115e23a7..464bcf421e0 100644 --- a/compiler/testData/codegen/box/javaInterop/objectMethods/cloneableClassWithoutClone.kt +++ b/compiler/testData/codegen/box/javaInterop/objectMethods/cloneableClassWithoutClone.kt @@ -6,6 +6,6 @@ fun box(): String { val a = A("OK") val b = a.externalClone() if (a != b) return "Fail equals" - if (a identityEquals b) return "Fail identity" + if (a.identityEquals(b)) return "Fail identity" return b.s } diff --git a/compiler/testData/codegen/box/multiDecl/ComplexInitializer.kt b/compiler/testData/codegen/box/multiDecl/ComplexInitializer.kt index f63eaa5c270..14e38239d17 100644 --- a/compiler/testData/codegen/box/multiDecl/ComplexInitializer.kt +++ b/compiler/testData/codegen/box/multiDecl/ComplexInitializer.kt @@ -1,7 +1,6 @@ class A { - fun component1() = 1 - fun component2() = 2 - + operator fun component1() = 1 + operator fun component2() = 2 } fun A.getA() = this diff --git a/compiler/testData/codegen/box/multiDecl/SimpleVals.kt b/compiler/testData/codegen/box/multiDecl/SimpleVals.kt index 4804c269f0a..9f438f3fe71 100644 --- a/compiler/testData/codegen/box/multiDecl/SimpleVals.kt +++ b/compiler/testData/codegen/box/multiDecl/SimpleVals.kt @@ -1,6 +1,6 @@ class A { - fun component1() = 1 - fun component2() = 2 + operator fun component1() = 1 + operator fun component2() = 2 } fun box() : String { diff --git a/compiler/testData/codegen/box/multiDecl/SimpleValsExtensions.kt b/compiler/testData/codegen/box/multiDecl/SimpleValsExtensions.kt index d5d442d7ed7..cab08120cb0 100644 --- a/compiler/testData/codegen/box/multiDecl/SimpleValsExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/SimpleValsExtensions.kt @@ -1,8 +1,8 @@ class A { } -fun A.component1() = 1 -fun A.component2() = 2 +operator fun A.component1() = 1 +operator fun A.component2() = 2 fun box() : String { val (a, b) = A() diff --git a/compiler/testData/codegen/box/multiDecl/SimpleVarsExtensions.kt b/compiler/testData/codegen/box/multiDecl/SimpleVarsExtensions.kt index 981ba45c9b1..525d1234901 100644 --- a/compiler/testData/codegen/box/multiDecl/SimpleVarsExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/SimpleVarsExtensions.kt @@ -1,6 +1,6 @@ class A { - fun component1() = 1 - fun component2() = 2 + operator fun component1() = 1 + operator fun component2() = 2 } fun box() : String { diff --git a/compiler/testData/codegen/box/multiDecl/ValCapturedInFunctionLiteral.kt b/compiler/testData/codegen/box/multiDecl/ValCapturedInFunctionLiteral.kt index 091b0f8eaea..4bf9bdcd08c 100644 --- a/compiler/testData/codegen/box/multiDecl/ValCapturedInFunctionLiteral.kt +++ b/compiler/testData/codegen/box/multiDecl/ValCapturedInFunctionLiteral.kt @@ -1,6 +1,6 @@ class A { - fun component1() = 1 - fun component2() = 2 + operator fun component1() = 1 + operator fun component2() = 2 } fun box() : String { diff --git a/compiler/testData/codegen/box/multiDecl/ValCapturedInLocalFunction.kt b/compiler/testData/codegen/box/multiDecl/ValCapturedInLocalFunction.kt index 9f728b333d2..91dfb1d7eb5 100644 --- a/compiler/testData/codegen/box/multiDecl/ValCapturedInLocalFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/ValCapturedInLocalFunction.kt @@ -1,6 +1,6 @@ class A { - fun component1() = 1 - fun component2() = 2 + operator fun component1() = 1 + operator fun component2() = 2 } fun box() : String { diff --git a/compiler/testData/codegen/box/multiDecl/ValCapturedInObjectLiteral.kt b/compiler/testData/codegen/box/multiDecl/ValCapturedInObjectLiteral.kt index 9f97face796..9e194386e6a 100644 --- a/compiler/testData/codegen/box/multiDecl/ValCapturedInObjectLiteral.kt +++ b/compiler/testData/codegen/box/multiDecl/ValCapturedInObjectLiteral.kt @@ -1,6 +1,6 @@ class A { - fun component1() = 1 - fun component2() = 2 + operator fun component1() = 1 + operator fun component2() = 2 } diff --git a/compiler/testData/codegen/box/multiDecl/VarCapturedInFunctionLiteral.kt b/compiler/testData/codegen/box/multiDecl/VarCapturedInFunctionLiteral.kt index 007aaabcdc9..e0eb2cb5edd 100644 --- a/compiler/testData/codegen/box/multiDecl/VarCapturedInFunctionLiteral.kt +++ b/compiler/testData/codegen/box/multiDecl/VarCapturedInFunctionLiteral.kt @@ -1,6 +1,6 @@ class A { - fun component1() = 1 - fun component2() = 2 + operator fun component1() = 1 + operator fun component2() = 2 } diff --git a/compiler/testData/codegen/box/multiDecl/VarCapturedInLocalFunction.kt b/compiler/testData/codegen/box/multiDecl/VarCapturedInLocalFunction.kt index d930cddfdc4..5c2a87c9d65 100644 --- a/compiler/testData/codegen/box/multiDecl/VarCapturedInLocalFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/VarCapturedInLocalFunction.kt @@ -1,8 +1,8 @@ class A { } -fun A.component1() = 1 -fun A.component2() = 2 +operator fun A.component1() = 1 +operator fun A.component2() = 2 fun box() : String { var (a, b) = A() diff --git a/compiler/testData/codegen/box/multiDecl/VarCapturedInObjectLiteral.kt b/compiler/testData/codegen/box/multiDecl/VarCapturedInObjectLiteral.kt index 94361786b1f..48534b362c6 100644 --- a/compiler/testData/codegen/box/multiDecl/VarCapturedInObjectLiteral.kt +++ b/compiler/testData/codegen/box/multiDecl/VarCapturedInObjectLiteral.kt @@ -1,6 +1,6 @@ class A { - fun component1() = 1 - fun component2() = 2 + operator fun component1() = 1 + operator fun component2() = 2 } diff --git a/compiler/testData/codegen/box/multiDecl/component.kt b/compiler/testData/codegen/box/multiDecl/component.kt index ec5b515705b..9595a700b3b 100644 --- a/compiler/testData/codegen/box/multiDecl/component.kt +++ b/compiler/testData/codegen/box/multiDecl/component.kt @@ -1,9 +1,9 @@ class S(val a: String, val b: String) { - fun component1() : String = a - fun component2() : String = b + operator fun component1() : String = a + operator fun component2() : String = b } -fun S.component3() = ((a + b) as java.lang.String).substring(2) +operator fun S.component3() = ((a + b) as java.lang.String).substring(2) class Tester() { fun box() : String { @@ -11,7 +11,7 @@ class Tester() { return o + k + ok + ok2 } - fun S.component4() = ((a + b) as java.lang.String).substring(2) + operator fun S.component4() = ((a + b) as java.lang.String).substring(2) } fun box() = Tester().box() \ No newline at end of file diff --git a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclFor.kt b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclFor.kt index 96bb5d56eec..411cbb7f59c 100644 --- a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclFor.kt +++ b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclFor.kt @@ -1,6 +1,6 @@ class C(val i: Int) { - fun component1() = i + 1 - fun component2() = i + 2 + operator fun component1() = i + 1 + operator fun component2() = i + 2 } fun doTest(l : java.util.ArrayList): String { diff --git a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentExtensions.kt index 12f00f6f48c..ae80ff2a341 100644 --- a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentExtensions.kt @@ -1,8 +1,8 @@ class C(val i: Int) { } -fun C.component1() = i + 1 -fun C.component2() = i + 2 +operator fun C.component1() = i + 1 +operator fun C.component2() = i + 2 fun doTest(l : java.util.ArrayList): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentMemberExtensions.kt index 8b844a17f36..dc38e0cea5b 100644 --- a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentMemberExtensions.kt @@ -2,8 +2,8 @@ class C(val i: Int) { } class M { - fun C.component1() = i + 1 - fun C.component2() = i + 2 + operator fun C.component1() = i + 1 + operator fun C.component2() = i + 2 fun doTest(l : java.util.ArrayList): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index 2b1499e2733..f19c994c14b 100644 --- a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -2,8 +2,8 @@ class C(val i: Int) { } class M { - fun C.component1() = i + 1 - fun C.component2() = i + 2 + operator fun C.component1() = i + 1 + operator fun C.component2() = i + 2 } fun M.doTest(l : java.util.ArrayList): String { diff --git a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForValCaptured.kt index d06d092a9a7..65714b836d8 100644 --- a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForValCaptured.kt @@ -1,6 +1,6 @@ class C(val i: Int) { - fun component1() = i + 1 - fun component2() = i + 2 + operator fun component1() = i + 1 + operator fun component2() = i + 2 } fun doTest(l : java.util.ArrayList): String { diff --git a/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensions.kt index 2c3798fcbcd..ba96b495179 100644 --- a/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensions.kt @@ -1,5 +1,5 @@ -fun Long.component1() = this + 1 -fun Long.component2() = this + 2 +operator fun Long.component1() = this + 1 +operator fun Long.component2() = this + 2 fun doTest(l : java.util.ArrayList): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensionsValCaptured.kt index 78f99bfd39d..3c6808a08b5 100644 --- a/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensionsValCaptured.kt @@ -1,5 +1,5 @@ -fun Long.component1() = this + 1 -fun Long.component2() = this + 2 +operator fun Long.component1() = this + 1 +operator fun Long.component2() = this + 2 fun doTest(l : java.util.ArrayList): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentMemberExtensions.kt index 71c7e19f3d6..2161ea8709e 100644 --- a/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentMemberExtensions.kt @@ -1,6 +1,6 @@ class M { - fun Long.component1() = this + 1 - fun Long.component2() = this + 2 + operator fun Long.component1() = this + 1 + operator fun Long.component2() = this + 2 fun doTest(l : java.util.ArrayList): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index b5c8caec294..0515fd60bc4 100644 --- a/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,6 +1,6 @@ class M { - fun Long.component1() = this + 1 - fun Long.component2() = this + 2 + operator fun Long.component1() = this + 1 + operator fun Long.component2() = this + 2 } fun M.doTest(l : java.util.ArrayList): String { diff --git a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclFor.kt b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclFor.kt index cc55f879bd2..ceabb3396b0 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclFor.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclFor.kt @@ -1,23 +1,23 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun component1() = i + 1 - fun component2() = i + 2 - fun rangeTo(c: C) = Range(this, c) + operator fun component1() = i + 1 + operator fun component2() = i + 2 + operator fun rangeTo(c: C) = Range(this, c) } fun doTest(): String { diff --git a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentExtensions.kt index 5acc2496a04..edcd9c1188e 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentExtensions.kt @@ -1,24 +1,24 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun rangeTo(c: C) = Range(this, c) + operator fun rangeTo(c: C) = Range(this, c) } -fun C.component1() = i + 1 -fun C.component2() = i + 2 +operator fun C.component1() = i + 1 +operator fun C.component2() = i + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentMemberExtensions.kt index 5efa425ef38..3692148f5b5 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentMemberExtensions.kt @@ -1,26 +1,26 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun rangeTo(c: C) = Range(this, c) + operator fun rangeTo(c: C) = Range(this, c) } class M { - fun C.component1() = i + 1 - fun C.component2() = i + 2 + operator fun C.component1() = i + 1 + operator fun C.component2() = i + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index a34d1424648..80258eee8e6 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,26 +1,26 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun rangeTo(c: C) = Range(this, c) + operator fun rangeTo(c: C) = Range(this, c) } class M { - fun C.component1() = i + 1 - fun C.component2() = i + 2 + operator fun C.component1() = i + 1 + operator fun C.component2() = i + 2 } fun M.doTest(): String { diff --git a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForValCaptured.kt index b0282c1a249..4687822bb09 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForValCaptured.kt @@ -1,23 +1,23 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun component1() = i + 1 - fun component2() = i + 2 - fun rangeTo(c: C) = Range(this, c) + operator fun component1() = i + 1 + operator fun component2() = i + 2 + operator fun rangeTo(c: C) = Range(this, c) } fun doTest(): String { diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclFor.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclFor.kt index 98bb16959c5..1c746927ffc 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclFor.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclFor.kt @@ -1,23 +1,23 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun component1() = i + 1 - fun component2() = i + 2 - fun rangeTo(c: C) = Range(this, c) + operator fun component1() = i + 1 + operator fun component2() = i + 2 + infix fun rangeTo(c: C) = Range(this, c) } fun doTest(): String { diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentExtensions.kt index cb9c18b0b78..2a3ce2cf5b7 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentExtensions.kt @@ -1,24 +1,24 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun rangeTo(c: C) = Range(this, c) + infix fun rangeTo(c: C) = Range(this, c) } -fun C.component1() = i + 1 -fun C.component2() = i + 2 +operator fun C.component1() = i + 1 +operator fun C.component2() = i + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentMemberExtensions.kt index 794ce9a6ca1..86973dd8f4f 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentMemberExtensions.kt @@ -1,30 +1,30 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun rangeTo(c: C) = Range(this, c) + operator fun rangeTo(c: C) = Range(this, c) } class M { - fun C.component1() = i + 1 - fun C.component2() = i + 2 + operator fun C.component1() = i + 1 + operator fun C.component2() = i + 2 fun doTest(): String { var s = "" - for ((a, b) in C(0) rangeTo C(2)) { + for ((a, b) in C(0).rangeTo(C(2))) { s += "$a:$b;" } return s diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index 1f1a7e0370e..43c353d5735 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,26 +1,26 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun rangeTo(c: C) = Range(this, c) + infix fun rangeTo(c: C) = Range(this, c) } class M { - fun C.component1() = i + 1 - fun C.component2() = i + 2 + operator fun C.component1() = i + 1 + operator fun C.component2() = i + 2 } fun M.doTest(): String { diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForValCaptured.kt index 99760eb1228..b09acb4b8aa 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForValCaptured.kt @@ -1,23 +1,23 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun component1() = i + 1 - fun component2() = i + 2 - fun rangeTo(c: C) = Range(this, c) + operator fun component1() = i + 1 + operator fun component2() = i + 2 + infix fun rangeTo(c: C) = Range(this, c) } fun doTest(): String { diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensions.kt index 9698bd4b447..68454565301 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensions.kt @@ -1,9 +1,9 @@ -fun Int.component1() = this + 1 -fun Int.component2() = this + 2 +operator fun Int.component1() = this + 1 +operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" - for ((a, b) in 0 rangeTo 2) { + for ((a, b) in 0.rangeTo(2)) { s += "$a:$b;" } return s diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensionsValCaptured.kt index 227512448b3..f1d711a42e2 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensionsValCaptured.kt @@ -1,9 +1,9 @@ -fun Int.component1() = this + 1 -fun Int.component2() = this + 2 +operator fun Int.component1() = this + 1 +operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" - for ((a, b) in 0 rangeTo 2) { + for ((a, b) in 0.rangeTo(2)) { s += {"$a:$b;"}() } return s diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentMemberExtensions.kt index 88e203d0395..b5cade5f662 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentMemberExtensions.kt @@ -1,10 +1,10 @@ class M { - fun Int.component1() = this + 1 - fun Int.component2() = this + 2 + operator fun Int.component1() = this + 1 + operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" - for ((a, b) in 0 rangeTo 2) { + for ((a, b) in 0.rangeTo(2)) { s += "$a:$b;" } return s diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index 2a02721efa3..22ed58c8d10 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,11 +1,11 @@ class M { - fun Int.component1() = this + 1 - fun Int.component2() = this + 2 + operator fun Int.component1() = this + 1 + operator fun Int.component2() = this + 2 } fun M.doTest(): String { var s = "" - for ((a, b) in 0 rangeTo 2) { + for ((a, b) in 0.rangeTo(2)) { s += "$a:$b;" } return s diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensions.kt index db52a8504a5..132c532501f 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensions.kt @@ -1,9 +1,9 @@ -fun Long.component1() = this + 1 -fun Long.component2() = this + 2 +operator fun Long.component1() = this + 1 +operator fun Long.component2() = this + 2 fun doTest(): String { var s = "" - for ((a, b) in 0.toLong() rangeTo 2.toLong()) { + for ((a, b) in 0.toLong().rangeTo(2.toLong())) { s += "$a:$b;" } return s diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensionsValCaptured.kt index f766b1d743a..fcb229e7f75 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensionsValCaptured.kt @@ -1,9 +1,9 @@ -fun Long.component1() = this + 1 -fun Long.component2() = this + 2 +operator fun Long.component1() = this + 1 +operator fun Long.component2() = this + 2 fun doTest(): String { var s = "" - for ((a, b) in 0.toLong() rangeTo 2.toLong()) { + for ((a, b) in 0.toLong().rangeTo(2.toLong())) { s += {"$a:$b;"}() } return s diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentMemberExtensions.kt index f5d2f3f2eee..664233c2d14 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentMemberExtensions.kt @@ -1,10 +1,10 @@ class M { - fun Long.component1() = this + 1 - fun Long.component2() = this + 2 + operator fun Long.component1() = this + 1 + operator fun Long.component2() = this + 2 fun doTest(): String { var s = "" - for ((a, b) in 0.toLong() rangeTo 2.toLong()) { + for ((a, b) in 0.toLong().rangeTo(2.toLong())) { s += "$a:$b;" } return s diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index 75b523c7bd1..99e71d259f3 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,11 +1,11 @@ class M { - fun Long.component1() = this + 1 - fun Long.component2() = this + 2 + operator fun Long.component1() = this + 1 + operator fun Long.component2() = this + 2 } fun M.doTest(): String { var s = "" - for ((a, b) in 0.toLong() rangeTo 2.toLong()) { + for ((a, b) in 0.toLong().rangeTo(2.toLong())) { s += "$a:$b;" } return s diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclFor.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclFor.kt index be0c2dcf03a..be1dacd3f39 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclFor.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclFor.kt @@ -1,22 +1,22 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun component1() = i + 1 - fun component2() = i + 2 + operator fun component1() = i + 1 + operator fun component2() = i + 2 fun rangeTo(c: C) = Range(this, c) } diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentExtensions.kt index c5f898d0ca1..08eb7d8914d 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentExtensions.kt @@ -1,24 +1,24 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { fun rangeTo(c: C) = Range(this, c) } -fun C.component1() = i + 1 -fun C.component2() = i + 2 +operator fun C.component1() = i + 1 +operator fun C.component2() = i + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentMemberExtensions.kt index 347a653ffe0..1efc37832ab 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentMemberExtensions.kt @@ -1,17 +1,17 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { @@ -19,8 +19,8 @@ class C(val i : Int) { } class M { - fun C.component1() = i + 1 - fun C.component2() = i + 2 + operator fun C.component1() = i + 1 + operator fun C.component2() = i + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index 47bc2ca7530..7daff02f89c 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,17 +1,17 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { @@ -19,8 +19,8 @@ class C(val i : Int) { } class M { - fun C.component1() = i + 1 - fun C.component2() = i + 2 + operator fun C.component1() = i + 1 + operator fun C.component2() = i + 2 } fun M.doTest(): String { diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForValCaptured.kt index d928f8d5b40..8df7e251bf5 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForValCaptured.kt @@ -1,22 +1,22 @@ class Range(val from : C, val to: C) { - fun iterator() = It(from, to) + operator fun iterator() = It(from, to) } class It(val from: C, val to: C) { var c = from.i - fun next(): C { + operator fun next(): C { val next = C(c) c++ return next } - fun hasNext(): Boolean = c <= to.i + operator fun hasNext(): Boolean = c <= to.i } class C(val i : Int) { - fun component1() = i + 1 - fun component2() = i + 2 + operator fun component1() = i + 1 + operator fun component2() = i + 2 fun rangeTo(c: C) = Range(this, c) } diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensions.kt index c8a4141ee7a..68454565301 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensions.kt @@ -1,5 +1,5 @@ -fun Int.component1() = this + 1 -fun Int.component2() = this + 2 +operator fun Int.component1() = this + 1 +operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensionsValCaptured.kt index c6cb984b12b..f1d711a42e2 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensionsValCaptured.kt @@ -1,5 +1,5 @@ -fun Int.component1() = this + 1 -fun Int.component2() = this + 2 +operator fun Int.component1() = this + 1 +operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentMemberExtensions.kt index 15c07d08d25..b5cade5f662 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentMemberExtensions.kt @@ -1,6 +1,6 @@ class M { - fun Int.component1() = this + 1 - fun Int.component2() = this + 2 + operator fun Int.component1() = this + 1 + operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index 01d29dd537b..22ed58c8d10 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,6 +1,6 @@ class M { - fun Int.component1() = this + 1 - fun Int.component2() = this + 2 + operator fun Int.component1() = this + 1 + operator fun Int.component2() = this + 2 } fun M.doTest(): String { diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensions.kt index 72f14fea734..c8bc4ce6e61 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensions.kt @@ -1,13 +1,13 @@ fun f(l : Long) { - l rangeTo l + l.rangeTo(l) } fun box(): String { return "OK" } -//fun Long.component1() = this + 1 -//fun Long.component2() = this + 2 +//operator fun Long.component1() = this + 1 +//operator fun Long.component2() = this + 2 // //fun doTest(): String { // var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensionsValCaptured.kt index 50c3d1dc246..fcb229e7f75 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensionsValCaptured.kt @@ -1,5 +1,5 @@ -fun Long.component1() = this + 1 -fun Long.component2() = this + 2 +operator fun Long.component1() = this + 1 +operator fun Long.component2() = this + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentMemberExtensions.kt index f87a725ccbb..664233c2d14 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentMemberExtensions.kt @@ -1,6 +1,6 @@ class M { - fun Long.component1() = this + 1 - fun Long.component2() = this + 2 + operator fun Long.component1() = this + 1 + operator fun Long.component2() = this + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index ee02e2ad4e2..99e71d259f3 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,6 +1,6 @@ class M { - fun Long.component1() = this + 1 - fun Long.component2() = this + 2 + operator fun Long.component1() = this + 1 + operator fun Long.component2() = this + 2 } fun M.doTest(): String { diff --git a/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensions.kt index 76233a97ed9..5f60ba33287 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensions.kt @@ -1,5 +1,5 @@ -fun Int.component1() = this + 1 -fun Int.component2() = this + 2 +operator fun Int.component1() = this + 1 +operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensionsValCaptured.kt index 3932aad37fd..fd0f6dac885 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensionsValCaptured.kt @@ -1,5 +1,5 @@ -fun Int.component1() = this + 1 -fun Int.component2() = this + 2 +operator fun Int.component1() = this + 1 +operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentMemberExtensions.kt index 1eed91c9a17..e1a6673c11a 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentMemberExtensions.kt @@ -1,6 +1,6 @@ class M { - fun Int.component1() = this + 1 - fun Int.component2() = this + 2 + operator fun Int.component1() = this + 1 + operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index f478f4391db..1a20e756f0f 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,6 +1,6 @@ class M { - fun Int.component1() = this + 1 - fun Int.component2() = this + 2 + operator fun Int.component1() = this + 1 + operator fun Int.component2() = this + 2 } fun M.doTest(): String { diff --git a/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensions.kt index d7e0cdc67ae..85f78eabcdc 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensions.kt @@ -1,5 +1,5 @@ -fun Long.component1() = this + 1 -fun Long.component2() = this + 2 +operator fun Long.component1() = this + 1 +operator fun Long.component2() = this + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensionsValCaptured.kt index 97dc780c3de..8bf72ec08d7 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensionsValCaptured.kt @@ -1,5 +1,5 @@ -fun Long.component1() = this + 1 -fun Long.component2() = this + 2 +operator fun Long.component1() = this + 1 +operator fun Long.component2() = this + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentMemberExtensions.kt index 5894923713f..a11156329f4 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentMemberExtensions.kt @@ -1,6 +1,6 @@ class M { - fun Long.component1() = this + 1 - fun Long.component2() = this + 2 + operator fun Long.component1() = this + 1 + operator fun Long.component2() = this + 2 fun doTest(): String { var s = "" diff --git a/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index 3070ef2407e..3ee641f67f7 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,6 +1,6 @@ class M { - fun Long.component1() = this + 1 - fun Long.component2() = this + 2 + operator fun Long.component1() = this + 1 + operator fun Long.component2() = this + 2 } fun M.doTest(): String { diff --git a/compiler/testData/codegen/box/objects/flist.kt b/compiler/testData/codegen/box/objects/flist.kt index 92e4006ba95..9da8a335ad7 100644 --- a/compiler/testData/codegen/box/objects/flist.kt +++ b/compiler/testData/codegen/box/objects/flist.kt @@ -16,7 +16,7 @@ public abstract class FList() { } } - public fun plus(head: T): FList = object : FList() { + operator fun plus(head: T): FList = object : FList() { override public val head: T get() = head @@ -33,7 +33,7 @@ public fun emptyFList(): FList = FList.emptyFList as FList public fun FList.reverse(where: FList = emptyFList()) : FList = if(empty) where else tail.reverse(where + head) -public fun FList.iterator(): Iterator = object: Iterator { +operator fun FList.iterator(): Iterator = object: Iterator { private var cur: FList = this@iterator override public fun next(): T { diff --git a/compiler/testData/codegen/box/objects/useAnonymousObjectAsIterator.kt b/compiler/testData/codegen/box/objects/useAnonymousObjectAsIterator.kt index b15b9fe722a..4b492007eb1 100644 --- a/compiler/testData/codegen/box/objects/useAnonymousObjectAsIterator.kt +++ b/compiler/testData/codegen/box/objects/useAnonymousObjectAsIterator.kt @@ -1,6 +1,6 @@ // KT-5869 -fun Iterator.iterator(): Iterator = this +operator fun Iterator.iterator(): Iterator = this fun box(): String { val iterator = object : Iterator { diff --git a/compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt b/compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt index 02f320878f7..e3a5bb5e2cb 100644 --- a/compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt +++ b/compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt @@ -2,34 +2,34 @@ class A() { var x = 0 } -fun A.plusAssign(y: Int) { x += y } -fun A.minusAssign(y: Int) { x -= y } -fun A.timesAssign(y: Int) { x *= y } -fun A.divAssign(y: Int) { x /= y } -fun A.modAssign(y: Int) { x %= y } +operator fun A.plusAssign(y: Int) { x += y } +operator fun A.minusAssign(y: Int) { x -= y } +operator fun A.timesAssign(y: Int) { x *= y } +operator fun A.divAssign(y: Int) { x /= y } +operator fun A.modAssign(y: Int) { x %= y } fun box(): String { val original = A() val a = original a += 1 - if (!(a identityEquals original)) return "Fail 1: $a !== $original" + if (!(a.identityEquals(original))) return "Fail 1: $a !== $original" if (a.x != 1) return "Fail 2: ${a.x} != 1" a -= 2 - if (!(a identityEquals original)) return "Fail 3: $a !== $original" + if (!(a.identityEquals(original))) return "Fail 3: $a !== $original" if (a.x != -1) return "Fail 4: ${a.x} != -1" a *= -10 - if (!(a identityEquals original)) return "Fail 5: $a !== $original" + if (!(a.identityEquals(original))) return "Fail 5: $a !== $original" if (a.x != 10) return "Fail 6: ${a.x} != 10" a /= 3 - if (!(a identityEquals original)) return "Fail 7: $a !== $original" + if (!(a.identityEquals(original))) return "Fail 7: $a !== $original" if (a.x != 3) return "Fail 8: ${a.x} != 3" a %= 2 - if (!(a identityEquals original)) return "Fail 9: $a !== $original" + if (!(a.identityEquals(original))) return "Fail 9: $a !== $original" if (a.x != 1) return "Fail 10: ${a.x} != 1" return "OK" diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt index 67a344bf1ec..833e11a733a 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt @@ -4,7 +4,6 @@ fun checkLess(x: Boolean, y: Boolean) = when { !(x <= y) -> "Fail !($x <= $y)" x > y -> "Fail $x > $y" x.compareTo(y) >= 0 -> "Fail $x.compareTo($y) >= 0" - x compareTo y >= 0 -> "Fail $x compareTo $y >= 0" else -> "OK" } diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/extensionArray.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/extensionArray.kt index e9216c54ce1..7ca0f34b787 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/extensionArray.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/extensionArray.kt @@ -7,7 +7,7 @@ fun checkLess(x: Array, y: Array) = when { else -> "OK" } -fun Array.compareTo(other: Array) = size - other.size +operator fun Array.compareTo(other: Array) = size - other.size fun box(): String { val a = arrayOfNulls(0) as Array diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/extensionObject.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/extensionObject.kt index 3dc1a6fca87..1f355ed16e6 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/extensionObject.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/extensionObject.kt @@ -1,6 +1,6 @@ class A(val x: Int) -fun A.compareTo(other: A) = x.compareTo(other.x) +operator fun A.compareTo(other: A) = x.compareTo(other.x) fun checkLess(x: A, y: A) = when { x >= y -> "Fail $x >= $y" diff --git a/compiler/testData/codegen/box/operatorConventions/incDecOnObject.kt b/compiler/testData/codegen/box/operatorConventions/incDecOnObject.kt index edf45722301..0717061a9b4 100644 --- a/compiler/testData/codegen/box/operatorConventions/incDecOnObject.kt +++ b/compiler/testData/codegen/box/operatorConventions/incDecOnObject.kt @@ -1,11 +1,11 @@ class X(var value: Long) -fun X.inc(): X { +operator fun X.inc(): X { this.value++ return this } -fun X.dec(): X { +operator fun X.dec(): X { this.value-- return this } diff --git a/compiler/testData/codegen/box/operatorConventions/kt4987.kt b/compiler/testData/codegen/box/operatorConventions/kt4987.kt index 3b850a340da..ed28874dbbc 100644 --- a/compiler/testData/codegen/box/operatorConventions/kt4987.kt +++ b/compiler/testData/codegen/box/operatorConventions/kt4987.kt @@ -1,5 +1,5 @@ fun box(): String { - fun Int?.inc() = (this ?: 0) + 1 + operator fun Int?.inc() = (this ?: 0) + 1 var counter: Int? = null counter++ return if (counter == 1) "OK" else "fail: $counter" diff --git a/compiler/testData/codegen/box/platformTypes/primitives/compareTo.kt b/compiler/testData/codegen/box/platformTypes/primitives/compareTo.kt index a8cf44debc1..c3f04bc29ab 100644 --- a/compiler/testData/codegen/box/platformTypes/primitives/compareTo.kt +++ b/compiler/testData/codegen/box/platformTypes/primitives/compareTo.kt @@ -3,7 +3,7 @@ fun box(): String { l.add(1) val x = l[0] < 2 if (x != true) return "Fail: $x}" - val y = l[0] compareTo 2 + val y = l[0].compareTo(2) if (y != -1) return "Fail (y): $y}" return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt b/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt index a4ee0641f67..c9f98e9a79c 100644 --- a/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt +++ b/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt @@ -9,11 +9,11 @@ fun box(): String { val x2 = l[0] === l[0] if (!x2) return "Fail 2: $x" - val y = l[0] identityEquals 1000 + val y = l[0].identityEquals(1000) if (y) return "Fail (y): $y" - val y1 = l[0] identityEquals 1 + val y1 = l[0].identityEquals(1) if (y1) return "Fail (y1): $y" - val y2 = l[0] identityEquals l[0] + val y2 = l[0].identityEquals(l[0]) if (!y2) return "Fail (y2): $y" return "OK" diff --git a/compiler/testData/codegen/box/primitiveTypes/equalsHashCodeToString.kt b/compiler/testData/codegen/box/primitiveTypes/equalsHashCodeToString.kt index 1acdac8c820..7d4684e70bd 100644 --- a/compiler/testData/codegen/box/primitiveTypes/equalsHashCodeToString.kt +++ b/compiler/testData/codegen/box/primitiveTypes/equalsHashCodeToString.kt @@ -9,56 +9,48 @@ fun box(): String { val z: Boolean = true b.equals(b) - b equals b b == b b.hashCode() b.toString() "$b" c.equals(c) - c equals c c == c c.hashCode() c.toString() "$c" s.equals(s) - s equals s s == s s.hashCode() s.toString() "$s" i.equals(i) - i equals i i == i i.hashCode() i.toString() "$i" j.equals(j) - j equals j j == j j.hashCode() j.toString() "$j" f.equals(f) - f equals f f == f f.hashCode() f.toString() "$f" d.equals(d) - d equals d d == d d.hashCode() d.toString() "$d" z.equals(z) - z equals z z == z z.hashCode() z.toString() diff --git a/compiler/testData/codegen/box/primitiveTypes/kt1055.kt b/compiler/testData/codegen/box/primitiveTypes/kt1055.kt index 7c97d9a3c0c..8502c6ad8f8 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt1055.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt1055.kt @@ -1,6 +1,6 @@ fun box() : String { val a = "lala" if(!a.identityEquals(a)) return "fail 1" - if(a identityEquals a) return "OK" + if(a.identityEquals(a)) return "OK" return "fail 2" } diff --git a/compiler/testData/codegen/box/primitiveTypes/kt1093.kt b/compiler/testData/codegen/box/primitiveTypes/kt1093.kt index 796bb26457c..cf8f6395bd3 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt1093.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt1093.kt @@ -1,8 +1,8 @@ val f : (Any) -> String = { it.toString() } fun box() : String { - if(!(f identityEquals f)) return "fail 1" + if(!(f.identityEquals(f))) return "fail 1" if(!(f == f)) return "fail 2" - if(!(f equals f)) return "fail 3" + if(!(f.equals(f))) return "fail 3" return "OK" } diff --git a/compiler/testData/codegen/box/primitiveTypes/kt752.kt b/compiler/testData/codegen/box/primitiveTypes/kt752.kt index 999da7f82bf..2ae20c06689 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt752.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt752.kt @@ -1,6 +1,6 @@ package demo_range -fun Int?.rangeTo(other : Int?) : IntRange = this!!.rangeTo(other!!) +operator fun Int?.rangeTo(other : Int?) : IntRange = this!!.rangeTo(other!!) fun box() : String { val x : Int? = 10 diff --git a/compiler/testData/codegen/box/primitiveTypes/kt756.kt b/compiler/testData/codegen/box/primitiveTypes/kt756.kt index cb5ac5c36ae..d542a3f2e8d 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt756.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt756.kt @@ -1,12 +1,12 @@ package demo_range -fun Int?.plus() : Int = this!!.plus() -fun Int?.dec() : Int = this!!.dec() -fun Int?.inc() : Int = this!!.inc() -fun Int?.minus() : Int = this!!.minus() +operator fun Int?.unaryPlus() : Int = this!!.unaryPlus() +operator fun Int?.dec() : Int = this!!.dec() +operator fun Int?.inc() : Int = this!!.inc() +operator fun Int?.unaryMinus() : Int = this!!.unaryMinus() fun box() : String { val x : Int? = 10 - System.out?.println(x?.inv())// * x?.plus() * x?.dec() * x?.minus() as Number) + System.out?.println(x?.inv())// * x?.unaryPlus() * x?.dec() * x?.unaryMinus() as Number) return "OK" } diff --git a/compiler/testData/codegen/box/primitiveTypes/kt935.kt b/compiler/testData/codegen/box/primitiveTypes/kt935.kt index 7ca6d8b4dc2..8109decb0e4 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt935.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt935.kt @@ -26,5 +26,5 @@ fun bottlesOfBeer(count : Int) : String { // An excerpt from the standard library fun print(message : String) { System.out?.print(message) } fun println(message : String) { System.out?.println(message) } -fun StringBuilder.plusAssign(o : Any) { append(o) } +operator fun StringBuilder.plusAssign(o : Any) { append(o) } val Array.isEmpty : Boolean get() = size == 0 diff --git a/compiler/testData/codegen/box/primitiveTypes/rangeTo.kt b/compiler/testData/codegen/box/primitiveTypes/rangeTo.kt index b1531024656..7d55b63daf9 100644 --- a/compiler/testData/codegen/box/primitiveTypes/rangeTo.kt +++ b/compiler/testData/codegen/box/primitiveTypes/rangeTo.kt @@ -6,59 +6,42 @@ fun box(): String { val j: Long = -42L b.rangeTo(b) - b rangeTo b b..b b.rangeTo(s) - b rangeTo s b..s b.rangeTo(i) - b rangeTo i b..i b.rangeTo(j) - b rangeTo j b..j c.rangeTo(c) - c rangeTo c c..c s.rangeTo(b) - s rangeTo b s..b s.rangeTo(s) - s rangeTo s s..s s.rangeTo(i) - s rangeTo i s..i s.rangeTo(j) - s rangeTo j s..j i.rangeTo(b) - i rangeTo b i..b i.rangeTo(s) - i rangeTo s i..s i.rangeTo(i) - i rangeTo i i..i i.rangeTo(j) - i rangeTo j i..j j.rangeTo(b) - j rangeTo b j..b j.rangeTo(s) - j rangeTo s j..s j.rangeTo(i) - j rangeTo i j..i j.rangeTo(j) - j rangeTo j j..j return "OK" @@ -71,7 +54,6 @@ fun main(args: Array) { for (j in s) { if ((i == 'c') != (j == 'c')) continue println(" $i.rangeTo($j)") - println(" $i rangeTo $j") println(" $i..$j") } println() diff --git a/compiler/testData/codegen/box/properties/kt4383.kt b/compiler/testData/codegen/box/properties/kt4383.kt index 79ed9194fb2..3a8d6e0a1e3 100644 --- a/compiler/testData/codegen/box/properties/kt4383.kt +++ b/compiler/testData/codegen/box/properties/kt4383.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class D { - fun getValue(a: Any, p: KProperty<*>) { } + operator fun getValue(a: Any, p: KProperty<*>) { } } object P { diff --git a/compiler/testData/codegen/box/properties/primitiveOverrideDelegateAccessor.kt b/compiler/testData/codegen/box/properties/primitiveOverrideDelegateAccessor.kt index 4918ea7a8e5..008ef946010 100644 --- a/compiler/testData/codegen/box/properties/primitiveOverrideDelegateAccessor.kt +++ b/compiler/testData/codegen/box/properties/primitiveOverrideDelegateAccessor.kt @@ -1,8 +1,8 @@ import kotlin.reflect.KProperty class Holder(var value: Int) { - fun getValue(that: Any?, desc: KProperty<*>) = value - fun setValue(that: Any?, desc: KProperty<*>, newValue: Int) { value = newValue } + operator fun getValue(that: Any?, desc: KProperty<*>) = value + operator fun setValue(that: Any?, desc: KProperty<*>, newValue: Int) { value = newValue } } interface R> { diff --git a/compiler/testData/codegen/box/regressions/kt3173.kt b/compiler/testData/codegen/box/regressions/kt3173.kt deleted file mode 100644 index 35833189d55..00000000000 --- a/compiler/testData/codegen/box/regressions/kt3173.kt +++ /dev/null @@ -1,4 +0,0 @@ -fun box(): String { - val sum = fun Int.(other: Int) = this + other - return if (1 sum 2 == 3) "OK" else "Fail" -} diff --git a/compiler/testData/codegen/box/regressions/kt3421.kt b/compiler/testData/codegen/box/regressions/kt3421.kt index 05529fbcfa9..a3f0590d621 100644 --- a/compiler/testData/codegen/box/regressions/kt3421.kt +++ b/compiler/testData/codegen/box/regressions/kt3421.kt @@ -1,5 +1,5 @@ public object Globals{ - public fun get(key: String, remove: Boolean = true): String { + operator fun get(key: String, remove: Boolean = true): String { return "OK" } } diff --git a/compiler/testData/codegen/box/regressions/kt3999.kt b/compiler/testData/codegen/box/regressions/kt3999.kt deleted file mode 100644 index 9cb3283e5e9..00000000000 --- a/compiler/testData/codegen/box/regressions/kt3999.kt +++ /dev/null @@ -1,17 +0,0 @@ -fun test() { - val a: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->Unit = {} - val b: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->Unit = {"$this $it"} - val c: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->Unit = {} - a.b(c) - a b c -} - -fun Int.foo(a: Int) = this * a -val boo = fun Int.(a: Int): Int = this + a - -fun box(): String { - test() - 1 foo 2 - 3 boo 4 - return "OK" -} diff --git a/compiler/testData/codegen/box/strings/kt889.kt b/compiler/testData/codegen/box/strings/kt889.kt index 20829fdbc57..4c8e894d64d 100644 --- a/compiler/testData/codegen/box/strings/kt889.kt +++ b/compiler/testData/codegen/box/strings/kt889.kt @@ -1,4 +1,4 @@ -fun Int.plus(s: String) : String { +operator fun Int.plus(s: String) : String { System.out?.println("Int.plus(s: String) called") return s } diff --git a/compiler/testData/codegen/box/typeMapping/kt3863.kt b/compiler/testData/codegen/box/typeMapping/kt3863.kt index a54da7eedb7..5fa48876a48 100644 --- a/compiler/testData/codegen/box/typeMapping/kt3863.kt +++ b/compiler/testData/codegen/box/typeMapping/kt3863.kt @@ -3,8 +3,8 @@ import kotlin.reflect.KProperty // java.lang.VerifyError: (class: NotImplemented, method: get signature: (Ljava/lang/Object;Lkotlin/reflect/KProperty;)Ljava/lang/Object;) Unable to pop operand off an empty stack class NotImplemented(){ - fun getValue(thisRef: Any?, prop: KProperty<*>): T = notImplemented() - fun setValue(thisRef: Any?, prop: KProperty<*>, value: T) = notImplemented() + operator fun getValue(thisRef: Any?, prop: KProperty<*>): T = notImplemented() + operator fun setValue(thisRef: Any?, prop: KProperty<*>, value: T) = notImplemented() } fun notImplemented() : Nothing = notImplemented() diff --git a/compiler/testData/codegen/box/typeMapping/kt3976.kt b/compiler/testData/codegen/box/typeMapping/kt3976.kt index 4ef9e8c07d7..47110878e72 100644 --- a/compiler/testData/codegen/box/typeMapping/kt3976.kt +++ b/compiler/testData/codegen/box/typeMapping/kt3976.kt @@ -4,11 +4,11 @@ import kotlin.reflect.KProperty var currentAccountId: Int? by SessionAccessor() class SessionAccessor { - fun getValue(o : Nothing?, desc: KProperty<*>): T { + operator fun getValue(o : Nothing?, desc: KProperty<*>): T { return null as T } - fun setValue(o : Nothing?, desc: KProperty<*>, value: T) { + operator fun setValue(o : Nothing?, desc: KProperty<*>, value: T) { } } diff --git a/compiler/testData/codegen/box/vararg/kt796_797.kt b/compiler/testData/codegen/box/vararg/kt796_797.kt index be848790975..ebb6be014c3 100644 --- a/compiler/testData/codegen/box/vararg/kt796_797.kt +++ b/compiler/testData/codegen/box/vararg/kt796_797.kt @@ -1,4 +1,4 @@ -fun Array?.get(i : Int?) = this!!.get(i!!) +operator fun Array?.get(i : Int?) = this!!.get(i!!) fun array(vararg t : T) : Array = t as Array fun box() : String { diff --git a/compiler/testData/codegen/box/when/longInRange.kt b/compiler/testData/codegen/box/when/longInRange.kt index 17bea8bd3fd..c73169ff600 100644 --- a/compiler/testData/codegen/box/when/longInRange.kt +++ b/compiler/testData/codegen/box/when/longInRange.kt @@ -1,5 +1,5 @@ class LongR { - fun contains(l : Long): Boolean = l == 5.toLong() + operator fun contains(l : Long): Boolean = l == 5.toLong() } fun box(): String { diff --git a/compiler/testData/codegen/boxAgainstJava/callableReference/publicMutableField.kt b/compiler/testData/codegen/boxAgainstJava/callableReference/publicMutableField.kt index 563afaaf69b..6958866e54a 100644 --- a/compiler/testData/codegen/boxAgainstJava/callableReference/publicMutableField.kt +++ b/compiler/testData/codegen/boxAgainstJava/callableReference/publicMutableField.kt @@ -4,7 +4,7 @@ fun box(): String { val a = A() val f = A::field if (f.get(a) != 239) return "Fail 1: ${f.get(a)}" - f[a] = 42 + f.set(a, 42) if (f.get(a) != 42) return "Fail 2: ${f.get(a)}" if (f.get(a) != 42) return "Fail 2: ${f.get(a)}" return "OK" diff --git a/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.java deleted file mode 100644 index 7b299431815..00000000000 --- a/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.java +++ /dev/null @@ -1,5 +0,0 @@ -class JavaClass { - void doSomething(Runnable i) { - i.run(); - } -} diff --git a/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.kt deleted file mode 100644 index 969631bbd61..00000000000 --- a/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.kt +++ /dev/null @@ -1,7 +0,0 @@ -fun box(): String { - val obj = JavaClass() - - var v = "FAIL" - obj doSomething { v = "OK" } - return v -} diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplit.2.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplit.2.kt index 57462caf683..5baf07999e6 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplit.2.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplit.2.kt @@ -2,7 +2,7 @@ package test public class Holder(var value: String = "") { - public fun plusAssign(s: String?) { + operator fun plusAssign(s: String?) { if (value.length() != 0) { value += " -> " } diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplitNoReturn.2.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplitNoReturn.2.kt index d6ba6580229..4258123efc6 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplitNoReturn.2.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplitNoReturn.2.kt @@ -2,7 +2,7 @@ package test public class Holder(var value: String = "") { - public fun plusAssign(s: String?) { + operator fun plusAssign(s: String?) { if (value.length() != 0) { value += " -> " } diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/exceptionInFinally.1.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/exceptionInFinally.1.kt index 84661766f8c..f63b7315953 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/exceptionInFinally.1.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/exceptionInFinally.1.kt @@ -6,7 +6,7 @@ import kotlin.test.fail class MyException(message: String) : Exception(message) class Holder(var value: String) { - public fun plusAssign(s: String?) { + operator fun plusAssign(s: String?) { value += s if (s != "closed") { value += "->" diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/tryCatchInFinally.2.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/tryCatchInFinally.2.kt index 57e72fe54b6..ea1355a25b1 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/tryCatchInFinally.2.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/tryCatchInFinally.2.kt @@ -2,7 +2,7 @@ package test public class Holder(var value: String = "") { - public fun plusAssign(s: String?) { + operator fun plusAssign(s: String?) { if (value.length() != 0) { value += " -> " } diff --git a/compiler/testData/codegen/boxInline/smap/resolve/inlineComponent.2.kt b/compiler/testData/codegen/boxInline/smap/resolve/inlineComponent.2.kt index 4ee86cf2d8d..7cdd760921b 100644 --- a/compiler/testData/codegen/boxInline/smap/resolve/inlineComponent.2.kt +++ b/compiler/testData/codegen/boxInline/smap/resolve/inlineComponent.2.kt @@ -2,8 +2,8 @@ package zzz public class A(val a: Int, val b: Int) -inline fun A.component1() = a +operator inline fun A.component1() = a -inline fun A.component2() = b +operator inline fun A.component2() = b //SMAP ABSENT \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/smap/resolve/inlineIterator.2.kt b/compiler/testData/codegen/boxInline/smap/resolve/inlineIterator.2.kt index 4fd2f073720..8c86c7b6f9e 100644 --- a/compiler/testData/codegen/boxInline/smap/resolve/inlineIterator.2.kt +++ b/compiler/testData/codegen/boxInline/smap/resolve/inlineIterator.2.kt @@ -2,6 +2,6 @@ package zzz public class A(val p: Int) -inline fun A.iterator() = (1..p).iterator() +operator inline fun A.iterator() = (1..p).iterator() //SMAP ABSENT \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/special/plusAssign.2.kt b/compiler/testData/codegen/boxInline/special/plusAssign.2.kt index aa534265ff3..2502da33fb1 100644 --- a/compiler/testData/codegen/boxInline/special/plusAssign.2.kt +++ b/compiler/testData/codegen/boxInline/special/plusAssign.2.kt @@ -2,6 +2,6 @@ package test public class Z(public var s: Int) -inline fun Z.plusAssign(lambda: () -> Int) { +operator inline fun Z.plusAssign(lambda: () -> Int) { this.s += lambda() } diff --git a/compiler/testData/codegen/boxWithJava/reflection/kotlinPropertyInheritedInJava/K.kt b/compiler/testData/codegen/boxWithJava/reflection/kotlinPropertyInheritedInJava/K.kt index 55c25777c33..e603d122d60 100644 --- a/compiler/testData/codegen/boxWithJava/reflection/kotlinPropertyInheritedInJava/K.kt +++ b/compiler/testData/codegen/boxWithJava/reflection/kotlinPropertyInheritedInJava/K.kt @@ -13,9 +13,9 @@ fun box(): String { val prop = J::prop if (prop !is KMutableProperty1<*, *>) return "Fail instanceof" if (prop.name != "prop") return "Fail name: ${prop.name}" - if (prop.get(j) != ":(") return "Fail get before: ${prop[j]}" - prop[j] = ":)" - if (prop.get(j) != ":)") return "Fail get after: ${prop[j]}" + if (prop.get(j) != ":(") return "Fail get before: ${prop.get(j)}" + prop.set(j, ":)") + if (prop.get(j) != ":)") return "Fail get after: ${prop.get(j)}" if (prop == K::prop) return "Fail J::prop == K::prop (these are different properties)" @@ -29,7 +29,7 @@ fun box(): String { if (prop != prop2) return "Fail: property references from :: and from properties differ: $prop != $prop2" if (prop2 !is KMutableProperty1<*, *>) return "Fail instanceof 2" (prop2 as KMutableProperty1).set(j, "::)") - if (prop.get(j) != "::)") return "Fail get after 2: ${prop[j]}" + if (prop.get(j) != "::)") return "Fail get after 2: ${prop.get(j)}" val ext = klass.memberExtensionProperties.firstOrNull { it.name == "ext" } ?: "Fail: no 'ext' property in memberExtensionProperties" diff --git a/compiler/testData/codegen/boxWithJava/reflection/mutatePrivateJavaInstanceField/K.kt b/compiler/testData/codegen/boxWithJava/reflection/mutatePrivateJavaInstanceField/K.kt index 8064ec98471..3365f880f9e 100644 --- a/compiler/testData/codegen/boxWithJava/reflection/mutatePrivateJavaInstanceField/K.kt +++ b/compiler/testData/codegen/boxWithJava/reflection/mutatePrivateJavaInstanceField/K.kt @@ -5,6 +5,6 @@ fun box(): String { val a = J() val p = J::class.members.single { it.name == "result" } as KMutableProperty1 p.isAccessible = true - p[a] = "OK" - return p[a] + p.set(a, "OK") + return p.get(a) } diff --git a/compiler/testData/codegen/boxWithJava/reflection/referenceToJavaFieldOfKotlinSubclass/K.kt b/compiler/testData/codegen/boxWithJava/reflection/referenceToJavaFieldOfKotlinSubclass/K.kt index 79a425eb69b..77f1ede74ec 100644 --- a/compiler/testData/codegen/boxWithJava/reflection/referenceToJavaFieldOfKotlinSubclass/K.kt +++ b/compiler/testData/codegen/boxWithJava/reflection/referenceToJavaFieldOfKotlinSubclass/K.kt @@ -3,5 +3,5 @@ open class K fun box(): String { val f = J::value val a = J() - return if (f.get(a) == 42) "OK" else "Fail: ${f[a]}" + return if (f.get(a) == 42) "OK" else "Fail: ${f.get(a)}" } diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/delegatedPropertySetter.kt b/compiler/testData/codegen/boxWithStdlib/annotations/delegatedPropertySetter.kt index a953dde912f..8d0ec0dc77c 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/delegatedPropertySetter.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/delegatedPropertySetter.kt @@ -9,11 +9,11 @@ class MyClass() { } class Delegate { - fun getValue(t: Any?, p: KProperty<*>): String { + operator fun getValue(t: Any?, p: KProperty<*>): String { return "OK" } - fun setValue(t: Any?, p: KProperty<*>, i: String) {} + operator fun setValue(t: Any?, p: KProperty<*>, i: String) {} } fun box(): String { diff --git a/compiler/testData/codegen/boxWithStdlib/arrays/arrayGetAssignMultiIndex.kt b/compiler/testData/codegen/boxWithStdlib/arrays/arrayGetAssignMultiIndex.kt index ece6e44a167..5e8e8bbd546 100644 --- a/compiler/testData/codegen/boxWithStdlib/arrays/arrayGetAssignMultiIndex.kt +++ b/compiler/testData/codegen/boxWithStdlib/arrays/arrayGetAssignMultiIndex.kt @@ -1,5 +1,5 @@ -fun Array.get(index1: Int, index2: Int) = this[index1 + index2] -fun Array.set(index1: Int, index2: Int, elem: String) { +operator fun Array.get(index1: Int, index2: Int) = this[index1 + index2] +operator fun Array.set(index1: Int, index2: Int, elem: String) { this[index1 + index2] = elem } diff --git a/compiler/testData/codegen/boxWithStdlib/arrays/arrayGetMultiIndex.kt b/compiler/testData/codegen/boxWithStdlib/arrays/arrayGetMultiIndex.kt index e476b7e8d57..6898a9b08e6 100644 --- a/compiler/testData/codegen/boxWithStdlib/arrays/arrayGetMultiIndex.kt +++ b/compiler/testData/codegen/boxWithStdlib/arrays/arrayGetMultiIndex.kt @@ -1,5 +1,5 @@ -fun Array.get(index1: Int, index2: Int) = this[index1 + index2] -fun Array.set(index1: Int, index2: Int, elem: String) { +operator fun Array.get(index1: Int, index2: Int) = this[index1 + index2] +operator fun Array.set(index1: Int, index2: Int, elem: String) { this[index1 + index2] = elem } diff --git a/compiler/testData/codegen/boxWithStdlib/arrays/cloneArray.kt b/compiler/testData/codegen/boxWithStdlib/arrays/cloneArray.kt index f0b493a9608..9b498cd820b 100644 --- a/compiler/testData/codegen/boxWithStdlib/arrays/cloneArray.kt +++ b/compiler/testData/codegen/boxWithStdlib/arrays/cloneArray.kt @@ -4,12 +4,12 @@ fun box(): String { val s = arrayOf("live", "long") val t: Array = s.clone() if (!equals(s, t)) return "Fail string" - if (s identityEquals t) return "Fail string identity" + if (s.identityEquals(t)) return "Fail string identity" val ss = arrayOf(s, s) val tt: Array> = ss.clone() if (!equals(ss, tt)) return "Fail string[]" - if (ss identityEquals tt) return "Fail string[] identity" + if (ss.identityEquals(tt)) return "Fail string[] identity" return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/arrays/clonePrimitiveArrays.kt b/compiler/testData/codegen/boxWithStdlib/arrays/clonePrimitiveArrays.kt index 61b45b5ef9c..a0a69ec455e 100644 --- a/compiler/testData/codegen/boxWithStdlib/arrays/clonePrimitiveArrays.kt +++ b/compiler/testData/codegen/boxWithStdlib/arrays/clonePrimitiveArrays.kt @@ -3,35 +3,35 @@ import java.util.Arrays.equals fun box(): String { val i = intArrayOf(1, 2) if (!equals(i, i.clone())) return "Fail int" - if (i.clone() identityEquals i) return "Fail int identity" + if (i.clone().identityEquals(i)) return "Fail int identity" val j = longArrayOf(1L, 2L) if (!equals(j, j.clone())) return "Fail long" - if (j.clone() identityEquals j) return "Fail long identity" + if (j.clone().identityEquals(j)) return "Fail long identity" val s = shortArrayOf(1.toShort(), 2.toShort()) if (!equals(s, s.clone())) return "Fail short" - if (s.clone() identityEquals s) return "Fail short identity" + if (s.clone().identityEquals(s)) return "Fail short identity" val b = byteArrayOf(1.toByte(), 2.toByte()) if (!equals(b, b.clone())) return "Fail byte" - if (b.clone() identityEquals b) return "Fail byte identity" + if (b.clone().identityEquals(b)) return "Fail byte identity" val c = charArrayOf('a', 'b') if (!equals(c, c.clone())) return "Fail char" - if (c.clone() identityEquals c) return "Fail char identity" + if (c.clone().identityEquals(c)) return "Fail char identity" val d = doubleArrayOf(1.0, -1.0) if (!equals(d, d.clone())) return "Fail double" - if (d.clone() identityEquals d) return "Fail double identity" + if (d.clone().identityEquals(d)) return "Fail double identity" val f = floatArrayOf(1f, -1f) if (!equals(f, f.clone())) return "Fail float" - if (f.clone() identityEquals f) return "Fail float identity" + if (f.clone().identityEquals(f)) return "Fail float identity" val z = booleanArrayOf(true, false) if (!equals(z, z.clone())) return "Fail boolean" - if (z.clone() identityEquals z) return "Fail boolean identity" + if (z.clone().identityEquals(z)) return "Fail boolean identity" return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/arrays/kt4357.kt b/compiler/testData/codegen/boxWithStdlib/arrays/kt4357.kt index 0bbb28adb38..95b92765fa4 100644 --- a/compiler/testData/codegen/boxWithStdlib/arrays/kt4357.kt +++ b/compiler/testData/codegen/boxWithStdlib/arrays/kt4357.kt @@ -1,8 +1,8 @@ fun box(): String { val array = intArrayOf(11, 12, 13) - val p = array get 0 + val p = array.get(0) if (p != 11) return "fail 1: $p" val stringArray = arrayOf("OK", "FAIL") - return stringArray get 0 + return stringArray.get(0) } \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithStdlib/arrays/stdlib.kt b/compiler/testData/codegen/boxWithStdlib/arrays/stdlib.kt index e7ff20e0b62..cd0ceb486fb 100644 --- a/compiler/testData/codegen/boxWithStdlib/arrays/stdlib.kt +++ b/compiler/testData/codegen/boxWithStdlib/arrays/stdlib.kt @@ -17,15 +17,15 @@ class MyIterator(val array : ReadOnlyArray) : javaUtilIterator { } interface ReadOnlyArray : ISized, Iterable { - fun get(index : Int) : T + operator fun get(index : Int) : T override fun iterator() : Iterator = MyIterator(this) } interface WriteOnlyArray : ISized { - fun set(index : Int, value : T) : Unit + operator fun set(index : Int, value : T) : Unit - fun set(from: Int, count: Int, value: T) { + operator fun set(from: Int, count: Int, value: T) { for(i in from..from+count-1) { set(i, value) } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/sortListOfStrings.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/sortListOfStrings.kt index 800384f8a51..20a2f3be594 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/sortListOfStrings.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/sortListOfStrings.kt @@ -9,7 +9,7 @@ fun sort(list: MutableList, comparator: (String, String) -> Int) { }) } -fun compare(s1: String, s2: String) = s1 compareTo s2 +fun compare(s1: String, s2: String) = s1.compareTo(s2) fun box(): String { val l = ArrayList(Arrays.asList("d", "b", "c", "e", "a")) diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/delegated.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/delegated.kt index 7fda779ddc0..00b880be84e 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/delegated.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/delegated.kt @@ -7,7 +7,7 @@ class A { } object NumberDecrypter { - fun getValue(instance: Any?, data: KProperty<*>) = when (data.name) { + operator fun getValue(instance: Any?, data: KProperty<*>) = when (data.name) { "four" -> 4 "two" -> 2 else -> throw AssertionError() diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/delegatedMutable.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/delegatedMutable.kt index 056b5bbd698..3bc30b3c17d 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/delegatedMutable.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/delegatedMutable.kt @@ -5,11 +5,11 @@ var result: String by Delegate object Delegate { var value = "lol" - fun getValue(instance: Any?, data: KProperty<*>): String { + operator fun getValue(instance: Any?, data: KProperty<*>): String { return value } - fun setValue(instance: Any?, data: KProperty<*>, newValue: String) { + operator fun setValue(instance: Any?, data: KProperty<*>, newValue: String) { value = newValue } } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/genericProperty.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/genericProperty.kt index 7c33ab4dfdf..a30bcbd89bd 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/genericProperty.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/genericProperty.kt @@ -10,7 +10,7 @@ val Value.additionalText by DVal(Value::text) //works val Value.additionalValue by DVal(Value::value) //not work class DVal>(val kmember: P) { - fun getValue(t: T, p: KProperty<*>): R { + operator fun getValue(t: T, p: KProperty<*>): R { return kmember.get(t) } } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleExtension.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleExtension.kt index 7e6b5c92df1..28d7199fe8d 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleExtension.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleExtension.kt @@ -4,7 +4,7 @@ val String.id: String fun box(): String { val pr = String::id - if (pr["123"] != "123") return "Fail value: ${pr["123"]}" + if (pr.get("123") != "123") return "Fail value: ${pr.get("123")}" if (pr.name != "id") return "Fail name: ${pr.name}" diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleMutableExtension.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleMutableExtension.kt index 0d5c562bcff..e69cbbe72fc 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleMutableExtension.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleMutableExtension.kt @@ -10,9 +10,9 @@ var Int.foo: Int fun box(): String { val pr = Int::foo - if (pr.get(42) != 42) return "Fail 1: ${pr[42]}" + if (pr.get(42) != 42) return "Fail 1: ${pr.get(42)}" pr.set(200, 39) - if (pr.get(-239) != 0) return "Fail 2: ${pr[-239]}" + if (pr.get(-239) != 0) return "Fail 2: ${pr.get(-239)}" if (storage != 239) return "Fail 3: $storage" return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleMutableMember.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleMutableMember.kt index a187f252008..f7d815af3fc 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleMutableMember.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/simpleMutableMember.kt @@ -4,9 +4,9 @@ fun box(): String { val o = Box("lorem") val prop = Box::value - if (prop.get(o) != "lorem") return "Fail 1: ${prop[o]}" + if (prop.get(o) != "lorem") return "Fail 1: ${prop.get(o)}" prop.set(o, "ipsum") - if (prop.get(o) != "ipsum") return "Fail 2: ${prop[o]}" + if (prop.get(o) != "ipsum") return "Fail 2: ${prop.get(o)}" if (o.value != "ipsum") return "Fail 3: ${o.value}" o.value = "dolor" if (prop.get(o) != "dolor") return "Fail 4: ${prop.get(o)}" diff --git a/compiler/testData/codegen/boxWithStdlib/classes/kt471.kt b/compiler/testData/codegen/boxWithStdlib/classes/kt471.kt index de15f28528f..4de658a6626 100644 --- a/compiler/testData/codegen/boxWithStdlib/classes/kt471.kt +++ b/compiler/testData/codegen/boxWithStdlib/classes/kt471.kt @@ -1,5 +1,5 @@ class MyNumber(val i: Int) { - fun inc(): MyNumber = MyNumber(i+1) + operator fun inc(): MyNumber = MyNumber(i+1) } class MNR(var ref: MyNumber) {} @@ -53,12 +53,12 @@ fun test6() : Boolean { class MyArrayList() { private var value17: T? = null private var value39: T? = null - fun get(index: Int): T { + operator fun get(index: Int): T { if (index == 17) return value17!! if (index == 39) return value39!! throw Exception() } - fun set(index: Int, value: T): T? { + operator fun set(index: Int, value: T): T? { if (index == 17) value17 = value else if (index == 39) value39 = value else throw Exception() diff --git a/compiler/testData/codegen/boxWithStdlib/classes/kt633.kt b/compiler/testData/codegen/boxWithStdlib/classes/kt633.kt index 49e543404aa..79b61fa0ad0 100644 --- a/compiler/testData/codegen/boxWithStdlib/classes/kt633.kt +++ b/compiler/testData/codegen/boxWithStdlib/classes/kt633.kt @@ -1,13 +1,13 @@ class mInt(val i : Int) { override fun toString() : String = "mint: $i" - fun plus(i : Int) = mInt(this.i + i) - fun inc() = mInt(i + 1) + operator fun plus(i : Int) = mInt(this.i + i) + operator fun inc() = mInt(i + 1) } class MyArray() { val a = Array(10, {mInt(0)}) - fun get(i : mInt) : mInt = a[i.i] - fun set(i : mInt, v : mInt) { + operator fun get(i : mInt) : mInt = a[i.i] + operator fun set(i : mInt, v : mInt) { a[i.i] = v } } diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/equals/alreadyDeclared.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/equals/alreadyDeclared.kt index 5aaf2403250..65e9e5b9bcf 100644 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/equals/alreadyDeclared.kt +++ b/compiler/testData/codegen/boxWithStdlib/dataClasses/equals/alreadyDeclared.kt @@ -4,5 +4,5 @@ data class A(val x: Int) { fun box(): String { val a = A(0) - return if (a equals a) "fail" else "OK" + return if (a.equals(a)) "fail" else "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithStdlib/delegatedProperty/stackOverflowOnCallFromGetValue.kt b/compiler/testData/codegen/boxWithStdlib/delegatedProperty/stackOverflowOnCallFromGetValue.kt index 83e85fc4015..3b577802838 100644 --- a/compiler/testData/codegen/boxWithStdlib/delegatedProperty/stackOverflowOnCallFromGetValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/delegatedProperty/stackOverflowOnCallFromGetValue.kt @@ -4,14 +4,14 @@ import java.lang.reflect.InvocationTargetException import kotlin.reflect.* object Delegate { - fun getValue(t: Any?, p: KProperty<*>): String { + operator fun getValue(t: Any?, p: KProperty<*>): String { (p as? KProperty0)?.get() (p as? KProperty1)?.get(O) (p as? KProperty2)?.get(O, O) return "Fail" } - fun setValue(t: Any?, p: KProperty<*>, v: String) { + operator fun setValue(t: Any?, p: KProperty<*>, v: String) { (p as? KMutableProperty0)?.set(v) (p as? KMutableProperty1)?.set(O, v) (p as? KMutableProperty2)?.set(O, O, v) diff --git a/compiler/testData/codegen/boxWithStdlib/delegatedProperty/useKPropertyLater.kt b/compiler/testData/codegen/boxWithStdlib/delegatedProperty/useKPropertyLater.kt index 99900817655..6d29f44bb08 100644 --- a/compiler/testData/codegen/boxWithStdlib/delegatedProperty/useKPropertyLater.kt +++ b/compiler/testData/codegen/boxWithStdlib/delegatedProperty/useKPropertyLater.kt @@ -4,12 +4,12 @@ import kotlin.reflect.* val properties = HashSet>() object Delegate { - fun getValue(t: Any?, p: KProperty<*>): String { + operator fun getValue(t: Any?, p: KProperty<*>): String { properties.add(p) return "" } - fun setValue(t: Any?, p: KProperty<*>, v: String) { + operator fun setValue(t: Any?, p: KProperty<*>, v: String) { properties.add(p) } } diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/infixCallBinary.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/infixCallBinary.kt deleted file mode 100644 index 67dcb63d816..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/infixCallBinary.kt +++ /dev/null @@ -1,20 +0,0 @@ -@Retention(AnnotationRetention.RUNTIME) -annotation class Ann( - val p1: Int, - val p2: Int, - val p3: Int, - val p4: Int, - val p5: Int -) - -@Ann(1 plus 1, 1 minus 1, 1 times 1, 1 div 1, 1 mod 1) class MyClass - -fun box(): String { - val annotation = javaClass().getAnnotation(javaClass())!! - if (annotation.p1 != 2) return "fail 1" - if (annotation.p2 != 0) return "fail 2" - if (annotation.p3 != 1) return "fail 3" - if (annotation.p4 != 1) return "fail 4" - if (annotation.p5 != 0) return "fail 5" - return "OK" -} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1202.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1202.kt index b95c0cb3fd9..149c87a9a78 100644 --- a/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1202.kt +++ b/compiler/testData/codegen/boxWithStdlib/fullJdk/regressions/kt1202.kt @@ -45,14 +45,14 @@ class Error(text : String) : Token("[Error: $text]") fun tokenize(text : String) : Deque { val result = LinkedList() for (c in text) { - result add when (c) { + result.add(when (c) { '(' -> LPAR ')' -> RPAR '+' -> PLUS '*' -> TIMES in '0'..'9' -> Number(c.toString()) else -> Error(c.toString()) - } + }) } result.add(EOF) return result diff --git a/compiler/testData/codegen/boxWithStdlib/fullJdk/smap/infixCalls.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/smap/infixCalls.kt index e7c56caf360..3f2920d5a41 100644 --- a/compiler/testData/codegen/boxWithStdlib/fullJdk/smap/infixCalls.kt +++ b/compiler/testData/codegen/boxWithStdlib/fullJdk/smap/infixCalls.kt @@ -53,7 +53,7 @@ inline fun test(): String { return "123" } -fun String.fail(p: String): String { +infix fun String.fail(p: String): String { throw AssertionError("fail") } diff --git a/compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/exceptionInMonitorExpression.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/exceptionInMonitorExpression.kt index 7e132d06d17..66d71c7e697 100644 --- a/compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/exceptionInMonitorExpression.kt +++ b/compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/exceptionInMonitorExpression.kt @@ -8,7 +8,7 @@ fun box(): String { } } catch (caught: Throwable) { - if (!(caught identityEquals e)) return "Fail: $caught" + if (!(caught.identityEquals(e))) return "Fail: $caught" } return "OK" diff --git a/compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/finally.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/finally.kt index 3ba247fccfa..cf0797eeac4 100644 --- a/compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/finally.kt +++ b/compiler/testData/codegen/boxWithStdlib/fullJdk/synchronized/finally.kt @@ -8,7 +8,7 @@ fun box(): String { } } catch (caught: Throwable) { - if (!(caught identityEquals e)) return "Fail: $caught" + if (!(caught.identityEquals(e))) return "Fail: $caught" // If monitorexit didn't happen (a finally block failed), this assertion would fail assertThatThreadDoesNotOwnMonitor(obj) } diff --git a/compiler/testData/codegen/boxWithStdlib/jvmStatic/convention.kt b/compiler/testData/codegen/boxWithStdlib/jvmStatic/convention.kt index 7f00683f2ca..979bad60814 100644 --- a/compiler/testData/codegen/boxWithStdlib/jvmStatic/convention.kt +++ b/compiler/testData/codegen/boxWithStdlib/jvmStatic/convention.kt @@ -8,7 +8,7 @@ object A { v += B(1000) } - @JvmStatic fun B.plusAssign(b: B) { + @JvmStatic operator fun B.plusAssign(b: B) { this.s += b.s } } diff --git a/compiler/testData/codegen/boxWithStdlib/lazyCodegen/increment.kt b/compiler/testData/codegen/boxWithStdlib/lazyCodegen/increment.kt index 1d9a8d9cebb..40369fff4af 100644 --- a/compiler/testData/codegen/boxWithStdlib/lazyCodegen/increment.kt +++ b/compiler/testData/codegen/boxWithStdlib/lazyCodegen/increment.kt @@ -10,7 +10,7 @@ class A(val p: Int) { var prop = this - fun inc(): A { + operator fun inc(): A { return A(p+1) } diff --git a/compiler/testData/codegen/boxWithStdlib/lazyCodegen/optimizations/noOptimization.kt b/compiler/testData/codegen/boxWithStdlib/lazyCodegen/optimizations/noOptimization.kt index d7e523c44bf..1437d56484b 100644 --- a/compiler/testData/codegen/boxWithStdlib/lazyCodegen/optimizations/noOptimization.kt +++ b/compiler/testData/codegen/boxWithStdlib/lazyCodegen/optimizations/noOptimization.kt @@ -3,12 +3,12 @@ class B var holder = 0 -fun A.not(): A { +operator fun A.not(): A { holder++ return this; } -fun B.not(): Boolean { +operator fun B.not(): Boolean { holder++ return false; } diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclFor.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclFor.kt index 9ae7bc19e81..8657604547a 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclFor.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclFor.kt @@ -1,6 +1,6 @@ class C(val i: Int) { - fun component1() = i + 1 - fun component2() = i + 2 + operator fun component1() = i + 1 + operator fun component2() = i + 2 } fun doTest(l : Array): String { diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentExtensions.kt index dea403c786c..056a9f5f793 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentExtensions.kt @@ -1,8 +1,8 @@ class C(val i: Int) { } -fun C.component1() = i + 1 -fun C.component2() = i + 2 +operator fun C.component1() = i + 1 +operator fun C.component2() = i + 2 fun doTest(l : Array): String { var s = "" diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentMemberExtensions.kt index 8579b88efc4..6a9f6be2409 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentMemberExtensions.kt @@ -2,8 +2,8 @@ class C(val i: Int) { } class M { - fun C.component1() = i + 1 - fun C.component2() = i + 2 + operator fun C.component1() = i + 1 + operator fun C.component2() = i + 2 fun doTest(l : Array): String { var s = "" diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index 298a71a5146..376aabb2466 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -2,8 +2,8 @@ class C(val i: Int) { } class M { - fun C.component1() = i + 1 - fun C.component2() = i + 2 + operator fun C.component1() = i + 1 + operator fun C.component2() = i + 2 } fun M.doTest(l : Array): String { diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForValCaptured.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForValCaptured.kt index 88d24eddce8..f25b504d607 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForValCaptured.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclForValCaptured.kt @@ -1,6 +1,6 @@ class C(val i: Int) { - fun component1() = i + 1 - fun component2() = i + 2 + operator fun component1() = i + 1 + operator fun component2() = i + 2 } fun doTest(l : Array): String { diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentExtensions.kt index fb9e0ad2b4d..f0687781516 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentExtensions.kt @@ -1,5 +1,5 @@ -fun Int.component1() = this + 1 -fun Int.component2() = this + 2 +operator fun Int.component1() = this + 1 +operator fun Int.component2() = this + 2 fun doTest(l : Array): String { var s = "" diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentExtensionsValCaptured.kt index b3db747fcd4..3dda25067f3 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentExtensionsValCaptured.kt @@ -1,5 +1,5 @@ -fun Int.component1() = this + 1 -fun Int.component2() = this + 2 +operator fun Int.component1() = this + 1 +operator fun Int.component2() = this + 2 fun doTest(l : Array): String { var s = "" diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentMemberExtensions.kt index 73a508d2641..2cf40134bf3 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentMemberExtensions.kt @@ -1,6 +1,6 @@ class M { - fun Int.component1() = this + 1 - fun Int.component2() = this + 2 + operator fun Int.component1() = this + 1 + operator fun Int.component2() = this + 2 fun doTest(l : Array): String { var s = "" diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index c4473762c3d..9ad2af28556 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/int/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,6 +1,6 @@ class M { - fun Int.component1() = this + 1 - fun Int.component2() = this + 2 + operator fun Int.component1() = this + 1 + operator fun Int.component2() = this + 2 } fun M.doTest(l : Array): String { diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentExtensions.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentExtensions.kt index b44769aeb7b..0ca7fc49d13 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentExtensions.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentExtensions.kt @@ -1,5 +1,5 @@ -fun Long.component1() = this + 1 -fun Long.component2() = this + 2 +operator fun Long.component1() = this + 1 +operator fun Long.component2() = this + 2 fun doTest(l : Array): String { var s = "" diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentExtensionsValCaptured.kt index c43026c494b..3e610b49997 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentExtensionsValCaptured.kt @@ -1,5 +1,5 @@ -fun Long.component1() = this + 1 -fun Long.component2() = this + 2 +operator fun Long.component1() = this + 1 +operator fun Long.component2() = this + 2 fun doTest(l : Array): String { var s = "" diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentMemberExtensions.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentMemberExtensions.kt index 638344c91fd..dad12c6d80f 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentMemberExtensions.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentMemberExtensions.kt @@ -1,6 +1,6 @@ class M { - fun Long.component1() = this + 1 - fun Long.component2() = this + 2 + operator fun Long.component1() = this + 1 + operator fun Long.component2() = this + 2 fun doTest(l : Array): String { var s = "" diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt index b1b646ac6a3..fde531f8d21 100644 --- a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/long/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt @@ -1,6 +1,6 @@ class M { - fun Long.component1() = this + 1 - fun Long.component2() = this + 2 + operator fun Long.component1() = this + 1 + operator fun Long.component2() = this + 2 } fun M.doTest(l : Array): String { diff --git a/compiler/testData/codegen/boxWithStdlib/nonLocalReturns/use.kt b/compiler/testData/codegen/boxWithStdlib/nonLocalReturns/use.kt index 576ba6e6c21..468c5508dd5 100644 --- a/compiler/testData/codegen/boxWithStdlib/nonLocalReturns/use.kt +++ b/compiler/testData/codegen/boxWithStdlib/nonLocalReturns/use.kt @@ -3,7 +3,7 @@ import java.io.Closeable class MyException(message: String) : Exception(message) class Holder(var value: String) { - public fun plusAssign(s: String?) { + operator fun plusAssign(s: String?) { value += s if (s != "closed") { value += "->" diff --git a/compiler/testData/codegen/boxWithStdlib/nonLocalReturns/useWithException.kt b/compiler/testData/codegen/boxWithStdlib/nonLocalReturns/useWithException.kt index 083e27a85b5..03bd17f76e2 100644 --- a/compiler/testData/codegen/boxWithStdlib/nonLocalReturns/useWithException.kt +++ b/compiler/testData/codegen/boxWithStdlib/nonLocalReturns/useWithException.kt @@ -6,7 +6,7 @@ import kotlin.test.assertEquals class MyException(message: String) : Exception(message) class Holder(var value: String) { - public fun plusAssign(s: String?) { + operator fun plusAssign(s: String?) { value += s if (s != "closed") { value += "->" diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/multiAssignmentIterationOverIntRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/multiAssignmentIterationOverIntRange.kt index 59a7bb40710..01edfadc0ce 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/multiAssignmentIterationOverIntRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/multiAssignmentIterationOverIntRange.kt @@ -1,8 +1,8 @@ -fun Int.component1(): String { +operator fun Int.component1(): String { return arrayListOf("zero", "one", "two", "three")[this] } -fun Int.component2(): Int { +operator fun Int.component2(): Int { return arrayListOf(0, 1, 4, 9)[this] } diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/getExtensionPropertiesMutableVsReadonly.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/getExtensionPropertiesMutableVsReadonly.kt index dc06a359b10..35660897e50 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/properties/getExtensionPropertiesMutableVsReadonly.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/getExtensionPropertiesMutableVsReadonly.kt @@ -20,7 +20,7 @@ fun box(): String { val a = A() mutable as KMutableProperty2 - assert(mutable[a, ""] == "before") { "Fail 3: ${mutable.get(a, "")}" } - mutable[a, ""] = "OK" + assert(mutable.get(a, "") == "before") { "Fail 3: ${mutable.get(a, "")}" } + mutable.set(a, "", "OK") return mutable.get(a, "") } diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/getPropertiesMutableVsReadonly.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/getPropertiesMutableVsReadonly.kt index 4b32193bf99..e37c6139eae 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/properties/getPropertiesMutableVsReadonly.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/getPropertiesMutableVsReadonly.kt @@ -13,7 +13,7 @@ fun box(): String { val a = A("") mutable as KMutableProperty1 - assert(mutable[a] == "before") { "Fail 3: ${mutable.get(a)}" } - mutable[a] = "OK" + assert(mutable.get(a) == "before") { "Fail 3: ${mutable.get(a)}" } + mutable.set(a, "OK") return mutable.get(a) } diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/memberAndMemberExtensionWithSameName.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/memberAndMemberExtensionWithSameName.kt index 9e5e7a6e02c..51646a5a991 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/properties/memberAndMemberExtensionWithSameName.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/memberAndMemberExtensionWithSameName.kt @@ -9,14 +9,14 @@ fun box(): String { run { val foo: KProperty1 = javaClass().kotlin.memberProperties.single() assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" } - assert(foo.get(A()) == "member") { "Fail value: ${foo[A()]}" } + assert(foo.get(A()) == "member") { "Fail value: ${foo.get(A())}" } } run { val foo: KProperty2 = javaClass().kotlin.memberExtensionProperties.single() assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" } foo as KProperty2 - assert(foo.get(A(), Unit) == "extension") { "Fail value: ${foo[A(), Unit]}" } + assert(foo.get(A(), Unit) == "extension") { "Fail value: ${foo.get(A(), Unit)}" } } return "OK" diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/privatePlatformStaticVarInObject.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/privatePlatformStaticVarInObject.kt index cfba807e447..65b3e042dd0 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/properties/privatePlatformStaticVarInObject.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/privatePlatformStaticVarInObject.kt @@ -11,15 +11,15 @@ fun box(): String { p.isAccessible = true try { - p[null] = "OK" + p.set(null, "OK") return "Fail: set should check that first argument is Obj" } catch (e: IllegalArgumentException) {} try { - p[null] + p.get(null) return "Fail: get should check that first argument is Obj" } catch (e: IllegalArgumentException) {} - p[Obj] = "OK" - return p[Obj] + p.set(Obj, "OK") + return p.get(Obj) } diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/protectedClassVar.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/protectedClassVar.kt index cd2f7f9f6ae..c28c12e597c 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/properties/protectedClassVar.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/protectedClassVar.kt @@ -25,5 +25,5 @@ fun box(): String { f.set(a, ":)") - return if (f[a] != ":)") "Fail: ${f[a]}" else "OK" + return if (f.get(a) != ":)") "Fail: ${f.get(a)}" else "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/reified/DIExample.kt b/compiler/testData/codegen/boxWithStdlib/reified/DIExample.kt index 2e3848078af..2a9ad1bd2f1 100644 --- a/compiler/testData/codegen/boxWithStdlib/reified/DIExample.kt +++ b/compiler/testData/codegen/boxWithStdlib/reified/DIExample.kt @@ -10,7 +10,7 @@ class Project { } } -inline fun Project.getValue(t: Any?, p: KProperty<*>): T = getInstance(javaClass()) +inline operator fun Project.getValue(t: Any?, p: KProperty<*>): T = getInstance(javaClass()) val project = Project() val x1: Int by project diff --git a/compiler/testData/codegen/bytecodeText/componentEvaluatesOnlyOnce.kt b/compiler/testData/codegen/bytecodeText/componentEvaluatesOnlyOnce.kt index 251bf130ba9..ed3de259788 100644 --- a/compiler/testData/codegen/bytecodeText/componentEvaluatesOnlyOnce.kt +++ b/compiler/testData/codegen/bytecodeText/componentEvaluatesOnlyOnce.kt @@ -1,9 +1,9 @@ class S(val a: String, val b: String) { - fun component1() : String = a - fun component2() : String = b + operator fun component1() : String = a + operator fun component2() : String = b } -fun S.component3() = ((a + b) as java.lang.String).substring(2) +operator fun S.component3() = ((a + b) as java.lang.String).substring(2) class Tester() { fun box() : String { @@ -11,7 +11,7 @@ class Tester() { return o + k + ok + ok2 } - fun S.component4() = ((a + b) as java.lang.String).substring(2) + operator fun S.component4() = ((a + b) as java.lang.String).substring(2) } fun box() = Tester().box() diff --git a/compiler/testData/codegen/bytecodeText/stringOperations/infixPlus.kt b/compiler/testData/codegen/bytecodeText/stringOperations/infixPlus.kt deleted file mode 100644 index 03057e0a39a..00000000000 --- a/compiler/testData/codegen/bytecodeText/stringOperations/infixPlus.kt +++ /dev/null @@ -1,17 +0,0 @@ -class A() { - - override fun toString(): String { - return "A" - } -} - - -fun box() : String { - - val s = "1" plus "2" plus 3 plus 4L plus 5.0 plus 6F plus '7' plus A() - - return "OK" -} - -/*TODO: -1 NEW java/lang/StringBuilder*/ diff --git a/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt b/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt index d3643218d1d..05c9d12b8f7 100644 --- a/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt +++ b/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt @@ -1,5 +1,5 @@ class AssertionChecker(val illegalStateExpected: Boolean) { - fun invoke(name: String, f: () -> Any) { + operator fun invoke(name: String, f: () -> Any) { try { f() } catch (e: IllegalStateException) { @@ -71,5 +71,5 @@ fun checkAssertions(illegalStateExpected: Boolean) { // check("inc-c") { var a = A.C.c(); ++a } } -fun A.C.inc(): A.C = A.C() -fun T.inc(): T = null as T +operator fun A.C.inc(): A.C = A.C() +operator fun T.inc(): T = null as T diff --git a/compiler/testData/codegen/properties/privateClassPropertyAccessors.kt b/compiler/testData/codegen/properties/privateClassPropertyAccessors.kt index 73d4613a022..21e4230aa96 100644 --- a/compiler/testData/codegen/properties/privateClassPropertyAccessors.kt +++ b/compiler/testData/codegen/properties/privateClassPropertyAccessors.kt @@ -27,7 +27,7 @@ class C { object Delegate { - fun getValue(x: C, p: KProperty<*>) = throw AssertionError() + operator fun getValue(x: C, p: KProperty<*>) = throw AssertionError() - fun setValue(x: C, p: KProperty<*>, value: Int) = throw AssertionError() + operator fun setValue(x: C, p: KProperty<*>, value: Int) = throw AssertionError() } diff --git a/compiler/testData/diagnostics/tests/incompleteCode/plusOnTheRight.kt b/compiler/testData/diagnostics/tests/incompleteCode/plusOnTheRight.kt index 7ae36b27c2e..ca4a8354714 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/plusOnTheRight.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/plusOnTheRight.kt @@ -2,9 +2,9 @@ package a class MyClass1 { - public operator fun plus() {} + public operator fun unaryPlus() {} } fun main(arg: MyClass1) { - arg+ + arg+ } diff --git a/compiler/testData/diagnostics/tests/incompleteCode/plusOnTheRight.txt b/compiler/testData/diagnostics/tests/incompleteCode/plusOnTheRight.txt index fdf48e5c0ec..ddd632f88f6 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/plusOnTheRight.txt +++ b/compiler/testData/diagnostics/tests/incompleteCode/plusOnTheRight.txt @@ -7,7 +7,7 @@ package a { public constructor MyClass1() 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 final operator fun plus(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public final operator fun unaryPlus(): kotlin.Unit } } diff --git a/compiler/testData/diagnostics/tests/redeclarations/ScriptAndClassConflict.txt b/compiler/testData/diagnostics/tests/redeclarations/ScriptAndClassConflict.txt index cf0832616a7..5665f6255c9 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/ScriptAndClassConflict.txt +++ b/compiler/testData/diagnostics/tests/redeclarations/ScriptAndClassConflict.txt @@ -2,13 +2,6 @@ package package test { - public final class A { - public constructor A() - 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 toString(): kotlin.String - } - public final class A { public constructor A() public final val x: kotlin.Int = 1 @@ -24,6 +17,13 @@ package test { } } + public final class A { + public constructor A() + 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 toString(): kotlin.String + } + public final class F1 { public constructor F1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/scopes/kt250.617.10.kt b/compiler/testData/diagnostics/tests/scopes/kt250.617.10.kt index 8129834a443..b4b15fc708a 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt250.617.10.kt +++ b/compiler/testData/diagnostics/tests/scopes/kt250.617.10.kt @@ -21,7 +21,7 @@ abstract class Tag(val name : String) { } abstract class TagWithText(name : String) : Tag(name) { - fun String.plus() { + operator fun String.unaryPlus() { children.add(TextElement(this)) } } diff --git a/compiler/testData/diagnostics/tests/scopes/kt250.617.10.txt b/compiler/testData/diagnostics/tests/scopes/kt250.617.10.txt index 602ec7bc025..427f12bff1b 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt250.617.10.txt +++ b/compiler/testData/diagnostics/tests/scopes/kt250.617.10.txt @@ -26,7 +26,7 @@ package kt_250_617_10 { 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 toString(): kotlin.String - public final override /*1*/ /*fake_override*/ fun kotlin.String.plus(): kotlin.Unit + public final override /*1*/ /*fake_override*/ fun kotlin.String.unaryPlus(): kotlin.Unit } public final class Body1 : kt_250_617_10.BodyTag { @@ -37,7 +37,7 @@ package kt_250_617_10 { 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 toString(): kotlin.String - public final override /*1*/ /*fake_override*/ fun kotlin.String.plus(): kotlin.Unit + public final override /*1*/ /*fake_override*/ fun kotlin.String.unaryPlus(): kotlin.Unit } public open class BodyTag : kt_250_617_10.TagWithText { @@ -48,7 +48,7 @@ package kt_250_617_10 { 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 toString(): kotlin.String - public final override /*1*/ /*fake_override*/ fun kotlin.String.plus(): kotlin.Unit + public final override /*1*/ /*fake_override*/ fun kotlin.String.unaryPlus(): kotlin.Unit } public open class Element { @@ -92,7 +92,7 @@ package kt_250_617_10 { 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 toString(): kotlin.String - public final fun kotlin.String.plus(): kotlin.Unit + public final operator fun kotlin.String.unaryPlus(): kotlin.Unit } public final class TextElement : kt_250_617_10.Element { diff --git a/compiler/testData/lineNumber/custom/multilineInfixCall.kt b/compiler/testData/lineNumber/custom/multilineInfixCall.kt index 123694c3129..8669cb4fde5 100644 --- a/compiler/testData/lineNumber/custom/multilineInfixCall.kt +++ b/compiler/testData/lineNumber/custom/multilineInfixCall.kt @@ -3,7 +3,7 @@ fun foo() { 1 } -fun Int.foo(i: Int) { +infix fun Int.foo(i: Int) { } // 2 4 7 diff --git a/compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt b/compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt index 0d815f84177..c80a24249e5 100644 --- a/compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt +++ b/compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt @@ -1,4 +1,4 @@ -fun String.execute(p: String) = this + p +infix fun String.execute(p: String) = this + p fun box(){ test() execute diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.kt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.kt index 27d124fb4f3..d16b8591705 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.kt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.kt @@ -6,6 +6,6 @@ annotation class Anno class Class { @Anno val x: Int by object { - fun getValue(thiz: Class, data: KProperty<*>) = null!! + operator fun getValue(thiz: Class, data: KProperty<*>) = null!! } } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.kt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.kt index 32944f1998e..0662beba560 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.kt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.kt @@ -5,5 +5,5 @@ import kotlin.reflect.KProperty annotation class Anno @Anno val x: Int by object { - fun getValue(thiz: Any?, data: KProperty<*>) = null!! + operator fun getValue(thiz: Any?, data: KProperty<*>) = null!! } diff --git a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/library/Max.kt b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/library/Max.kt index 4c4fce88b50..2fd2ec91aac 100644 --- a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/library/Max.kt +++ b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/library/Max.kt @@ -1,7 +1,7 @@ package test public open class Max { - public open fun max(p0 : Collection?): T? where T : Comparable? { + public open fun max(p0 : Collection?): T? where T : Comparable? { throw UnsupportedOperationException() } } diff --git a/compiler/testData/loadJava/compiledKotlin/prop/VarWithDelegated.kt b/compiler/testData/loadJava/compiledKotlin/prop/VarWithDelegated.kt index 83754b6bf3a..19b04a271a4 100644 --- a/compiler/testData/loadJava/compiledKotlin/prop/VarWithDelegated.kt +++ b/compiler/testData/loadJava/compiledKotlin/prop/VarWithDelegated.kt @@ -8,6 +8,6 @@ class A { } class MyProperty { - fun getValue(t: T, p: KProperty<*>): Int = 42 - fun setValue(t: T, p: KProperty<*>, i: Int) {} + operator fun getValue(t: T, p: KProperty<*>): Int = 42 + operator fun setValue(t: T, p: KProperty<*>, i: Int) {} } diff --git a/compiler/testData/loadJava/compiledKotlin/prop/VarWithDelegated.txt b/compiler/testData/loadJava/compiledKotlin/prop/VarWithDelegated.txt index 1bd8ea99ba2..e818aeff9cb 100644 --- a/compiler/testData/loadJava/compiledKotlin/prop/VarWithDelegated.txt +++ b/compiler/testData/loadJava/compiledKotlin/prop/VarWithDelegated.txt @@ -9,6 +9,6 @@ public final class A { public final class MyProperty { /*primary*/ public constructor MyProperty() - public final fun getValue(/*0*/ t: T, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.Int - public final fun setValue(/*0*/ t: T, /*1*/ p: kotlin.reflect.KProperty<*>, /*2*/ i: kotlin.Int): kotlin.Unit + public final operator fun getValue(/*0*/ t: T, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.Int + public final operator fun setValue(/*0*/ t: T, /*1*/ p: kotlin.reflect.KProperty<*>, /*2*/ i: kotlin.Int): kotlin.Unit } diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/infixCallBinary.kt b/compiler/testData/resolveAnnotations/parameters/expressions/infixCallBinary.kt deleted file mode 100644 index 62b957802de..00000000000 --- a/compiler/testData/resolveAnnotations/parameters/expressions/infixCallBinary.kt +++ /dev/null @@ -1,13 +0,0 @@ -package test - -annotation class Ann( - val p1: Int, - val p2: Int, - val p3: Int, - val p4: Int, - val p5: Int -) - -@Ann(1 plus 1, 1 minus 1, 1 times 1, 1 div 1, 1 mod 1) class MyClass - -// EXPECTED: @Ann(p1 = 2, p2 = 0, p3 = 1, p4 = 1, p5 = 0) diff --git a/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.kt b/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.kt index e2d8f9f38ed..aef123ec902 100644 --- a/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.kt +++ b/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.kt @@ -13,7 +13,7 @@ abstract class Tag(val name: String): Element { } abstract class TagWithText(name: String): Tag(name) { - fun String.plus() {} + operator fun String.unaryPlus() {} } class HTML(): TagWithText("html") { diff --git a/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.txt b/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.txt index bdfc870eb63..9c7d63300ae 100644 --- a/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.txt +++ b/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.txt @@ -13,7 +13,7 @@ abstract class Tag(val name: String): Element { } abstract class TagWithText(name: String): Tag(name) { - fun String.plus() {} + operator fun String.unaryPlus() {} } class HTML(): TagWithText("html") { @@ -42,7 +42,7 @@ val fail: Nothing get() = throw Exception() Resolved call: -Resulting descriptor: fun String.plus(): Unit defined in Title +Resulting descriptor: fun String.unaryPlus(): Unit defined in Title Explicit receiver kind = EXTENSION_RECEIVER Dispatch receiver = TitleExt{fun Title.(): Unit defined in result..} diff --git a/compiler/testData/writeFlags/delegatedProperty/visibility/privateSet.kt b/compiler/testData/writeFlags/delegatedProperty/visibility/privateSet.kt index 6350d255283..8a7d1fa07b2 100644 --- a/compiler/testData/writeFlags/delegatedProperty/visibility/privateSet.kt +++ b/compiler/testData/writeFlags/delegatedProperty/visibility/privateSet.kt @@ -6,11 +6,11 @@ class MyClass() { } class Delegate { - fun getValue(t: Any?, p: KProperty<*>): Int { + operator fun getValue(t: Any?, p: KProperty<*>): Int { return 1 } - fun setValue(t: Any?, p: KProperty<*>, i: Int) {} + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) {} } // TESTED_OBJECT_KIND: function diff --git a/compiler/testData/writeFlags/property/classObject/class/delegatedProtectedVar.kt b/compiler/testData/writeFlags/property/classObject/class/delegatedProtectedVar.kt index 6906c801d8e..ae8bde8c485 100644 --- a/compiler/testData/writeFlags/property/classObject/class/delegatedProtectedVar.kt +++ b/compiler/testData/writeFlags/property/classObject/class/delegatedProtectedVar.kt @@ -1,11 +1,11 @@ import kotlin.reflect.KProperty class TestDelegate() { - fun getValue(thisRef: Any?, desc: KProperty<*>): Int { + operator fun getValue(thisRef: Any?, desc: KProperty<*>): Int { return 10 } - public open fun setValue(thisRef: Any?, desc: KProperty<*>, svalue : Int) { + operator open fun setValue(thisRef: Any?, desc: KProperty<*>, svalue : Int) { } } diff --git a/compiler/testData/writeFlags/property/classObject/class/delegatedPublicVal.kt b/compiler/testData/writeFlags/property/classObject/class/delegatedPublicVal.kt index 512953964c2..ea3cbc1ebf3 100644 --- a/compiler/testData/writeFlags/property/classObject/class/delegatedPublicVal.kt +++ b/compiler/testData/writeFlags/property/classObject/class/delegatedPublicVal.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class TestDelegate() { - fun getValue(thisRef: Any?, desc: KProperty<*>): Int { + operator fun getValue(thisRef: Any?, desc: KProperty<*>): Int { return 10 } } diff --git a/compiler/testData/writeFlags/property/classObject/rename/delegatedAndDelegated.kt b/compiler/testData/writeFlags/property/classObject/rename/delegatedAndDelegated.kt index a56d0554142..c4bd477fa31 100644 --- a/compiler/testData/writeFlags/property/classObject/rename/delegatedAndDelegated.kt +++ b/compiler/testData/writeFlags/property/classObject/rename/delegatedAndDelegated.kt @@ -3,14 +3,14 @@ import kotlin.reflect.KProperty public open class TestDelegate(private val initializer: () -> T) { private var value: T? = null - public open fun getValue(thisRef: Any?, desc: KProperty<*>): T { + operator open fun getValue(thisRef: Any?, desc: KProperty<*>): T { if (value == null) { value = initializer() } return value!! } - public open fun setValue(thisRef: Any?, desc: KProperty<*>, svalue : T) { + operator open fun setValue(thisRef: Any?, desc: KProperty<*>, svalue : T) { value = svalue } } diff --git a/compiler/testData/writeFlags/property/classObject/rename/delegatedAndProperty.kt b/compiler/testData/writeFlags/property/classObject/rename/delegatedAndProperty.kt index 13afc8e400e..6a641ff54a9 100644 --- a/compiler/testData/writeFlags/property/classObject/rename/delegatedAndProperty.kt +++ b/compiler/testData/writeFlags/property/classObject/rename/delegatedAndProperty.kt @@ -3,14 +3,14 @@ import kotlin.reflect.KProperty public open class TestDelegate(private val initializer: () -> T) { private var value: T? = null - public open fun getValue(thisRef: Any?, desc: KProperty<*>): T { + operator open fun getValue(thisRef: Any?, desc: KProperty<*>): T { if (value == null) { value = initializer() } return value!! } - public open fun setValue(thisRef: Any?, desc: KProperty<*>, svalue : T) { + operator open fun setValue(thisRef: Any?, desc: KProperty<*>, svalue : T) { value = svalue } } diff --git a/compiler/testData/writeFlags/property/classObject/trait/delegatedProtectedVar.kt b/compiler/testData/writeFlags/property/classObject/trait/delegatedProtectedVar.kt index d1630d55cc9..3cbf9bf1bc4 100644 --- a/compiler/testData/writeFlags/property/classObject/trait/delegatedProtectedVar.kt +++ b/compiler/testData/writeFlags/property/classObject/trait/delegatedProtectedVar.kt @@ -1,11 +1,11 @@ import kotlin.reflect.KProperty class TestDelegate() { - fun getValue(thisRef: Any?, desc: KProperty<*>): Int { + operator fun getValue(thisRef: Any?, desc: KProperty<*>): Int { return 10 } - public open fun setValue(thisRef: Any?, desc: KProperty<*>, svalue : Int) { + operator open fun setValue(thisRef: Any?, desc: KProperty<*>, svalue : Int) { } } diff --git a/compiler/testData/writeFlags/property/classObject/trait/delegatedPublicVal.kt b/compiler/testData/writeFlags/property/classObject/trait/delegatedPublicVal.kt index 6f75cd8fcc0..667b1f67ed5 100644 --- a/compiler/testData/writeFlags/property/classObject/trait/delegatedPublicVal.kt +++ b/compiler/testData/writeFlags/property/classObject/trait/delegatedPublicVal.kt @@ -1,7 +1,7 @@ import kotlin.reflect.KProperty class TestDelegate() { - fun getValue(thisRef: Any?, desc: KProperty<*>): Int { + operator fun getValue(thisRef: Any?, desc: KProperty<*>): Int { return 10 } } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index d2e3d050cbe..2594b8584dd 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -952,12 +952,6 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { doTest(fileName); } - @TestMetadata("infixPlus.kt") - public void testInfixPlus() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/stringOperations/infixPlus.kt"); - doTest(fileName); - } - @TestMetadata("interpolation.kt") public void testInterpolation() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/stringOperations/interpolation.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java index 7dda666a3ad..4de87959acf 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java @@ -803,12 +803,6 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCod doTestAgainstJava(fileName); } - @TestMetadata("infixCall.kt") - public void testInfixCall() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.kt"); - doTestAgainstJava(fileName); - } - @TestMetadata("invoke.kt") public void testInvoke() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/invoke.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index 5ccde502500..665af4441b7 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -349,24 +349,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("infixCall.kt") - public void testInfixCall() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/infixCall.kt"); - doTest(fileName); - } - - @TestMetadata("infixCallAny.kt") - public void testInfixCallAny() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/infixCallAny.kt"); - doTest(fileName); - } - - @TestMetadata("infixCallNullable.kt") - public void testInfixCallNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/infixCallNullable.kt"); - doTest(fileName); - } - @TestMetadata("intrinsic.kt") public void testIntrinsic() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/intrinsic.kt"); @@ -4624,12 +4606,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("innerInfixCall.kt") - public void testInnerInfixCall() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/innerInfixCall.kt"); - doTest(fileName); - } - @TestMetadata("innerLabeledThis.kt") public void testInnerLabeledThis() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/innerLabeledThis.kt"); @@ -4741,12 +4717,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/intrinsics"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("compareTo.kt") - public void testCompareTo() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/intrinsics/compareTo.kt"); - doTest(fileName); - } - @TestMetadata("ea35953.kt") public void testEa35953() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/intrinsics/ea35953.kt"); @@ -4759,12 +4729,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("infixCall.kt") - public void testInfixCall() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/intrinsics/infixCall.kt"); - doTest(fileName); - } - @TestMetadata("longRangeWithExplicitDot.kt") public void testLongRangeWithExplicitDot() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/intrinsics/longRangeWithExplicitDot.kt"); @@ -6919,12 +6883,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("kt3173.kt") - public void testKt3173() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt3173.kt"); - doTest(fileName); - } - @TestMetadata("kt3421.kt") public void testKt3421() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt3421.kt"); @@ -6943,12 +6901,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("kt3999.kt") - public void testKt3999() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt3999.kt"); - doTest(fileName); - } - @TestMetadata("kt4281.kt") public void testKt4281() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt4281.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 97bdc777c0e..318d659cd36 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -1534,12 +1534,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("infixCallBinary.kt") - public void testInfixCallBinary() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/evaluate/infixCallBinary.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("intrincics.kt") public void testIntrincics() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/evaluate/intrincics.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AnnotationParameterTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AnnotationParameterTestGenerated.java index db50ee7edf8..a3802470c15 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AnnotationParameterTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AnnotationParameterTestGenerated.java @@ -151,12 +151,6 @@ public class AnnotationParameterTestGenerated extends AbstractAnnotationParamete doTest(fileName); } - @TestMetadata("infixCallBinary.kt") - public void testInfixCallBinary() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/resolveAnnotations/parameters/expressions/infixCallBinary.kt"); - doTest(fileName); - } - @TestMetadata("intrincics.kt") public void testIntrincics() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/resolveAnnotations/parameters/expressions/intrincics.kt"); diff --git a/idea/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt b/idea/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt index e26b22b4601..282f2b8b30d 100644 --- a/idea/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt +++ b/idea/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt @@ -1,4 +1,4 @@ -fun Any.get(a: Int) { +operator fun Any.get(a: Int) { if (a > 0) { this[a - 1] } @@ -10,32 +10,32 @@ class A { return true } - fun inc(): A { + operator fun inc(): A { this++ ++this return this } - fun component1(): Int { + operator fun component1(): Int { // TODO: should be recursion marker too val (a) = this return 1 } - fun unaryPlus() { + operator fun unaryPlus() { +this } - fun unaryMinus() { + operator fun unaryMinus() { -this } - fun plus(a: Int) { + operator fun plus(a: Int) { this + 1 this += 1 } - fun invoke() { + operator fun invoke() { val a = A() a() a.invoke() @@ -46,7 +46,7 @@ class A { } class B -fun B.invoke() { +operator fun B.invoke() { this() invoke() } \ No newline at end of file diff --git a/idea/testData/copyPaste/imports/ExtensionAsInfixOrOperator.kt b/idea/testData/copyPaste/imports/ExtensionAsInfixOrOperator.kt index 318b6c0e73f..a467880ee82 100644 --- a/idea/testData/copyPaste/imports/ExtensionAsInfixOrOperator.kt +++ b/idea/testData/copyPaste/imports/ExtensionAsInfixOrOperator.kt @@ -2,9 +2,9 @@ package a class A() {} -fun A.plus(a: A) = this +operator fun A.plus(a: A) = this -fun A.infix(i: Int) = i +infix fun A.infix(i: Int) = i fun f(a: A) { a + a diff --git a/idea/testData/copyPaste/imports/ExtensionConflict.expected.kt b/idea/testData/copyPaste/imports/ExtensionConflict.expected.kt index 5a39e1b6097..4f501695065 100644 --- a/idea/testData/copyPaste/imports/ExtensionConflict.expected.kt +++ b/idea/testData/copyPaste/imports/ExtensionConflict.expected.kt @@ -1,27 +1,27 @@ // ERROR: Overload resolution ambiguity: public fun a.A.ext(): kotlin.Unit defined in a public fun a.A.ext(): kotlin.Unit defined in to -// ERROR: Overload resolution ambiguity: public fun a.A.plus(a: a.A): kotlin.Unit defined in a public fun a.A.plus(a: a.A): kotlin.Unit defined in to -// ERROR: Overload resolution ambiguity: public fun a.A.infix(a: a.A): kotlin.Unit defined in a public fun a.A.infix(a: a.A): kotlin.Unit defined in to -// ERROR: Overload resolution ambiguity: public fun a.A.minus(): kotlin.Unit defined in a public fun a.A.minus(): kotlin.Unit defined in to +// ERROR: Overload resolution ambiguity: public operator fun a.A.plus(a: a.A): kotlin.Unit defined in a public operator fun a.A.plus(a: a.A): kotlin.Unit defined in to +// ERROR: Overload resolution ambiguity: public infix fun a.A.infix(a: a.A): kotlin.Unit defined in a public infix fun a.A.infix(a: a.A): kotlin.Unit defined in to +// ERROR: Overload resolution ambiguity: public operator fun a.A.unaryMinus(): kotlin.Unit defined in a public operator fun a.A.unaryMinus(): kotlin.Unit defined in to // ERROR: Overload resolution ambiguity: public val a.A.p: kotlin.Int defined in a public val a.A.p: kotlin.Int defined in to package to import a.A import a.ext import a.infix -import a.minus import a.p import a.plus +import a.unaryMinus fun A.ext() { } -fun A.infix(a: A) { +infix fun A.infix(a: A) { } -fun A.plus(a: A) { +operator fun A.plus(a: A) { } -fun A.minus() { +operator fun A.unaryMinus() { } val A.p: Int diff --git a/idea/testData/copyPaste/imports/ExtensionConflict.expected.names b/idea/testData/copyPaste/imports/ExtensionConflict.expected.names index f514a914fd7..7c547955e7c 100644 --- a/idea/testData/copyPaste/imports/ExtensionConflict.expected.names +++ b/idea/testData/copyPaste/imports/ExtensionConflict.expected.names @@ -1,5 +1,5 @@ a.ext a.infix -a.minus a.p a.plus +a.unaryMinus \ No newline at end of file diff --git a/idea/testData/copyPaste/imports/ExtensionConflict.kt b/idea/testData/copyPaste/imports/ExtensionConflict.kt index d239c2c1253..5305d66b1ae 100644 --- a/idea/testData/copyPaste/imports/ExtensionConflict.kt +++ b/idea/testData/copyPaste/imports/ExtensionConflict.kt @@ -6,13 +6,13 @@ class A { fun A.ext() { } -fun A.infix(a: A) { +infix fun A.infix(a: A) { } -fun A.plus(a: A) { +operator fun A.plus(a: A) { } -fun A.minus() { +operator fun A.unaryMinus() { } val A.p: Int diff --git a/idea/testData/copyPaste/imports/ExtensionConflict.to.kt b/idea/testData/copyPaste/imports/ExtensionConflict.to.kt index 44bd3a2b05a..ef90af76c22 100644 --- a/idea/testData/copyPaste/imports/ExtensionConflict.to.kt +++ b/idea/testData/copyPaste/imports/ExtensionConflict.to.kt @@ -5,13 +5,13 @@ import a.A fun A.ext() { } -fun A.infix(a: A) { +infix fun A.infix(a: A) { } -fun A.plus(a: A) { +operator fun A.plus(a: A) { } -fun A.minus() { +operator fun A.unaryMinus() { } val A.p: Int diff --git a/idea/testData/copyPaste/imports/ForLoop.kt b/idea/testData/copyPaste/imports/ForLoop.kt index dd8602b5957..850a47aa5f2 100644 --- a/idea/testData/copyPaste/imports/ForLoop.kt +++ b/idea/testData/copyPaste/imports/ForLoop.kt @@ -6,11 +6,11 @@ class A() { class B() { } -fun B.next(): Int = 3 +operator fun B.next(): Int = 3 -fun B.hasNext(): Boolean = false +operator fun B.hasNext(): Boolean = false -fun A.iterator() = B() +operator fun A.iterator() = B() fun f() { for (i in A()) { diff --git a/idea/testData/copyPaste/imports/GetExpression.kt b/idea/testData/copyPaste/imports/GetExpression.kt index 74683ce855a..bfe6a4f9553 100644 --- a/idea/testData/copyPaste/imports/GetExpression.kt +++ b/idea/testData/copyPaste/imports/GetExpression.kt @@ -3,7 +3,7 @@ package a class A { } -fun A.get(s: String) { +operator fun A.get(s: String) { } fun f() { diff --git a/idea/testData/copyPaste/imports/Invoke.kt b/idea/testData/copyPaste/imports/Invoke.kt index e6981156053..1e3761d5392 100644 --- a/idea/testData/copyPaste/imports/Invoke.kt +++ b/idea/testData/copyPaste/imports/Invoke.kt @@ -3,7 +3,7 @@ package a class A { } -fun A.invoke() { +operator fun A.invoke() { } fun f(a: A) { diff --git a/idea/testData/copyPaste/imports/MultiDeclaration.kt b/idea/testData/copyPaste/imports/MultiDeclaration.kt index b7c730c73c2..e00832fb17b 100644 --- a/idea/testData/copyPaste/imports/MultiDeclaration.kt +++ b/idea/testData/copyPaste/imports/MultiDeclaration.kt @@ -3,8 +3,8 @@ package a class A() { } -fun A.component1() = 1 -fun A.component2() = 2 +operator fun A.component1() = 1 +operator fun A.component2() = 2 fun f() { val (a, b) = A() diff --git a/idea/testData/copyPaste/imports/MultiReferencePartiallyCopied.expected.kt b/idea/testData/copyPaste/imports/MultiReferencePartiallyCopied.expected.kt index 20f33e8a611..2900af082f9 100644 --- a/idea/testData/copyPaste/imports/MultiReferencePartiallyCopied.expected.kt +++ b/idea/testData/copyPaste/imports/MultiReferencePartiallyCopied.expected.kt @@ -5,7 +5,7 @@ import a.B import a.hasNext import a.next -fun A.iterator() = B() +operator fun A.iterator() = B() fun f() { for (i in A()) { diff --git a/idea/testData/copyPaste/imports/MultiReferencePartiallyCopied.kt b/idea/testData/copyPaste/imports/MultiReferencePartiallyCopied.kt index 6053b8a6122..cca948a98e5 100644 --- a/idea/testData/copyPaste/imports/MultiReferencePartiallyCopied.kt +++ b/idea/testData/copyPaste/imports/MultiReferencePartiallyCopied.kt @@ -6,11 +6,11 @@ class A() { class B() { } -fun B.next(): Int = 3 +operator fun B.next(): Int = 3 -fun B.hasNext(): Boolean = false +operator fun B.hasNext(): Boolean = false -fun A.iterator() = B() +operator fun A.iterator() = B() fun f() { for (i in A()) { diff --git a/idea/testData/debugger/smartStepInto/unary.kt b/idea/testData/debugger/smartStepInto/unary.kt index 34b4f9af166..a6d49cde3d2 100644 --- a/idea/testData/debugger/smartStepInto/unary.kt +++ b/idea/testData/debugger/smartStepInto/unary.kt @@ -1,9 +1,9 @@ class A { - fun plus() {} - fun minus() {} + operator fun unaryPlus() {} + operator fun unaryMinus() {} } fun foo() { - +A() || A()- + +A() || -A() } -// EXISTS: plus(), minus() \ No newline at end of file +// EXISTS: unaryPlus(), unaryMinus() \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClass.out b/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClass.out index 6d0ab104f85..af8f4630fc5 100644 --- a/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClass.out +++ b/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClass.out @@ -19,11 +19,11 @@ class A { } class MyDelegate { - fun getValue(t: Any?, p: KProperty<*>): Int = 1 + operator fun getValue(t: Any?, p: KProperty<*>): Int = 1 } class MyDelegateThrowsException { - fun getValue(t: Any?, p: KProperty<*>): Int = throw IllegalStateException() + operator fun getValue(t: Any?, p: KProperty<*>): Int = throw IllegalStateException() } // PRINT_FRAME diff --git a/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClassWoRenderer.out b/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClassWoRenderer.out index f82f11c5ce9..06d5c30a469 100644 --- a/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClassWoRenderer.out +++ b/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClassWoRenderer.out @@ -18,7 +18,7 @@ class A { } class MyDelegate { - fun getValue(t: Any?, p: KProperty<*>): Int = 1 + operator fun getValue(t: Any?, p: KProperty<*>): Int = 1 } // RENDER_DELEGATED_PROPERTIES: false diff --git a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/withoutBodyTypeParameters.kt b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/withoutBodyTypeParameters.kt index b68a4cf777a..af0d05f3483 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/withoutBodyTypeParameters.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/withoutBodyTypeParameters.kt @@ -5,7 +5,7 @@ import kotlin.properties.Delegates // EXPRESSION: i // RESULT: instance of java.lang.Integer(id=ID): Ljava/lang/Integer; //Breakpoint! -fun foo(i: T) = i +fun foo(i: T) = i fun run(i: () -> Int) = 1 diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/dependentOnFile.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/dependentOnFile.kt index 6135f2bbb64..5e107fbca51 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/dependentOnFile.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/dependentOnFile.kt @@ -27,7 +27,7 @@ val Int.testExtVal: Int get() = 1 val testDelVal by Delegate() class Delegate { - fun getValue(a: Any?, b: KProperty<*>) = 1 + operator fun getValue(a: Any?, b: KProperty<*>) = 1 } // EXPRESSION: TestClass().testFun() diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extractVariablesFromCall.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extractVariablesFromCall.kt index 5d2a18a1a53..e4acae7f27e 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extractVariablesFromCall.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extractVariablesFromCall.kt @@ -9,7 +9,7 @@ fun main(args: Array) { } fun f1(i: Int, s: String) = i + s.length() -fun Int.f2(s: String) = this + s.length() +infix fun Int.f2(s: String) = this + s.length() class MyClass { fun f1(i: Int, s: String) = i + s.length() diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClass.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClass.kt index b2a9bdfeb52..2a45266131e 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClass.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClass.kt @@ -15,11 +15,11 @@ class A { } class MyDelegate { - fun getValue(t: Any?, p: KProperty<*>): Int = 1 + operator fun getValue(t: Any?, p: KProperty<*>): Int = 1 } class MyDelegateThrowsException { - fun getValue(t: Any?, p: KProperty<*>): Int = throw IllegalStateException() + operator fun getValue(t: Any?, p: KProperty<*>): Int = throw IllegalStateException() } // PRINT_FRAME diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassWoRenderer.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassWoRenderer.kt index 5be6497a9b8..8a0864bd90e 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassWoRenderer.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassWoRenderer.kt @@ -14,7 +14,7 @@ class A { } class MyDelegate { - fun getValue(t: Any?, p: KProperty<*>): Int = 1 + operator fun getValue(t: Any?, p: KProperty<*>): Int = 1 } // RENDER_DELEGATED_PROPERTIES: false diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/typeParameterRef.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/typeParameterRef.kt index 416343cecd9..10ce2bea09d 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/typeParameterRef.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/typeParameterRef.kt @@ -4,11 +4,11 @@ fun main(args: Array) { test() } -fun foo(): Int { +fun foo(): Int { return 1 } -fun test() { +fun test() { //Breakpoint! val a = foo() } diff --git a/idea/testData/findUsages/kotlin/conventions/unaryMinus.0.kt b/idea/testData/findUsages/kotlin/conventions/unaryMinus.0.kt index c10d2b4e499..92af03bdca2 100644 --- a/idea/testData/findUsages/kotlin/conventions/unaryMinus.0.kt +++ b/idea/testData/findUsages/kotlin/conventions/unaryMinus.0.kt @@ -2,10 +2,10 @@ // OPTIONS: usages class A(val n: Int) { - fun minus(): A = this + operator fun unaryMinus(): A = this } fun test() { - A(1).minus() + A(1).unaryMinus() -A(1) } diff --git a/idea/testData/findUsages/kotlin/conventions/unaryMinus.results.txt b/idea/testData/findUsages/kotlin/conventions/unaryMinus.results.txt index f38ad70bc7e..706b8ce92ea 100644 --- a/idea/testData/findUsages/kotlin/conventions/unaryMinus.results.txt +++ b/idea/testData/findUsages/kotlin/conventions/unaryMinus.results.txt @@ -1,2 +1,2 @@ Function call (10: 5) -A(1) -Function call (9: 10) A(1).minus() \ No newline at end of file +Function call (9: 10) A(1).unaryMinus() \ No newline at end of file diff --git a/idea/testData/intentions/branched/ifThenToDoubleBang/conditionInvalidBinaryExp.kt b/idea/testData/intentions/branched/ifThenToDoubleBang/conditionInvalidBinaryExp.kt index 8822e66b74b..4e93e95c323 100644 --- a/idea/testData/intentions/branched/ifThenToDoubleBang/conditionInvalidBinaryExp.kt +++ b/idea/testData/intentions/branched/ifThenToDoubleBang/conditionInvalidBinaryExp.kt @@ -1,7 +1,7 @@ // WITH_RUNTIME // IS_APPLICABLE: false -fun T.compareTo(a: T): Int = 0 +operator fun T.compareTo(a: T): Int = 0 fun main(args: Array) { val foo = null diff --git a/idea/testData/intentions/branched/ifThenToElvis/conditionInvalidBinaryExp.kt b/idea/testData/intentions/branched/ifThenToElvis/conditionInvalidBinaryExp.kt index ffc885e542e..d4c091bf323 100644 --- a/idea/testData/intentions/branched/ifThenToElvis/conditionInvalidBinaryExp.kt +++ b/idea/testData/intentions/branched/ifThenToElvis/conditionInvalidBinaryExp.kt @@ -1,5 +1,5 @@ // IS_APPLICABLE: false -fun T.compareTo(a: T): Int = 0 +operator fun T.compareTo(a: T): Int = 0 fun main(args: Array) { val foo = null diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/conditionInvalidBinaryExp.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/conditionInvalidBinaryExp.kt index f6432dc4382..c29ab881c3e 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/conditionInvalidBinaryExp.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/conditionInvalidBinaryExp.kt @@ -1,5 +1,5 @@ // IS_APPLICABLE: false -fun T.compareTo(a: T): Int = 0 +operator fun T.compareTo(a: T): Int = 0 fun main(args: Array) { val foo = "foo" diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/conditionNotBinaryExpr.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/conditionNotBinaryExpr.kt index 681e65feeee..23549502ede 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/conditionNotBinaryExpr.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/conditionNotBinaryExpr.kt @@ -1,5 +1,5 @@ // IS_APPLICABLE: false -fun String?.times(a: Int): Boolean = a == 0 +operator fun String?.times(a: Int): Boolean = a == 0 fun main(args: Array) { val foo: String = "foo" diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt index 90584de7521..1773e0aaaf4 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt @@ -1,10 +1,10 @@ -fun doSomething(a: T) {} +fun doSomething(a: T) {} fun test() { class Test { - fun unaryPlus(): Test = Test() - fun plus(a: Test): Test = Test() - fun unaryMinus(): Test = Test() + operator fun unaryPlus(): Test = Test() + operator fun plus(a: Test): Test = Test() + operator fun unaryMinus(): Test = Test() } val test = Test() doSomething((-((test + test).unaryPlus())).toString()) diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after index 175daac3073..39bb9fe77ed 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after @@ -1,10 +1,10 @@ -fun doSomething(a: T) {} +fun doSomething(a: T) {} fun test() { class Test { - fun unaryPlus(): Test = Test() - fun plus(a: Test): Test = Test() - fun unaryMinus(): Test = Test() + operator fun unaryPlus(): Test = Test() + operator fun plus(a: Test): Test = Test() + operator fun unaryMinus(): Test = Test() } val test = Test() doSomething((-(+(test + test))).toString()) diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt index 8e47f5e4e55..5f9d50cdd90 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt @@ -1,7 +1,7 @@ fun test() { class Test() - fun Test.unaryPlus(): Test = Test() + operator fun Test.unaryPlus(): Test = Test() val test = Test() test.unaryPlus() diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after index b3efb2dbaf8..d48f923f20f 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after @@ -1,7 +1,7 @@ fun test() { class Test() - fun Test.unaryPlus(): Test = Test() + operator fun Test.unaryPlus(): Test = Test() val test = Test() +test diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt index b3083f198a1..7cdd5ed5a2d 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt @@ -1,7 +1,7 @@ // INTENTION_TEXT: Replace with '-' operator fun test() { class Test { - fun unaryMinus(): Test = Test() + operator fun unaryMinus(): Test = Test() } val test = Test() test.unaryMinus() diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after index ccc39653c56..9fa986eaa2b 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after @@ -1,7 +1,7 @@ // INTENTION_TEXT: Replace with '-' operator fun test() { class Test { - fun unaryMinus(): Test = Test() + operator fun unaryMinus(): Test = Test() } val test = Test() -test diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt index 1b5a568f726..02d9a9936f6 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt @@ -1,6 +1,6 @@ fun test() { class Test { - fun unaryPlus(): Test = Test() + operator fun unaryPlus(): Test = Test() } val test = Test() +test.unaryPlus() diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after index c4213b3430f..0267910c354 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after @@ -1,6 +1,6 @@ fun test() { class Test { - fun unaryPlus(): Test = Test() + operator fun unaryPlus(): Test = Test() } val test = Test() +(+test) diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt index 3cc07d9d70c..5a2a5dae3aa 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt @@ -1,7 +1,7 @@ // INTENTION_TEXT: Replace with '+' operator fun test() { class Test { - fun unaryPlus(): Test = Test() + operator fun unaryPlus(): Test = Test() } val test = Test() test.unaryPlus() diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after index 87046c7f5e3..04355017b18 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after @@ -1,7 +1,7 @@ // INTENTION_TEXT: Replace with '+' operator fun test() { class Test { - fun unaryPlus(): Test = Test() + operator fun unaryPlus(): Test = Test() } val test = Test() +test diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt index 49b99081d5b..252f6283974 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt @@ -1,6 +1,6 @@ class C { companion object { - fun unaryMinus(): C = C() + operator fun unaryMinus(): C = C() } } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after index 63a45078ab6..9ad0a501be9 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after @@ -1,6 +1,6 @@ class C { companion object { - fun unaryMinus(): C = C() + operator fun unaryMinus(): C = C() } } diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt index 90f14507191..2d77154562d 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt @@ -1,7 +1,7 @@ // IS_APPLICABLE: false open class Base { - open fun unaryMinus() = this + open operator fun unaryMinus() = this } class C : Base() { diff --git a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt index bb92785b513..d33ef248a67 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt +++ b/idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt @@ -1,7 +1,7 @@ // IS_APPLICABLE: false fun test() { class Test { - fun unaryPlus(): T? = this as? T + operator fun unaryPlus(): T? = this as? T } val test = Test() test.unaryPlus() diff --git a/idea/testData/intentions/convertForEachToForLoop/infixCall.kt b/idea/testData/intentions/convertForEachToForLoop/infixCall.kt index cfb82e118d3..34950f29c48 100644 --- a/idea/testData/intentions/convertForEachToForLoop/infixCall.kt +++ b/idea/testData/intentions/convertForEachToForLoop/infixCall.kt @@ -2,5 +2,5 @@ fun foo() { val x = 1..4 - x forEach { a -> a } + x.forEach { a -> a } } \ No newline at end of file diff --git a/idea/testData/intentions/convertForEachToForLoop/infixCallNotAvailable.kt b/idea/testData/intentions/convertForEachToForLoop/infixCallNotAvailable.kt index e4a9a07a8af..78dd41741f6 100644 --- a/idea/testData/intentions/convertForEachToForLoop/infixCallNotAvailable.kt +++ b/idea/testData/intentions/convertForEachToForLoop/infixCallNotAvailable.kt @@ -3,5 +3,5 @@ fun foo() { val x = 1..4 - x forEach { a -> a } + x.forEach { a -> a } } \ No newline at end of file diff --git a/idea/testData/intentions/convertForEachToForLoop/parenthesizedExpression.kt b/idea/testData/intentions/convertForEachToForLoop/parenthesizedExpression.kt index 67b40498721..5241bbc0c74 100644 --- a/idea/testData/intentions/convertForEachToForLoop/parenthesizedExpression.kt +++ b/idea/testData/intentions/convertForEachToForLoop/parenthesizedExpression.kt @@ -1,4 +1,7 @@ // WITH_RUNTIME + +infix fun Int.upTo(other: Int) = this.rangeTo(other) + fun main() { - (1 rangeTo 2).forEach { x -> x } + (1 upTo 2).forEach { x -> x } } \ No newline at end of file diff --git a/idea/testData/intentions/convertForEachToForLoop/parenthesizedExpression.kt.after b/idea/testData/intentions/convertForEachToForLoop/parenthesizedExpression.kt.after index 1d0cf3af340..2f8f17c7e9e 100644 --- a/idea/testData/intentions/convertForEachToForLoop/parenthesizedExpression.kt.after +++ b/idea/testData/intentions/convertForEachToForLoop/parenthesizedExpression.kt.after @@ -1,6 +1,9 @@ // WITH_RUNTIME + +infix fun Int.upTo(other: Int) = this.rangeTo(other) + fun main() { - for (x in 1 rangeTo 2) { + for (x in 1 upTo 2) { x } } \ No newline at end of file diff --git a/idea/testData/intentions/convertFunctionToProperty/invoke.kt b/idea/testData/intentions/convertFunctionToProperty/invoke.kt index 7c5cad4f6b8..85f3c7842c3 100644 --- a/idea/testData/intentions/convertFunctionToProperty/invoke.kt +++ b/idea/testData/intentions/convertFunctionToProperty/invoke.kt @@ -1,7 +1,7 @@ // WITH_RUNTIME // IS_APPLICABLE: false class A(val n: Int) { - fun invoke(): Int = 1 + operator fun invoke(): Int = 1 } fun test(a: A) { diff --git a/idea/testData/intentions/convertFunctionToProperty/iterator.kt b/idea/testData/intentions/convertFunctionToProperty/iterator.kt index e13485954fe..897b340522c 100644 --- a/idea/testData/intentions/convertFunctionToProperty/iterator.kt +++ b/idea/testData/intentions/convertFunctionToProperty/iterator.kt @@ -1,7 +1,7 @@ // WITH_RUNTIME // IS_APPLICABLE: false class A(val n: Int) { - fun iterator(): Iterator = throw Exception("") + operator fun iterator(): Iterator = throw Exception("") } fun test() { diff --git a/idea/testData/intentions/convertFunctionToProperty/unaryOp.kt b/idea/testData/intentions/convertFunctionToProperty/unaryOp.kt index b058aaa31cb..c7bab8c25ac 100644 --- a/idea/testData/intentions/convertFunctionToProperty/unaryOp.kt +++ b/idea/testData/intentions/convertFunctionToProperty/unaryOp.kt @@ -1,7 +1,7 @@ // WITH_RUNTIME // IS_APPLICABLE: false class A(val n: Int) { - fun unaryMinus(): A = A(-n) + operator fun unaryMinus(): A = A(-n) } fun test() { diff --git a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt index 51ede2c0e1f..82e75fd43ba 100644 --- a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt +++ b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt @@ -1,4 +1,4 @@ -fun String.not(): Boolean { +operator fun String.not(): Boolean { return length == 0 } diff --git a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt.after b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt.after index 5a36e3b8012..f805056486b 100644 --- a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt.after +++ b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt.after @@ -1,4 +1,4 @@ -fun String.not(): Boolean { +operator fun String.not(): Boolean { return length == 0 } diff --git a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/nonstandardPrefixOperator.kt b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/nonstandardPrefixOperator.kt index 37ba863a649..a1070c18def 100644 --- a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/nonstandardPrefixOperator.kt +++ b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/nonstandardPrefixOperator.kt @@ -1,4 +1,4 @@ -fun Boolean.plus(): Boolean { +operator fun Boolean.unaryPlus(): Boolean { return false } diff --git a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/nonstandardPrefixOperator.kt.after b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/nonstandardPrefixOperator.kt.after index dd4562c36ec..0168d30491d 100644 --- a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/nonstandardPrefixOperator.kt.after +++ b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/nonstandardPrefixOperator.kt.after @@ -1,4 +1,4 @@ -fun Boolean.plus(): Boolean { +operator fun Boolean.unaryPlus(): Boolean { return false } diff --git a/idea/testData/intentions/convertToForEachFunctionCall/binaryExpressionLoopRange.kt b/idea/testData/intentions/convertToForEachFunctionCall/binaryExpressionLoopRange.kt index fe47f57dbbf..4714e5510b7 100644 --- a/idea/testData/intentions/convertToForEachFunctionCall/binaryExpressionLoopRange.kt +++ b/idea/testData/intentions/convertToForEachFunctionCall/binaryExpressionLoopRange.kt @@ -1,6 +1,6 @@ // WITH_RUNTIME fun main() { - for (x in 1 rangeTo 2) { + for (x in 1.rangeTo(2)) { x } } \ No newline at end of file diff --git a/idea/testData/intentions/convertToForEachFunctionCall/binaryExpressionLoopRange.kt.after b/idea/testData/intentions/convertToForEachFunctionCall/binaryExpressionLoopRange.kt.after index a0deecc549e..c923c8bb267 100644 --- a/idea/testData/intentions/convertToForEachFunctionCall/binaryExpressionLoopRange.kt.after +++ b/idea/testData/intentions/convertToForEachFunctionCall/binaryExpressionLoopRange.kt.after @@ -1,4 +1,4 @@ // WITH_RUNTIME fun main() { - (1 rangeTo 2).forEach { x -> x } + 1.rangeTo(2).forEach { x -> x } } \ No newline at end of file diff --git a/idea/testData/intentions/infixCallToOrdinary/functionLiteralArgument.kt b/idea/testData/intentions/infixCallToOrdinary/functionLiteralArgument.kt index 57518537c71..2b3e997c6ac 100644 --- a/idea/testData/intentions/infixCallToOrdinary/functionLiteralArgument.kt +++ b/idea/testData/intentions/infixCallToOrdinary/functionLiteralArgument.kt @@ -1,5 +1,5 @@ interface Foo { - fun foo(f: (Int) -> Unit) + infix fun foo(f: (Int) -> Unit) } fun foo(x: Foo) { x foo { it * 2 } diff --git a/idea/testData/intentions/infixCallToOrdinary/functionLiteralArgument.kt.after b/idea/testData/intentions/infixCallToOrdinary/functionLiteralArgument.kt.after index 6eefdcc0907..306dc3a5f4b 100644 --- a/idea/testData/intentions/infixCallToOrdinary/functionLiteralArgument.kt.after +++ b/idea/testData/intentions/infixCallToOrdinary/functionLiteralArgument.kt.after @@ -1,5 +1,5 @@ interface Foo { - fun foo(f: (Int) -> Unit) + infix fun foo(f: (Int) -> Unit) } fun foo(x: Foo) { x.foo { it * 2 } diff --git a/idea/testData/intentions/infixCallToOrdinary/nullAssertedCall.kt b/idea/testData/intentions/infixCallToOrdinary/nullAssertedCall.kt index d15aa7aa570..3fe7d2ca247 100644 --- a/idea/testData/intentions/infixCallToOrdinary/nullAssertedCall.kt +++ b/idea/testData/intentions/infixCallToOrdinary/nullAssertedCall.kt @@ -1,3 +1,5 @@ +infix fun String.compareTo(other: String) = 0 + fun foo(x: String) { x!! compareTo "1" } diff --git a/idea/testData/intentions/infixCallToOrdinary/nullAssertedCall.kt.after b/idea/testData/intentions/infixCallToOrdinary/nullAssertedCall.kt.after index 7eb0a544afe..daffee38284 100644 --- a/idea/testData/intentions/infixCallToOrdinary/nullAssertedCall.kt.after +++ b/idea/testData/intentions/infixCallToOrdinary/nullAssertedCall.kt.after @@ -1,3 +1,5 @@ +infix fun String.compareTo(other: String) = 0 + fun foo(x: String) { x!!.compareTo("1") } diff --git a/idea/testData/intentions/infixCallToOrdinary/parenthesesAroundRightHandArgument.kt b/idea/testData/intentions/infixCallToOrdinary/parenthesesAroundRightHandArgument.kt index 68934da493b..ad141ed134f 100644 --- a/idea/testData/intentions/infixCallToOrdinary/parenthesesAroundRightHandArgument.kt +++ b/idea/testData/intentions/infixCallToOrdinary/parenthesesAroundRightHandArgument.kt @@ -1,3 +1,5 @@ +infix fun String.add(other: String) = "" + fun foo(x: String) { - x plus ("1" + "2") + x add ("1" + "2") } diff --git a/idea/testData/intentions/infixCallToOrdinary/parenthesesAroundRightHandArgument.kt.after b/idea/testData/intentions/infixCallToOrdinary/parenthesesAroundRightHandArgument.kt.after index e21575bb82f..fa3f9940713 100644 --- a/idea/testData/intentions/infixCallToOrdinary/parenthesesAroundRightHandArgument.kt.after +++ b/idea/testData/intentions/infixCallToOrdinary/parenthesesAroundRightHandArgument.kt.after @@ -1,3 +1,5 @@ +infix fun String.add(other: String) = "" + fun foo(x: String) { - x.plus("1" + "2") + x.add("1" + "2") } diff --git a/idea/testData/intentions/infixCallToOrdinary/simpleInfixFunctionCall.kt b/idea/testData/intentions/infixCallToOrdinary/simpleInfixFunctionCall.kt index 3905bb0ed64..7b4116c034e 100644 --- a/idea/testData/intentions/infixCallToOrdinary/simpleInfixFunctionCall.kt +++ b/idea/testData/intentions/infixCallToOrdinary/simpleInfixFunctionCall.kt @@ -1,3 +1,5 @@ +infix fun Int.compareTo(other: Int) = 0 + fun foo(x: Int) { x compareTo 1 } diff --git a/idea/testData/intentions/infixCallToOrdinary/simpleInfixFunctionCall.kt.after b/idea/testData/intentions/infixCallToOrdinary/simpleInfixFunctionCall.kt.after index 3f32bd9e9c4..1da32e561ab 100644 --- a/idea/testData/intentions/infixCallToOrdinary/simpleInfixFunctionCall.kt.after +++ b/idea/testData/intentions/infixCallToOrdinary/simpleInfixFunctionCall.kt.after @@ -1,3 +1,5 @@ +infix fun Int.compareTo(other: Int) = 0 + fun foo(x: Int) { x.compareTo(1) } diff --git a/idea/testData/intentions/operatorToFunction/arrayAccessMultipleIndex.kt b/idea/testData/intentions/operatorToFunction/arrayAccessMultipleIndex.kt index 88a8ec79617..f1afee6ce7b 100644 --- a/idea/testData/intentions/operatorToFunction/arrayAccessMultipleIndex.kt +++ b/idea/testData/intentions/operatorToFunction/arrayAccessMultipleIndex.kt @@ -1,5 +1,5 @@ class Bar { - fun get(vararg args: Int) {} + operator fun get(vararg args: Int) {} } fun foo(a: Bar, i: Int) { diff --git a/idea/testData/intentions/operatorToFunction/arrayAccessMultipleIndex.kt.after b/idea/testData/intentions/operatorToFunction/arrayAccessMultipleIndex.kt.after index 66376895418..befabd6654d 100644 --- a/idea/testData/intentions/operatorToFunction/arrayAccessMultipleIndex.kt.after +++ b/idea/testData/intentions/operatorToFunction/arrayAccessMultipleIndex.kt.after @@ -1,5 +1,5 @@ class Bar { - fun get(vararg args: Int) {} + operator fun get(vararg args: Int) {} } fun foo(a: Bar, i: Int) { diff --git a/idea/testData/intentions/operatorToFunction/binaryPlusEquals.kt b/idea/testData/intentions/operatorToFunction/binaryPlusEquals.kt index 6b4fd1a30e9..51968cfa333 100644 --- a/idea/testData/intentions/operatorToFunction/binaryPlusEquals.kt +++ b/idea/testData/intentions/operatorToFunction/binaryPlusEquals.kt @@ -1,5 +1,5 @@ class Bar { - fun plusAssign(arg: Bar) {} + operator fun plusAssign(arg: Bar) {} } fun foo(b: Bar) { diff --git a/idea/testData/intentions/operatorToFunction/binaryPlusEquals.kt.after b/idea/testData/intentions/operatorToFunction/binaryPlusEquals.kt.after index e20ec04548f..25818100c1a 100644 --- a/idea/testData/intentions/operatorToFunction/binaryPlusEquals.kt.after +++ b/idea/testData/intentions/operatorToFunction/binaryPlusEquals.kt.after @@ -1,5 +1,5 @@ class Bar { - fun plusAssign(arg: Bar) {} + operator fun plusAssign(arg: Bar) {} } fun foo(b: Bar) { diff --git a/idea/testData/intentions/operatorToFunction/functionCallMultipleArgument.kt b/idea/testData/intentions/operatorToFunction/functionCallMultipleArgument.kt index 92710592dde..32d87d8ac74 100644 --- a/idea/testData/intentions/operatorToFunction/functionCallMultipleArgument.kt +++ b/idea/testData/intentions/operatorToFunction/functionCallMultipleArgument.kt @@ -1,5 +1,5 @@ class bar() { - fun invoke(i: Any?, j: Any?) : Boolean { + operator fun invoke(i: Any?, j: Any?) : Boolean { return true } } diff --git a/idea/testData/intentions/operatorToFunction/functionCallMultipleArgument.kt.after b/idea/testData/intentions/operatorToFunction/functionCallMultipleArgument.kt.after index 2b8528e8fd4..877b2b41913 100644 --- a/idea/testData/intentions/operatorToFunction/functionCallMultipleArgument.kt.after +++ b/idea/testData/intentions/operatorToFunction/functionCallMultipleArgument.kt.after @@ -1,5 +1,5 @@ class bar() { - fun invoke(i: Any?, j: Any?) : Boolean { + operator fun invoke(i: Any?, j: Any?) : Boolean { return true } } diff --git a/idea/testData/intentions/operatorToFunction/functionCallWithMultipleArgumentsAndSingleLambda.kt b/idea/testData/intentions/operatorToFunction/functionCallWithMultipleArgumentsAndSingleLambda.kt index 7874980140d..6449c4e83f0 100644 --- a/idea/testData/intentions/operatorToFunction/functionCallWithMultipleArgumentsAndSingleLambda.kt +++ b/idea/testData/intentions/operatorToFunction/functionCallWithMultipleArgumentsAndSingleLambda.kt @@ -1,5 +1,5 @@ class Mocha() { - fun invoke(x: Int, y: String, f: (Int) -> String) { + operator fun invoke(x: Int, y: String, f: (Int) -> String) { } } fun main() { diff --git a/idea/testData/intentions/operatorToFunction/functionCallWithMultipleArgumentsAndSingleLambda.kt.after b/idea/testData/intentions/operatorToFunction/functionCallWithMultipleArgumentsAndSingleLambda.kt.after index f0b80c3eda7..d5496b8894d 100644 --- a/idea/testData/intentions/operatorToFunction/functionCallWithMultipleArgumentsAndSingleLambda.kt.after +++ b/idea/testData/intentions/operatorToFunction/functionCallWithMultipleArgumentsAndSingleLambda.kt.after @@ -1,5 +1,5 @@ class Mocha() { - fun invoke(x: Int, y: String, f: (Int) -> String) { + operator fun invoke(x: Int, y: String, f: (Int) -> String) { } } fun main() { diff --git a/idea/testData/intentions/operatorToFunction/functionCallWithSingleLambda.kt b/idea/testData/intentions/operatorToFunction/functionCallWithSingleLambda.kt index 89b97d719c4..453df8edf60 100644 --- a/idea/testData/intentions/operatorToFunction/functionCallWithSingleLambda.kt +++ b/idea/testData/intentions/operatorToFunction/functionCallWithSingleLambda.kt @@ -1,5 +1,5 @@ class Mocha() { - fun invoke(f: (Int) -> String) {} + operator fun invoke(f: (Int) -> String) {} } fun main() { val mocha = Mocha() diff --git a/idea/testData/intentions/operatorToFunction/functionCallWithSingleLambda.kt.after b/idea/testData/intentions/operatorToFunction/functionCallWithSingleLambda.kt.after index 89760fa36d8..3bbe35d4bfd 100644 --- a/idea/testData/intentions/operatorToFunction/functionCallWithSingleLambda.kt.after +++ b/idea/testData/intentions/operatorToFunction/functionCallWithSingleLambda.kt.after @@ -1,5 +1,5 @@ class Mocha() { - fun invoke(f: (Int) -> String) {} + operator fun invoke(f: (Int) -> String) {} } fun main() { val mocha = Mocha() diff --git a/idea/testData/intentions/removeUnnecessaryParentheses/necessaryParentheses5.kt b/idea/testData/intentions/removeUnnecessaryParentheses/necessaryParentheses5.kt index 494b05895ca..0c2fa957854 100644 --- a/idea/testData/intentions/removeUnnecessaryParentheses/necessaryParentheses5.kt +++ b/idea/testData/intentions/removeUnnecessaryParentheses/necessaryParentheses5.kt @@ -1,7 +1,7 @@ // IS_APPLICABLE: false interface Foo { - fun get(x : Any) : Foo - fun plus(x : Any) : Foo + operator fun get(x : Any) : Foo + operator fun plus(x : Any) : Foo } fun foo(x: Foo) { (x + x)[x] diff --git a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses3.kt b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses3.kt index b96a1338482..1fcaff95c4a 100644 --- a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses3.kt +++ b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses3.kt @@ -1,5 +1,5 @@ interface Foo { - fun get(x : Any) : Foo + operator fun get(x : Any) : Foo } fun foo(x: Foo) { (x[x])[x] diff --git a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses3.kt.after b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses3.kt.after index 50b541447d3..61f5e1457db 100644 --- a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses3.kt.after +++ b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses3.kt.after @@ -1,5 +1,5 @@ interface Foo { - fun get(x : Any) : Foo + operator fun get(x : Any) : Foo } fun foo(x: Foo) { x[x][x] diff --git a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses4.kt b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses4.kt index afd088c2ec4..ac7f1b0e32c 100644 --- a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses4.kt +++ b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses4.kt @@ -1,6 +1,6 @@ interface Foo { - fun inc() : Foo - fun not() : Foo + operator fun inc() : Foo + operator fun not() : Foo } fun foo(x: Foo) { !(x.inc()) diff --git a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses4.kt.after b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses4.kt.after index f4f0d4cc866..c813dbd069c 100644 --- a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses4.kt.after +++ b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses4.kt.after @@ -1,6 +1,6 @@ interface Foo { - fun inc() : Foo - fun not() : Foo + operator fun inc() : Foo + operator fun not() : Foo } fun foo(x: Foo) { !x.inc() diff --git a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt index 9a57e7ef813..7ffaf930649 100644 --- a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt +++ b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt @@ -1,5 +1,5 @@ class C() { - fun get(i: Int) = i + 1 + operator fun get(i: Int) = i + 1 // KT-4513: Unnecessary parenthesis around 'this' val foo = (this)[41] diff --git a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt.after b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt.after index 2b597c6f0f3..47ed99246c3 100644 --- a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt.after +++ b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt.after @@ -1,5 +1,5 @@ class C() { - fun get(i: Int) = i + 1 + operator fun get(i: Int) = i + 1 // KT-4513: Unnecessary parenthesis around 'this' val foo = this[41] diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt b/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt index bd9c8ea4e95..ab89ede2a84 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt +++ b/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt @@ -1,6 +1,6 @@ // INTENTION_TEXT: Simplify negated 'in' expression to '!in' class A(val e: Int) { - fun contains(i: Int): Boolean = e == i + operator fun contains(i: Int): Boolean = e == i } fun test(n: Int) { diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt.after b/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt.after index 0416942d8cc..4ec59f26966 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt.after +++ b/idea/testData/intentions/simplifyNegatedBinaryExpression/in.kt.after @@ -1,6 +1,6 @@ // INTENTION_TEXT: Simplify negated 'in' expression to '!in' class A(val e: Int) { - fun contains(i: Int): Boolean = e == i + operator fun contains(i: Int): Boolean = e == i } fun test(n: Int) { diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt b/idea/testData/intentions/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt index 6ea57272a84..e59e1b4e621 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt +++ b/idea/testData/intentions/simplifyNegatedBinaryExpression/inapplicableBinaryOperation.kt @@ -1,5 +1,5 @@ // IS_APPLICABLE: false -fun Int.lt(b: Int): Boolean = this < b +infix fun Int.lt(b: Int): Boolean = this < b fun test(n: Int) { !(1 lt 2) } diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt b/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt index f046f987119..44a913ccfa5 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt +++ b/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt @@ -1,6 +1,6 @@ // INTENTION_TEXT: Simplify negated '!in' expression to 'in' class A(val e: Int) { - fun contains(i: Int): Boolean = e == i + operator fun contains(i: Int): Boolean = e == i } fun test(n: Int) { diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt.after b/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt.after index 60141878621..f6867ae2852 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt.after +++ b/idea/testData/intentions/simplifyNegatedBinaryExpression/notIn.kt.after @@ -1,6 +1,6 @@ // INTENTION_TEXT: Simplify negated '!in' expression to 'in' class A(val e: Int) { - fun contains(i: Int): Boolean = e == i + operator fun contains(i: Int): Boolean = e == i } fun test(n: Int) { diff --git a/idea/testData/intentions/swapBinaryExpression/compareTo.kt b/idea/testData/intentions/swapBinaryExpression/compareTo.kt deleted file mode 100644 index 931f70c49d4..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/compareTo.kt +++ /dev/null @@ -1,4 +0,0 @@ -// IS_APPLICABLE: false -fun main() { - val testing = 5 compareTo 10 -} \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/divideLiteral.kt b/idea/testData/intentions/swapBinaryExpression/divideLiteral.kt deleted file mode 100644 index d640b4c2f57..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/divideLiteral.kt +++ /dev/null @@ -1,4 +0,0 @@ -// IS_APPLICABLE: false -fun main() { - val test = 5 div 2 -} \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/equalsLiteral.kt b/idea/testData/intentions/swapBinaryExpression/equalsLiteral.kt deleted file mode 100644 index 930623054b6..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/equalsLiteral.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun neq(a: Int, b: Int) { - if (a equals b) {} -} \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/equalsLiteral.kt.after b/idea/testData/intentions/swapBinaryExpression/equalsLiteral.kt.after deleted file mode 100644 index 2407d8ec4ed..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/equalsLiteral.kt.after +++ /dev/null @@ -1,3 +0,0 @@ -fun neq(a: Int, b: Int) { - if (b equals a) {} -} \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/identityEqualsLiteral.kt b/idea/testData/intentions/swapBinaryExpression/identityEqualsLiteral.kt deleted file mode 100644 index 8998a30a32d..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/identityEqualsLiteral.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun neq(a: Int, b: Int) { - if (a identityEquals b) {} -} \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/identityEqualsLiteral.kt.after b/idea/testData/intentions/swapBinaryExpression/identityEqualsLiteral.kt.after deleted file mode 100644 index ca6f4f0ab46..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/identityEqualsLiteral.kt.after +++ /dev/null @@ -1,3 +0,0 @@ -fun neq(a: Int, b: Int) { - if (b identityEquals a) {} -} \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/infixFunction.kt b/idea/testData/intentions/swapBinaryExpression/infixFunction.kt index 67fef9d2456..738672ac1cd 100644 --- a/idea/testData/intentions/swapBinaryExpression/infixFunction.kt +++ b/idea/testData/intentions/swapBinaryExpression/infixFunction.kt @@ -1,6 +1,6 @@ // IS_APPLICABLE: false class Foo() { - fun cat(x: Int): Int {return x} + infix fun cat(x: Int): Int {return x} } fun main() { diff --git a/idea/testData/intentions/swapBinaryExpression/minusLiteral.kt b/idea/testData/intentions/swapBinaryExpression/minusLiteral.kt deleted file mode 100644 index 7dd7beb055e..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/minusLiteral.kt +++ /dev/null @@ -1,4 +0,0 @@ -// IS_APPLICABLE: false -fun new(x: Int, y: Int): Int { - return y minus x -} \ No newline at end of file diff --git a/idea/testData/intentions/swapBinaryExpression/plusLiteral.kt b/idea/testData/intentions/swapBinaryExpression/plusLiteral.kt deleted file mode 100644 index db5fbae1ba3..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/plusLiteral.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun test(a: Int, b: Int): Int { - return a plus b -} diff --git a/idea/testData/intentions/swapBinaryExpression/plusLiteral.kt.after b/idea/testData/intentions/swapBinaryExpression/plusLiteral.kt.after deleted file mode 100644 index bcd1af9c7ca..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/plusLiteral.kt.after +++ /dev/null @@ -1,3 +0,0 @@ -fun test(a: Int, b: Int): Int { - return b plus a -} diff --git a/idea/testData/intentions/swapBinaryExpression/rangeTo.kt b/idea/testData/intentions/swapBinaryExpression/rangeTo.kt index 93713174fb8..912028c13e2 100644 --- a/idea/testData/intentions/swapBinaryExpression/rangeTo.kt +++ b/idea/testData/intentions/swapBinaryExpression/rangeTo.kt @@ -1,5 +1,5 @@ // IS_APPLICABLE: false -fun doSomething(a: T) {} +fun doSomething(a: T) {} fun main() { for (i in 1..10) { diff --git a/idea/testData/intentions/swapBinaryExpression/rangeToLiteral.kt b/idea/testData/intentions/swapBinaryExpression/rangeToLiteral.kt deleted file mode 100644 index acd4506490a..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/rangeToLiteral.kt +++ /dev/null @@ -1,8 +0,0 @@ -// IS_APPLICABLE: false -fun doSomething(a: T) {} - -fun main() { - for (i in 1 rangeTo 10) { - doSomething("Hello World") - } -} diff --git a/idea/testData/intentions/swapBinaryExpression/timesLiteral.kt b/idea/testData/intentions/swapBinaryExpression/timesLiteral.kt deleted file mode 100644 index 02c2a61d053..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/timesLiteral.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun test(a: Int, b: Int): Int { - return a times b -} diff --git a/idea/testData/intentions/swapBinaryExpression/timesLiteral.kt.after b/idea/testData/intentions/swapBinaryExpression/timesLiteral.kt.after deleted file mode 100644 index 90346fd8192..00000000000 --- a/idea/testData/intentions/swapBinaryExpression/timesLiteral.kt.after +++ /dev/null @@ -1,3 +0,0 @@ -fun test(a: Int, b: Int): Int { - return b times a -} diff --git a/idea/testData/quickfix/autoImports/delegateExtensionSet.test b/idea/testData/quickfix/autoImports/delegateExtensionSet.test index 6eab383a7c0..cc3cb1e2c6a 100644 --- a/idea/testData/quickfix/autoImports/delegateExtensionSet.test +++ b/idea/testData/quickfix/autoImports/delegateExtensionSet.test @@ -19,8 +19,8 @@ class DelegateImpl { val value: T = null!! } -public fun DelegateImpl.getValue(thisRef: Any?, property: PropertyMetadata): T = value -public fun DelegateImpl.setValue(thisRef: Any, propertyMetadata: PropertyMetadata, t: T) {} +operator fun DelegateImpl.getValue(thisRef: Any?, property: PropertyMetadata): T = value +operator fun DelegateImpl.setValue(thisRef: Any, propertyMetadata: PropertyMetadata, t: T) {} diff --git a/idea/testData/quickfix/autoImports/indexCallExtensionImportGetOnNoOperatorWarning.test b/idea/testData/quickfix/autoImports/indexCallExtensionImportGetOnNoOperatorWarning.test index ea7bcc0aa4d..3b640bd1022 100644 --- a/idea/testData/quickfix/autoImports/indexCallExtensionImportGetOnNoOperatorWarning.test +++ b/idea/testData/quickfix/autoImports/indexCallExtensionImportGetOnNoOperatorWarning.test @@ -1,5 +1,6 @@ // FILE: first.before.kt // "Import" "true" +// ERROR: operator modifier is required on 'get' in 'some.Some' package testing @@ -26,6 +27,7 @@ operator fun Some.get(s: String) {} // FILE: first.after.kt // "Import" "true" +// ERROR: operator modifier is required on 'get' in 'some.Some' package testing diff --git a/idea/testData/quickfix/autoImports/indexCallExtensionImportSetOnNoOperatorWarning.test b/idea/testData/quickfix/autoImports/indexCallExtensionImportSetOnNoOperatorWarning.test index 2a69f346342..51a3f47e6f5 100644 --- a/idea/testData/quickfix/autoImports/indexCallExtensionImportSetOnNoOperatorWarning.test +++ b/idea/testData/quickfix/autoImports/indexCallExtensionImportSetOnNoOperatorWarning.test @@ -1,5 +1,6 @@ // FILE: first.before.kt // "Import" "true" +// ERROR: operator modifier is required on 'set' in 'some.Some' package testing @@ -26,6 +27,7 @@ operator fun Some.set(s: String, i: Int) {} // FILE: first.after.kt // "Import" "true" +// ERROR: operator modifier is required on 'set' in 'some.Some' package testing diff --git a/idea/testData/quickfix/checkArguments/addNameToArgument/invokeOnString.kt b/idea/testData/quickfix/checkArguments/addNameToArgument/invokeOnString.kt index 73b6d2c21aa..180f69956cf 100644 --- a/idea/testData/quickfix/checkArguments/addNameToArgument/invokeOnString.kt +++ b/idea/testData/quickfix/checkArguments/addNameToArgument/invokeOnString.kt @@ -1,5 +1,5 @@ // "Add name to argument: 'b = 42'" "true" -fun String.invoke(a: Int, b: Int) {} +operator fun String.invoke(a: Int, b: Int) {} fun g() { ""(a = 1, 42) diff --git a/idea/testData/quickfix/checkArguments/addNameToArgument/invokeOnString.kt.after b/idea/testData/quickfix/checkArguments/addNameToArgument/invokeOnString.kt.after index 13522e67947..7a1c8a6e277 100644 --- a/idea/testData/quickfix/checkArguments/addNameToArgument/invokeOnString.kt.after +++ b/idea/testData/quickfix/checkArguments/addNameToArgument/invokeOnString.kt.after @@ -1,5 +1,5 @@ // "Add name to argument: 'b = 42'" "true" -fun String.invoke(a: Int, b: Int) {} +operator fun String.invoke(a: Int, b: Int) {} fun g() { ""(a = 1, b = 42) diff --git a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/customOperationOnUserType.kt b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/customOperationOnUserType.kt index ff542e35aa4..12fd7bd9008 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/customOperationOnUserType.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/customOperationOnUserType.kt @@ -1,4 +1,5 @@ // "Create member function 'foo'" "true" +// ERROR: infix modifier is required on 'foo' in 'A' class A(val n: T) diff --git a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/customOperationOnUserType.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/customOperationOnUserType.kt.after index dc372ba6573..9cd7bee301d 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/customOperationOnUserType.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/customOperationOnUserType.kt.after @@ -1,4 +1,5 @@ // "Create member function 'foo'" "true" +// ERROR: infix modifier is required on 'foo' in 'A' class A(val n: T) { infix fun foo(t: T): A { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/quotedName.kt b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/quotedName.kt index 344eb33e65b..ba958385eba 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/quotedName.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/quotedName.kt @@ -1,4 +1,6 @@ // "Create extension function '!u00A0'" "true" +// ERROR: infix modifier is required on '!u00A0' in '' + fun test() { val t: Int = 1 `!u00A0` 2 } \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/quotedName.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/quotedName.kt.after index 21b79767789..dca3908bc1d 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/quotedName.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/quotedName.kt.after @@ -1,4 +1,6 @@ // "Create extension function '!u00A0'" "true" +// ERROR: infix modifier is required on '!u00A0' in '' + fun test() { val t: Int = 1 `!u00A0` 2 } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage1.kt b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage1.kt index 67da74bd091..0dffde81f0e 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage1.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage1.kt @@ -1,7 +1,7 @@ // "Create member function 'component3'" "true" class Foo { - fun component1(): Int { return 0 } - fun component2(): Int { return 0 } + operator fun component1(): Int { return 0 } + operator fun component2(): Int { return 0 } } fun foo() { val (a, b, c) = Foo() diff --git a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage1.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage1.kt.after index 64ec1b49dc6..7f2bea15609 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage1.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage1.kt.after @@ -1,7 +1,7 @@ // "Create member function 'component3'" "true" class Foo { - fun component1(): Int { return 0 } - fun component2(): Int { return 0 } + operator fun component1(): Int { return 0 } + operator fun component2(): Int { return 0 } operator fun component3(): Any { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. diff --git a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage2.kt b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage2.kt index 3c5547cde90..3fe003d3c27 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage2.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage2.kt @@ -1,7 +1,7 @@ // "Create member function 'component3'" "true" class Foo { - fun component1(): Int { return 0 } - fun component2(): Int { return 0 } + operator fun component1(): Int { return 0 } + operator fun component2(): Int { return 0 } } fun foo() { val (a, b, c: String) = Foo() diff --git a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage2.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage2.kt.after index 936d15b4238..de8ae858edd 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage2.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage2.kt.after @@ -1,7 +1,7 @@ // "Create member function 'component3'" "true" class Foo { - fun component1(): Int { return 0 } - fun component2(): Int { return 0 } + operator fun component1(): Int { return 0 } + operator fun component2(): Int { return 0 } operator fun component3(): String { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. diff --git a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage3.kt b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage3.kt index eb5917cf1d4..c31b754a2e7 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage3.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage3.kt @@ -1,16 +1,16 @@ // "Create extension function 'component2'" "true" class FooIterator { - fun hasNext(): Boolean { return false } - fun next(): Any { + operator fun hasNext(): Boolean { return false } + operator fun next(): Any { throw UnsupportedOperationException("not implemented") } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw UnsupportedOperationException("not implemented") } } -fun Any.component1(): Int { +operator fun Any.component1(): Int { return 0 } fun foo() { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage3.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage3.kt.after index f4fbe37ee2e..21ae481f8d0 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage3.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/component/createComponentFromUsage3.kt.after @@ -1,16 +1,16 @@ // "Create extension function 'component2'" "true" class FooIterator { - fun hasNext(): Boolean { return false } - fun next(): Any { + operator fun hasNext(): Boolean { return false } + operator fun next(): Any { throw UnsupportedOperationException("not implemented") } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw UnsupportedOperationException("not implemented") } } -fun Any.component1(): Int { +operator fun Any.component1(): Int { return 0 } fun foo() { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingGet.kt b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingGet.kt index 3688d4714d6..0069f811b55 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingGet.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingGet.kt @@ -2,7 +2,7 @@ import kotlin.reflect.KProperty class F { - fun setValue(x: X, property: KProperty<*>, i: Int) { } + operator fun setValue(x: X, property: KProperty<*>, i: Int) { } } class X { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingGet.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingGet.kt.after index cd6898aa830..7bfccf79cd4 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingGet.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingGet.kt.after @@ -2,7 +2,7 @@ import kotlin.reflect.KProperty class F { - fun setValue(x: X, property: KProperty<*>, i: Int) { } + operator fun setValue(x: X, property: KProperty<*>, i: Int) { } operator fun getValue(x: X, property: KProperty<*>): Int { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. diff --git a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt index c7cb7ac972c..60e3a0179c9 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt @@ -2,7 +2,7 @@ import kotlin.reflect.KProperty class F { - fun getValue(x: X, property: KProperty<*>): Int = 1 + operator fun getValue(x: X, property: KProperty<*>): Int = 1 } class X { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after index a6f7666592a..fb23af9afad 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after @@ -2,7 +2,7 @@ import kotlin.reflect.KProperty class F { - fun getValue(x: X, property: KProperty<*>): Int = 1 + operator fun getValue(x: X, property: KProperty<*>): Int = 1 operator fun setValue(x: X, property: KProperty<*>, i: Int) { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage1.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage1.kt index 3619ff1745c..983c40f13df 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage1.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage1.kt @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo { fun x (y: Foo>) { val z: Iterable = y[""] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage1.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage1.kt.after index 4ed55c29a22..3f8f3923370 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage1.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage1.kt.after @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo { fun x (y: Foo>) { val z: Iterable = y[""] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage10.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage10.kt index d839d088ac0..118181a6c0d 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage10.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage10.kt @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo { fun x (y: Foo>, w: java.util.ArrayList) { val z: Iterable = y["", w] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage10.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage10.kt.after index 4fd4f3b5423..6a111575a7d 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage10.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage10.kt.after @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo { fun x (y: Foo>, w: java.util.ArrayList) { val z: Iterable = y["", w] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage11.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage11.kt index abe94a8db0f..ab2de907abd 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage11.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage11.kt @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo fun x (y: Foo>, w: java.util.ArrayList) { val z: Iterable = y["", w] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage11.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage11.kt.after index 26103fbdac7..0e8fed35deb 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage11.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage11.kt.after @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo { operator fun get(s: String, w: T): T { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage12.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage12.kt index a63474e4cb0..6485b8f13fb 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage12.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage12.kt @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo fun x (y: Foo>, w: java.util.ArrayList) { val z = y["", w] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage12.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage12.kt.after index f8ebf5638e8..065a3daaabd 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage12.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage12.kt.after @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo { operator fun get(s: String, w: T): Any { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage13.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage13.kt index e86b7e7e17d..dec607604d9 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage13.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage13.kt @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + import java.util.ArrayList class Foo { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage13.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage13.kt.after index 31dc448b12f..17468ecfa0d 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage13.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage13.kt.after @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + import java.util.ArrayList class Foo { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage2.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage2.kt index b3722990f1a..d3a0db8e66e 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage2.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage2.kt @@ -1,4 +1,6 @@ // "Create extension function 'get'" "true" +// ERROR: operator modifier is required on 'get' in '' + fun x (y: Any) { val z: Any = y[""] } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage2.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage2.kt.after index ae5baccb1b3..9484e3367d6 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage2.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage2.kt.after @@ -1,4 +1,6 @@ // "Create extension function 'get'" "true" +// ERROR: operator modifier is required on 'get' in '' + fun x (y: Any) { val z: Any = y[""] } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage3.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage3.kt index 71ec5220936..bb751079d2b 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage3.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage3.kt @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo { fun x (y: Foo>) { val z: Iterable = y[""] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage3.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage3.kt.after index c2fbd56ad63..e70e5680cc1 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage3.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage3.kt.after @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo { fun x (y: Foo>) { val z: Iterable = y[""] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage4.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage4.kt index ab908843b56..085152fc4c7 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage4.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage4.kt @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo> { fun x (y: Foo>) { val z: U = y[""] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage4.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage4.kt.after index ad68666126e..0e1af892a3c 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage4.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage4.kt.after @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo> { fun x (y: Foo>) { val z: U = y[""] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage5.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage5.kt index 89997fde8c1..478fc12c8d5 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage5.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage5.kt @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo { fun x (y: Foo>, w: Iterable) { val z: Iterable = y["", w] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage5.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage5.kt.after index 7446233adbf..abd9e447f15 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage5.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage5.kt.after @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + class Foo { fun x (y: Foo>, w: Iterable) { val z: Iterable = y["", w] diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage7.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage7.kt index 218a622ea8d..7be0b90fb86 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage7.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage7.kt @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + import java.util.ArrayList class Foo { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage7.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage7.kt.after index d1e45e2eee0..a8c18fac981 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage7.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage7.kt.after @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + import java.util.ArrayList class Foo { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage8.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage8.kt index a6451c06d08..ad3b163e09e 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage8.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage8.kt @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + import java.util.ArrayList class Foo { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage8.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage8.kt.after index 89a38b760a1..a427fc0bd72 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage8.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage8.kt.after @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + import java.util.ArrayList class Foo { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage9.kt b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage9.kt index 8f0c65e1bdb..f3f008d3d87 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage9.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage9.kt @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + import java.util.ArrayList class Foo { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage9.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage9.kt.after index afd5035a6af..7721c576544 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage9.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/get/createGetFromUsage9.kt.after @@ -1,4 +1,6 @@ // "Create member function 'get'" "true" +// ERROR: operator modifier is required on 'get' in 'Foo' + import java.util.ArrayList class Foo { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage1.kt b/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage1.kt index af54c8eebc2..c346a2ff1b5 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage1.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage1.kt @@ -1,11 +1,11 @@ // "Create member function 'hasNext'" "true" class FooIterator { - fun next(): Int { + operator fun next(): Int { throw Exception("not implemented") } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw Exception("not implemented") } } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage1.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage1.kt.after index ffcede7997f..558a379be21 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage1.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage1.kt.after @@ -1,6 +1,6 @@ // "Create member function 'hasNext'" "true" class FooIterator { - fun next(): Int { + operator fun next(): Int { throw Exception("not implemented") } @@ -9,7 +9,7 @@ class FooIterator { } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw Exception("not implemented") } } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage2.kt b/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage2.kt index 990644a0269..18473c23046 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage2.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage2.kt @@ -1,11 +1,11 @@ // "Create member function 'hasNext'" "true" class FooIterator { - fun next(): T { + operator fun next(): T { throw Exception("not implemented") } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw Exception("not implemented") } } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage2.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage2.kt.after index 553ed85848c..7afe5dd8249 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage2.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/hasNext/createHasNextFromUsage2.kt.after @@ -1,6 +1,6 @@ // "Create member function 'hasNext'" "true" class FooIterator { - fun next(): T { + operator fun next(): T { throw Exception("not implemented") } @@ -9,7 +9,7 @@ class FooIterator { } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw Exception("not implemented") } } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/iterator/createIteratorFromUsage3.kt b/idea/testData/quickfix/createFromUsage/createFunction/iterator/createIteratorFromUsage3.kt index 8c1bc5bb117..1b2c310d9d2 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/iterator/createIteratorFromUsage3.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/iterator/createIteratorFromUsage3.kt @@ -1,16 +1,16 @@ // "Create member function 'next'" "true" class FooIterator { - fun hasNext(): Boolean { return false } + operator fun hasNext(): Boolean { return false } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw UnsupportedOperationException("not implemented") } } -fun Any.component1(): Int { +operator fun Any.component1(): Int { return 0 } -fun Any.component2(): Int { +operator fun Any.component2(): Int { return 0 } fun foo() { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/iterator/createIteratorFromUsage3.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/iterator/createIteratorFromUsage3.kt.after index 10a731e7cbc..467be063edb 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/iterator/createIteratorFromUsage3.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/iterator/createIteratorFromUsage3.kt.after @@ -1,20 +1,20 @@ // "Create member function 'next'" "true" class FooIterator { - fun hasNext(): Boolean { return false } + operator fun hasNext(): Boolean { return false } operator fun next(): Any { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw UnsupportedOperationException("not implemented") } } -fun Any.component1(): Int { +operator fun Any.component1(): Int { return 0 } -fun Any.component2(): Int { +operator fun Any.component2(): Int { return 0 } fun foo() { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage1.kt b/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage1.kt index b1f8035b2b4..aba53622514 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage1.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage1.kt @@ -1,9 +1,9 @@ // "Create member function 'next'" "true" class FooIterator { - fun hasNext(): Boolean { return false } + operator fun hasNext(): Boolean { return false } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw Exception("not implemented") } } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage1.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage1.kt.after index 81b0b4c9294..db247c27456 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage1.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage1.kt.after @@ -1,13 +1,13 @@ // "Create member function 'next'" "true" class FooIterator { - fun hasNext(): Boolean { return false } + operator fun hasNext(): Boolean { return false } operator fun next(): Int { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw Exception("not implemented") } } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage2.kt b/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage2.kt index 34f740acb56..67794a26d1a 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage2.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage2.kt @@ -1,9 +1,9 @@ // "Create member function 'next'" "true" class FooIterator { - fun hasNext(): Boolean { return false } + operator fun hasNext(): Boolean { return false } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw Exception("not implemented") } } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage2.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage2.kt.after index bb369dce559..38cdae353cc 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage2.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/next/createNextFromUsage2.kt.after @@ -1,13 +1,13 @@ // "Create member function 'next'" "true" class FooIterator { - fun hasNext(): Boolean { return false } + operator fun hasNext(): Boolean { return false } operator fun next(): T { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } } class Foo { - fun iterator(): FooIterator { + operator fun iterator(): FooIterator { throw Exception("not implemented") } } diff --git a/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage1.kt b/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage1.kt index be677ce850b..2ce48512d69 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage1.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage1.kt @@ -1,4 +1,6 @@ // "Create member function 'set'" "true" +// ERROR: operator modifier is required on 'set' in 'Foo' + class Foo { fun x (y: Foo>, w: java.util.ArrayList) { y["", w] = w diff --git a/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage1.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage1.kt.after index 355f1e154b1..528ba2c3fac 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage1.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage1.kt.after @@ -1,4 +1,6 @@ // "Create member function 'set'" "true" +// ERROR: operator modifier is required on 'set' in 'Foo' + class Foo { fun x (y: Foo>, w: java.util.ArrayList) { y["", w] = w diff --git a/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage2.kt b/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage2.kt index 5cfb1848508..672d7f842b3 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage2.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage2.kt @@ -1,4 +1,5 @@ // "Create extension function 'set'" "true" +// ERROR: operator modifier is required on 'set' in '' class Foo { fun x (y: Any, w: java.util.ArrayList) { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage2.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage2.kt.after index 21a12da8b76..057f482e0ef 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage2.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/set/createSetFromUsage2.kt.after @@ -1,6 +1,7 @@ import java.util.ArrayList // "Create extension function 'set'" "true" +// ERROR: operator modifier is required on 'set' in '' class Foo { fun x (y: Any, w: java.util.ArrayList) { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/set/setterForIncrement.kt b/idea/testData/quickfix/createFromUsage/createFunction/set/setterForIncrement.kt index 0ef85f51599..99e411cc933 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/set/setterForIncrement.kt +++ b/idea/testData/quickfix/createFromUsage/createFunction/set/setterForIncrement.kt @@ -1,6 +1,6 @@ // "Create member function 'set'" "true" class A { - fun get(s: String): Int = 1 + operator fun get(s: String): Int = 1 } fun foo() { diff --git a/idea/testData/quickfix/createFromUsage/createFunction/set/setterForIncrement.kt.after b/idea/testData/quickfix/createFromUsage/createFunction/set/setterForIncrement.kt.after index 5da19a2a03c..8189d0c7195 100644 --- a/idea/testData/quickfix/createFromUsage/createFunction/set/setterForIncrement.kt.after +++ b/idea/testData/quickfix/createFromUsage/createFunction/set/setterForIncrement.kt.after @@ -1,6 +1,6 @@ // "Create member function 'set'" "true" class A { - fun get(s: String): Int = 1 + operator fun get(s: String): Int = 1 operator fun set(s: String, value: Int) { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/infixCall.kt b/idea/testData/quickfix/deprecatedSymbolUsage/infixCall.kt index 3d79856285b..6891907895c 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/infixCall.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/infixCall.kt @@ -1,11 +1,11 @@ // "Replace with 'newFun(p, this)'" "true" @Deprecated("", ReplaceWith("newFun(p, this)")) -fun String.oldFun(p: Int) { +infix fun String.oldFun(p: Int) { newFun(p, this) } -fun newFun(p: Int, s: String){} +infix fun newFun(p: Int, s: String){} fun foo() { "" oldFun 1 diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/infixCall.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/infixCall.kt.after index e08e8ac9bfb..992a2c011c4 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/infixCall.kt.after +++ b/idea/testData/quickfix/deprecatedSymbolUsage/infixCall.kt.after @@ -1,11 +1,11 @@ // "Replace with 'newFun(p, this)'" "true" @Deprecated("", ReplaceWith("newFun(p, this)")) -fun String.oldFun(p: Int) { +infix fun String.oldFun(p: Int) { newFun(p, this) } -fun newFun(p: Int, s: String){} +infix fun newFun(p: Int, s: String){} fun foo() { newFun(1, "") diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/keepInfixCall.kt b/idea/testData/quickfix/deprecatedSymbolUsage/keepInfixCall.kt index 287ed8f232c..773e8b68329 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/keepInfixCall.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/keepInfixCall.kt @@ -1,11 +1,11 @@ // "Replace with 'newFun(p)'" "true" @Deprecated("", ReplaceWith("newFun(p)")) -fun String.oldFun(p: Int) { +infix fun String.oldFun(p: Int) { newFun(p) } -fun String.newFun(p: Int) { +infix fun String.newFun(p: Int) { } fun foo() { diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/keepInfixCall.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/keepInfixCall.kt.after index 30e13b775af..47d9ae9b7a3 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/keepInfixCall.kt.after +++ b/idea/testData/quickfix/deprecatedSymbolUsage/keepInfixCall.kt.after @@ -1,11 +1,11 @@ // "Replace with 'newFun(p)'" "true" @Deprecated("", ReplaceWith("newFun(p)")) -fun String.oldFun(p: Int) { +infix fun String.oldFun(p: Int) { newFun(p) } -fun String.newFun(p: Int) { +infix fun String.newFun(p: Int) { } fun foo() { diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall.kt b/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall.kt index 752382dd590..5eb5d396448 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall.kt @@ -3,7 +3,7 @@ interface I @Deprecated("", ReplaceWith("newFun(p, this)")) -fun I.plus(p: Int) { +operator fun I.plus(p: Int) { newFun(p, this) } diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall.kt.after index 032462576f8..ad3a8c5c57d 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall.kt.after +++ b/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall.kt.after @@ -3,7 +3,7 @@ interface I @Deprecated("", ReplaceWith("newFun(p, this)")) -fun I.plus(p: Int) { +operator fun I.plus(p: Int) { newFun(p, this) } diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall2.kt b/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall2.kt index b66bed1e17d..52ce8247c21 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall2.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall2.kt @@ -3,7 +3,7 @@ interface I @Deprecated("", ReplaceWith("newFun(p)")) -fun I.plus(p: Int) { +operator fun I.plus(p: Int) { newFun(p) } diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall2.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall2.kt.after index 7bbc85fe57e..67628ba2f49 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall2.kt.after +++ b/idea/testData/quickfix/deprecatedSymbolUsage/operatorCall2.kt.after @@ -3,7 +3,7 @@ interface I @Deprecated("", ReplaceWith("newFun(p)")) -fun I.plus(p: Int) { +operator fun I.plus(p: Int) { newFun(p) } diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/safeCall/changeThisSafeCallWithValue4Runtime.kt b/idea/testData/quickfix/deprecatedSymbolUsage/safeCall/changeThisSafeCallWithValue4Runtime.kt index 1aad28563d3..9b807a4ad44 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/safeCall/changeThisSafeCallWithValue4Runtime.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/safeCall/changeThisSafeCallWithValue4Runtime.kt @@ -13,4 +13,4 @@ fun foo(s: String, t: X) { } } -fun X.plus(x: X): X? = null \ No newline at end of file +operator fun X.plus(x: X): X? = null \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/safeCall/changeThisSafeCallWithValue4Runtime.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/safeCall/changeThisSafeCallWithValue4Runtime.kt.after index fdddb49ab3c..fb53686a27b 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/safeCall/changeThisSafeCallWithValue4Runtime.kt.after +++ b/idea/testData/quickfix/deprecatedSymbolUsage/safeCall/changeThisSafeCallWithValue4Runtime.kt.after @@ -13,4 +13,4 @@ fun foo(s: String, t: X) { } } -fun X.plus(x: X): X? = null \ No newline at end of file +operator fun X.plus(x: X): X? = null \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt index 7118faeb80d..737c9d7c871 100644 --- a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt +++ b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt @@ -1,4 +1,6 @@ // "Rename to 'setValue'" "true" +// ERROR: 'get' method convention on type 'CustomDelegate' is deprecated. Rename to 'getValue' + class CustomDelegate { operator fun get(thisRef: Any?, prop: PropertyMetadata): String = "" operator fun set(thisRef: Any?, prop: PropertyMetadata, value: String) {} diff --git a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt.after b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt.after index a026f1eca94..485ed7e9dbf 100644 --- a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt.after +++ b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt.after @@ -1,4 +1,6 @@ // "Rename to 'setValue'" "true" +// ERROR: 'get' method convention on type 'CustomDelegate' is deprecated. Rename to 'getValue' + class CustomDelegate { operator fun get(thisRef: Any?, prop: PropertyMetadata): String = "" operator fun setValue(thisRef: Any?, prop: PropertyMetadata, value: String) {} diff --git a/idea/testData/quickfix/modifiers/operatorModifierComponent.kt b/idea/testData/quickfix/modifiers/operatorModifierComponent.kt index bb8d4ccf362..a75e03ccaf4 100644 --- a/idea/testData/quickfix/modifiers/operatorModifierComponent.kt +++ b/idea/testData/quickfix/modifiers/operatorModifierComponent.kt @@ -1,4 +1,6 @@ // "Add 'operator' modifier" "true" +// ERROR: operator modifier is required on 'component2' in 'A' + class A { fun component1(): Int = 0 fun component2(): Int = 1 diff --git a/idea/testData/quickfix/modifiers/operatorModifierComponent.kt.after b/idea/testData/quickfix/modifiers/operatorModifierComponent.kt.after index 5352a016eab..a8783f40f3b 100644 --- a/idea/testData/quickfix/modifiers/operatorModifierComponent.kt.after +++ b/idea/testData/quickfix/modifiers/operatorModifierComponent.kt.after @@ -1,4 +1,6 @@ // "Add 'operator' modifier" "true" +// ERROR: operator modifier is required on 'component2' in 'A' + class A { operator fun component1(): Int = 0 fun component2(): Int = 1 diff --git a/idea/testData/quickfix/suppress/forStatement/infix.kt b/idea/testData/quickfix/suppress/forStatement/infix.kt index 4175a8a4d54..978ec50c27f 100644 --- a/idea/testData/quickfix/suppress/forStatement/infix.kt +++ b/idea/testData/quickfix/suppress/forStatement/infix.kt @@ -1,5 +1,7 @@ // "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true" +infix fun Int.add(other: Int) = this + other + fun foo() { - 1!! plus 2 + 1!! add 2 } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/infix.kt.after b/idea/testData/quickfix/suppress/forStatement/infix.kt.after index bcef56f2ee6..0fe0d0a2b83 100644 --- a/idea/testData/quickfix/suppress/forStatement/infix.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/infix.kt.after @@ -1,6 +1,8 @@ // "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true" +infix fun Int.add(other: Int) = this + other + fun foo() { @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") - (1!! plus 2) + (1!! add 2) } \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/anonymousObjectInInfixCall.kt b/idea/testData/quickfix/typeMismatch/anonymousObjectInInfixCall.kt index 36a7dc422b1..3cf3fa65fe0 100644 --- a/idea/testData/quickfix/typeMismatch/anonymousObjectInInfixCall.kt +++ b/idea/testData/quickfix/typeMismatch/anonymousObjectInInfixCall.kt @@ -1,7 +1,7 @@ // "Change parameter 't' type of function 'foo' to 'T'" "true" interface T -fun Int.foo(t: Int) = this +infix fun Int.foo(t: Int) = this fun foo() { 1 foo object: T{} diff --git a/idea/testData/quickfix/typeMismatch/anonymousObjectInInfixCall.kt.after b/idea/testData/quickfix/typeMismatch/anonymousObjectInInfixCall.kt.after index 5f1e665ad0a..af30fb5b387 100644 --- a/idea/testData/quickfix/typeMismatch/anonymousObjectInInfixCall.kt.after +++ b/idea/testData/quickfix/typeMismatch/anonymousObjectInInfixCall.kt.after @@ -1,7 +1,7 @@ // "Change parameter 't' type of function 'foo' to 'T'" "true" interface T -fun Int.foo(t: T) = this +infix fun Int.foo(t: T) = this fun foo() { 1 foo object: T{} diff --git a/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible1.kt b/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible1.kt index 02e238fab02..cb1326959f1 100644 --- a/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible1.kt +++ b/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible1.kt @@ -1,7 +1,7 @@ // "Cast expression 'a' to 'Foo'" "true" interface Foo { - fun plus(x: Any) : Foo + operator fun plus(x: Any) : Foo } open class MyClass { diff --git a/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible1.kt.after b/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible1.kt.after index 366f5681c6c..7561148297a 100644 --- a/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible1.kt.after +++ b/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible1.kt.after @@ -1,7 +1,7 @@ // "Cast expression 'a' to 'Foo'" "true" interface Foo { - fun plus(x: Any) : Foo + operator fun plus(x: Any) : Foo } open class MyClass { diff --git a/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible2.kt b/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible2.kt index 2034e55a1e7..34d769df8c5 100644 --- a/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible2.kt +++ b/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible2.kt @@ -1,7 +1,7 @@ // "Cast expression 'a' to 'Foo'" "true" interface Foo { - fun not() : Foo + operator fun not() : Foo } open class MyClass { diff --git a/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible2.kt.after b/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible2.kt.after index 2756f99ef68..c7cbaa2e31f 100644 --- a/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible2.kt.after +++ b/idea/testData/quickfix/typeMismatch/casts/smartcastImpossible2.kt.after @@ -1,7 +1,7 @@ // "Cast expression 'a' to 'Foo'" "true" interface Foo { - fun not() : Foo + operator fun not() : Foo } open class MyClass { diff --git a/idea/testData/quickfix/typeMismatch/casts/typeMismatch3.kt b/idea/testData/quickfix/typeMismatch/casts/typeMismatch3.kt index 47c3bc48e66..fa7a0014058 100644 --- a/idea/testData/quickfix/typeMismatch/casts/typeMismatch3.kt +++ b/idea/testData/quickfix/typeMismatch/casts/typeMismatch3.kt @@ -1,6 +1,6 @@ // "Cast expression 'a + a' to 'B'" "true" interface A { - fun plus(x: Any): A + operator fun plus(x: Any): A } interface B : A diff --git a/idea/testData/quickfix/typeMismatch/casts/typeMismatch3.kt.after b/idea/testData/quickfix/typeMismatch/casts/typeMismatch3.kt.after index 491082178d1..1591c8d4ab5 100644 --- a/idea/testData/quickfix/typeMismatch/casts/typeMismatch3.kt.after +++ b/idea/testData/quickfix/typeMismatch/casts/typeMismatch3.kt.after @@ -1,9 +1,9 @@ // "Cast expression 'a + a' to 'B'" "true" interface A { - fun plus(x: Any): A + operator fun plus(x: Any): A } interface B : A fun foo(a: A): B { - return (a + a) as B + return (a + a) as B } \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/changeReturnTypeWhenValueParameterListIsAbsent.kt b/idea/testData/quickfix/typeMismatch/changeReturnTypeWhenValueParameterListIsAbsent.kt index 1d71468c8d1..fc311c4a57e 100644 --- a/idea/testData/quickfix/typeMismatch/changeReturnTypeWhenValueParameterListIsAbsent.kt +++ b/idea/testData/quickfix/typeMismatch/changeReturnTypeWhenValueParameterListIsAbsent.kt @@ -1,8 +1,8 @@ // "Change 'A.hasNext' function return type to 'Boolean'" "true" abstract class A { - abstract fun hasNext - abstract fun next(): Int - abstract fun iterator(): A + abstract operator fun hasNext + abstract operator fun next(): Int + abstract operator fun iterator(): A } fun test(notRange: A) { diff --git a/idea/testData/quickfix/typeMismatch/changeReturnTypeWhenValueParameterListIsAbsent.kt.after b/idea/testData/quickfix/typeMismatch/changeReturnTypeWhenValueParameterListIsAbsent.kt.after index 9f6681c1b47..66a361bacc2 100644 --- a/idea/testData/quickfix/typeMismatch/changeReturnTypeWhenValueParameterListIsAbsent.kt.after +++ b/idea/testData/quickfix/typeMismatch/changeReturnTypeWhenValueParameterListIsAbsent.kt.after @@ -1,8 +1,8 @@ // "Change 'A.hasNext' function return type to 'Boolean'" "true" abstract class A { - abstract fun hasNext: Boolean - abstract fun next(): Int - abstract fun iterator(): A + abstract operator fun hasNext: Boolean + abstract operator fun next(): Int + abstract operator fun iterator(): A } fun test(notRange: A) { diff --git a/idea/testData/quickfix/typeMismatch/compareToTypeMismatch.kt b/idea/testData/quickfix/typeMismatch/compareToTypeMismatch.kt index b8028798e72..132f6a4be8b 100644 --- a/idea/testData/quickfix/typeMismatch/compareToTypeMismatch.kt +++ b/idea/testData/quickfix/typeMismatch/compareToTypeMismatch.kt @@ -1,6 +1,6 @@ // "Change 'A.compareTo' function return type to 'Int'" "true" interface A { - fun compareTo(other: Any): String + operator fun compareTo(other: Any): String } fun foo(x: A) { if (x < 0) {} diff --git a/idea/testData/quickfix/typeMismatch/compareToTypeMismatch.kt.after b/idea/testData/quickfix/typeMismatch/compareToTypeMismatch.kt.after index 2e6777b4499..1cccdee3d6b 100644 --- a/idea/testData/quickfix/typeMismatch/compareToTypeMismatch.kt.after +++ b/idea/testData/quickfix/typeMismatch/compareToTypeMismatch.kt.after @@ -1,6 +1,6 @@ // "Change 'A.compareTo' function return type to 'Int'" "true" interface A { - fun compareTo(other: Any): Int + operator fun compareTo(other: Any): Int } fun foo(x: A) { if (x < 0) {} diff --git a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch1.kt b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch1.kt index 717cfed960f..2ae9beb442f 100644 --- a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch1.kt +++ b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch1.kt @@ -1,7 +1,7 @@ // "Change 'A.component1' function return type to 'Int'" "true" abstract class A { - abstract fun component1() - abstract fun component2(): Int + abstract operator fun component1() + abstract operator fun component2(): Int } fun foo(a: A) { diff --git a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch1.kt.after b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch1.kt.after index 3dcd795171a..2397a242778 100644 --- a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch1.kt.after +++ b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch1.kt.after @@ -1,7 +1,7 @@ // "Change 'A.component1' function return type to 'Int'" "true" abstract class A { - abstract fun component1(): Int - abstract fun component2(): Int + abstract operator fun component1(): Int + abstract operator fun component2(): Int } fun foo(a: A) { diff --git a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch2.kt b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch2.kt index e076e74cef6..d6938e1ce65 100644 --- a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch2.kt +++ b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch2.kt @@ -1,7 +1,7 @@ // "Change 'A.component2' function return type to 'Int'" "true" abstract class A { - abstract fun component1(): Int - abstract fun component2(): String + abstract operator fun component1(): Int + abstract operator fun component2(): String } fun foo(a: A) { diff --git a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch2.kt.after b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch2.kt.after index c83364f3b65..d71e0c760e6 100644 --- a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch2.kt.after +++ b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch2.kt.after @@ -1,7 +1,7 @@ // "Change 'A.component2' function return type to 'Int'" "true" abstract class A { - abstract fun component1(): Int - abstract fun component2(): Int + abstract operator fun component1(): Int + abstract operator fun component2(): Int } fun foo(a: A) { diff --git a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch3.kt b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch3.kt index abadafb49e3..89b7b25c5d3 100644 --- a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch3.kt +++ b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch3.kt @@ -1,7 +1,7 @@ // "Remove explicitly specified return type in 'A.component2' function" "true" abstract class A { - abstract fun component1(): Int - abstract fun component2(): Int + abstract operator fun component1(): Int + abstract operator fun component2(): Int } fun foo(a: A) { diff --git a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch3.kt.after b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch3.kt.after index 7d89eb6eaed..9afa29bf382 100644 --- a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch3.kt.after +++ b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch3.kt.after @@ -1,7 +1,7 @@ // "Remove explicitly specified return type in 'A.component2' function" "true" abstract class A { - abstract fun component1(): Int - abstract fun component2() + abstract operator fun component1(): Int + abstract operator fun component2() } fun foo(a: A) { diff --git a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch4.kt b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch4.kt index 7fcf869866c..825aa7343b1 100644 --- a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch4.kt +++ b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch4.kt @@ -1,8 +1,8 @@ // "Change 'A.component2' function return type to 'Unit'" "true" // ERROR: The integer literal does not conform to the expected type kotlin.Unit abstract class A { - abstract fun component1(): Int - fun component2() = 42 + abstract operator fun component1(): Int + operator fun component2() = 42 } fun foo(a: A) { diff --git a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch4.kt.after b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch4.kt.after index abbe2300836..7ac9da58cae 100644 --- a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch4.kt.after +++ b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch4.kt.after @@ -1,8 +1,8 @@ // "Change 'A.component2' function return type to 'Unit'" "true" // ERROR: The integer literal does not conform to the expected type kotlin.Unit abstract class A { - abstract fun component1(): Int - fun component2(): Unit = 42 + abstract operator fun component1(): Int + operator fun component2(): Unit = 42 } fun foo(a: A) { diff --git a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch5.kt b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch5.kt index 822bc91c700..3160166aa1a 100644 --- a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch5.kt +++ b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch5.kt @@ -1,8 +1,8 @@ // "Change 'y' type to 'Int'" "true" class A { - fun component1() = 42 - fun component2() = 42 - fun component3() = 42 + operator fun component1() = 42 + operator fun component2() = 42 + operator fun component3() = 42 } fun foo(a: A) { diff --git a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch5.kt.after b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch5.kt.after index 503d3e31f01..ea925d1d906 100644 --- a/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch5.kt.after +++ b/idea/testData/quickfix/typeMismatch/componentFunctionReturnTypeMismatch/componentFunctionReturnTypeMismatch5.kt.after @@ -1,8 +1,8 @@ // "Change 'y' type to 'Int'" "true" class A { - fun component1() = 42 - fun component2() = 42 - fun component3() = 42 + operator fun component1() = 42 + operator fun component2() = 42 + operator fun component3() = 42 } fun foo(a: A) { diff --git a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeNotFunctionReturnType.kt b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeNotFunctionReturnType.kt index 28c05b878ba..f2dcf7f7f72 100644 --- a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeNotFunctionReturnType.kt +++ b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeNotFunctionReturnType.kt @@ -1,7 +1,7 @@ // "Change 'A.not' function return type to 'A'" "true" interface A { - fun not(): String - fun times(a: A): A + operator fun not(): String + operator fun times(a: A): A } fun foo(a: A): A = a * !(if (true) a else a) \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeNotFunctionReturnType.kt.after b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeNotFunctionReturnType.kt.after index ce0594d5c61..d71164d274c 100644 --- a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeNotFunctionReturnType.kt.after +++ b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeNotFunctionReturnType.kt.after @@ -1,7 +1,7 @@ // "Change 'A.not' function return type to 'A'" "true" interface A { - fun not(): A - fun times(a: A): A + operator fun not(): A + operator fun times(a: A): A } fun foo(a: A): A = a * !(if (true) a else a) \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changePlusFunctionReturnType.kt b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changePlusFunctionReturnType.kt index e3915d9e301..fdd335c4799 100644 --- a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changePlusFunctionReturnType.kt +++ b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changePlusFunctionReturnType.kt @@ -1,6 +1,6 @@ // "Change 'A.plus' function return type to '() -> Int'" "true" interface A { - fun plus(a: A): String + operator fun plus(a: A): String } fun foo(a: A): () -> Int { diff --git a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changePlusFunctionReturnType.kt.after b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changePlusFunctionReturnType.kt.after index 38a92aec5e0..ddea04b0eb8 100644 --- a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changePlusFunctionReturnType.kt.after +++ b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changePlusFunctionReturnType.kt.after @@ -1,6 +1,6 @@ // "Change 'A.plus' function return type to '() -> Int'" "true" interface A { - fun plus(a: A): () -> Int + operator fun plus(a: A): () -> Int } fun foo(a: A): () -> Int { diff --git a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeTimesFunctionParameterType.kt b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeTimesFunctionParameterType.kt index bc2f8b03cc2..5bed2b41d00 100644 --- a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeTimesFunctionParameterType.kt +++ b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeTimesFunctionParameterType.kt @@ -1,6 +1,6 @@ // "Change parameter 'a' type of function 'A.times' to 'String'" "true" interface A { - fun times(a: A): A + operator fun times(a: A): A } fun foo(a: A): A = a * "" \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeTimesFunctionParameterType.kt.after b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeTimesFunctionParameterType.kt.after index 252bb1d98bd..0de4ca504ad 100644 --- a/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeTimesFunctionParameterType.kt.after +++ b/idea/testData/quickfix/typeMismatch/fixOverloadedOperator/changeTimesFunctionParameterType.kt.after @@ -1,6 +1,6 @@ // "Change parameter 'a' type of function 'A.times' to 'String'" "true" interface A { - fun times(a: String): A + operator fun times(a: String): A } fun foo(a: A): A = a * "" \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/hasNextFunctionReturnTypeMismatch.kt b/idea/testData/quickfix/typeMismatch/hasNextFunctionReturnTypeMismatch.kt index 379fec3240d..76bc2b5b3f9 100644 --- a/idea/testData/quickfix/typeMismatch/hasNextFunctionReturnTypeMismatch.kt +++ b/idea/testData/quickfix/typeMismatch/hasNextFunctionReturnTypeMismatch.kt @@ -1,8 +1,8 @@ // "Change 'A.hasNext' function return type to 'Boolean'" "true" abstract class A { - abstract fun hasNext(): Int - abstract fun next(): Int - abstract fun iterator(): A + abstract operator fun hasNext(): Int + abstract operator fun next(): Int + abstract operator fun iterator(): A } fun test(notRange: A) { diff --git a/idea/testData/quickfix/typeMismatch/hasNextFunctionReturnTypeMismatch.kt.after b/idea/testData/quickfix/typeMismatch/hasNextFunctionReturnTypeMismatch.kt.after index 6804ef6ca95..7ad68800624 100644 --- a/idea/testData/quickfix/typeMismatch/hasNextFunctionReturnTypeMismatch.kt.after +++ b/idea/testData/quickfix/typeMismatch/hasNextFunctionReturnTypeMismatch.kt.after @@ -1,8 +1,8 @@ // "Change 'A.hasNext' function return type to 'Boolean'" "true" abstract class A { - abstract fun hasNext(): Boolean - abstract fun next(): Int - abstract fun iterator(): A + abstract operator fun hasNext(): Boolean + abstract operator fun next(): Int + abstract operator fun iterator(): A } fun test(notRange: A) { diff --git a/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/multiFakeOverrideForOperatorConvention.kt b/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/multiFakeOverrideForOperatorConvention.kt index e29145d5232..4ac9f26bf4e 100644 --- a/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/multiFakeOverrideForOperatorConvention.kt +++ b/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/multiFakeOverrideForOperatorConvention.kt @@ -4,11 +4,11 @@ // ACTION: Replace overloaded operator with function call // ERROR: Type mismatch: inferred type is kotlin.Boolean but kotlin.Int was expected interface A { - fun contains(i: Int): Boolean + operator fun contains(i: Int): Boolean } open class AA { - fun contains(i: Int) = true + operator fun contains(i: Int) = true } class AAA: AA(), A { diff --git a/idea/testData/refactoring/rename/renameUnaryMinus/before/unaryMinus.kt b/idea/testData/refactoring/rename/renameUnaryMinus/before/unaryMinus.kt index 62ed0d6422a..5fedd867f33 100644 --- a/idea/testData/refactoring/rename/renameUnaryMinus/before/unaryMinus.kt +++ b/idea/testData/refactoring/rename/renameUnaryMinus/before/unaryMinus.kt @@ -1,8 +1,8 @@ class A(val n: Int) { - operator fun minus(): A = this + operator fun unaryMinus(): A = this } fun test() { - A(1).minus() + A(1).unaryMinus() -A(1) } \ No newline at end of file diff --git a/idea/testData/refactoring/rename/renameUnaryMinus/unaryMinus.test b/idea/testData/refactoring/rename/renameUnaryMinus/unaryMinus.test index 93e0b1a2a6a..5f7b563ae65 100644 --- a/idea/testData/refactoring/rename/renameUnaryMinus/unaryMinus.test +++ b/idea/testData/refactoring/rename/renameUnaryMinus/unaryMinus.test @@ -1,7 +1,7 @@ { "type": "KOTLIN_FUNCTION", "classId": "/A", - "oldName": "minus", + "oldName": "unaryMinus", "newName": "foo", "mainFile": "unaryMinus.kt" } \ No newline at end of file diff --git a/idea/testData/unifier/equivalence/declarations/localCallables/multiDeclaration.kt b/idea/testData/unifier/equivalence/declarations/localCallables/multiDeclaration.kt index d1a10ada3a6..648498afe34 100644 --- a/idea/testData/unifier/equivalence/declarations/localCallables/multiDeclaration.kt +++ b/idea/testData/unifier/equivalence/declarations/localCallables/multiDeclaration.kt @@ -7,7 +7,7 @@ fun foo1() { } fun foo2() { - fun A.component1(): Int = a + 1 + operator fun A.component1(): Int = a + 1 val (aa, bb) = A(1, "2") val (uu, vv) = A(2, "2") diff --git a/idea/testData/unifier/equivalence/expressions/calls/externalArgumentsRuntime.kt b/idea/testData/unifier/equivalence/expressions/calls/externalArgumentsRuntime.kt index df57bd50da8..77f05467ded 100644 --- a/idea/testData/unifier/equivalence/expressions/calls/externalArgumentsRuntime.kt +++ b/idea/testData/unifier/equivalence/expressions/calls/externalArgumentsRuntime.kt @@ -1,4 +1,4 @@ -fun Int.contains(n: Int): Boolean = n < this +operator fun Int.contains(n: Int): Boolean = n < this fun foo(n: Int): Int { if (n in 1) { diff --git a/idea/testData/unifier/equivalence/expressions/conventions/inc.kt b/idea/testData/unifier/equivalence/expressions/conventions/inc.kt index 37e8876bf45..01aaad84ed6 100644 --- a/idea/testData/unifier/equivalence/expressions/conventions/inc.kt +++ b/idea/testData/unifier/equivalence/expressions/conventions/inc.kt @@ -1,4 +1,4 @@ -fun String.inc() = this + "+" +operator fun String.inc() = this + "+" class Foo { init { diff --git a/idea/testData/unifier/equivalence/expressions/conventions/infixCall.kt b/idea/testData/unifier/equivalence/expressions/conventions/infixCall.kt index 82dd4f76110..15f2285347f 100644 --- a/idea/testData/unifier/equivalence/expressions/conventions/infixCall.kt +++ b/idea/testData/unifier/equivalence/expressions/conventions/infixCall.kt @@ -1,3 +1 @@ -val a = 1 + 2 -val b = 1 plus 2 -val d = 2 plus 1 \ No newline at end of file +val a = 1 + 2 \ No newline at end of file diff --git a/idea/testData/unifier/equivalence/expressions/conventions/infixCall.kt.match b/idea/testData/unifier/equivalence/expressions/conventions/infixCall.kt.match index e78ceb3c488..193df0b550b 100644 --- a/idea/testData/unifier/equivalence/expressions/conventions/infixCall.kt.match +++ b/idea/testData/unifier/equivalence/expressions/conventions/infixCall.kt.match @@ -1,3 +1 @@ -1 + 2 - -1 plus 2 \ No newline at end of file +1 + 2 \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index a4efd9dcb9a..5ad3af3c0c7 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -7759,12 +7759,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } - @TestMetadata("compareTo.kt") - public void testCompareTo() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/compareTo.kt"); - doTest(fileName); - } - @TestMetadata("conjunction.kt") public void testConjunction() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/conjunction.kt"); @@ -7801,24 +7795,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } - @TestMetadata("divideLiteral.kt") - public void testDivideLiteral() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/divideLiteral.kt"); - doTest(fileName); - } - @TestMetadata("equals.kt") public void testEquals() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/equals.kt"); doTest(fileName); } - @TestMetadata("equalsLiteral.kt") - public void testEqualsLiteral() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/equalsLiteral.kt"); - doTest(fileName); - } - @TestMetadata("greaterThan.kt") public void testGreaterThan() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/greaterThan.kt"); @@ -7837,12 +7819,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } - @TestMetadata("identityEqualsLiteral.kt") - public void testIdentityEqualsLiteral() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/identityEqualsLiteral.kt"); - doTest(fileName); - } - @TestMetadata("in.kt") public void testIn() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/in.kt"); @@ -7885,12 +7861,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } - @TestMetadata("minusLiteral.kt") - public void testMinusLiteral() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/minusLiteral.kt"); - doTest(fileName); - } - @TestMetadata("multipleOperands.kt") public void testMultipleOperands() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/multipleOperands.kt"); @@ -7999,12 +7969,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } - @TestMetadata("plusLiteral.kt") - public void testPlusLiteral() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/plusLiteral.kt"); - doTest(fileName); - } - @TestMetadata("plusMinus.kt") public void testPlusMinus() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/plusMinus.kt"); @@ -8017,12 +7981,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } - @TestMetadata("rangeToLiteral.kt") - public void testRangeToLiteral() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/rangeToLiteral.kt"); - doTest(fileName); - } - @TestMetadata("remainder.kt") public void testRemainder() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/remainder.kt"); @@ -8047,12 +8005,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } - @TestMetadata("timesLiteral.kt") - public void testTimesLiteral() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/timesLiteral.kt"); - doTest(fileName); - } - @TestMetadata("xor.kt") public void testXor() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/swapBinaryExpression/xor.kt"); diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt index f9f40951b8a..28455f8773a 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File import java.util.* -private val DECLARATION_KEYWORDS = listOf("interface", "class", "enum class", "object", "fun", "val", "var") +private val DECLARATION_KEYWORDS = listOf("interface", "class", "enum class", "object", "fun", "operator fun", "val", "var") private val DECLARATION_STARTS_WITH = DECLARATION_KEYWORDS.map { it + " " } abstract class AbstractLookupTrackerTest : AbstractIncrementalJpsTest( diff --git a/jps-plugin/testData/incremental/lookupTracker/conventions/comparison.kt b/jps-plugin/testData/incremental/lookupTracker/conventions/comparison.kt index 02cae7f1a1f..d7f73c68b45 100644 --- a/jps-plugin/testData/incremental/lookupTracker/conventions/comparison.kt +++ b/jps-plugin/testData/incremental/lookupTracker/conventions/comparison.kt @@ -6,13 +6,13 @@ package foo.bar na /*c:foo.bar.A(equals)*/== a na /*c:foo.bar.A(equals)*/== null - a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo) c:foo.bar.A(getCompareTo) c:foo.bar.A(getCOMPARETo)*/> b - a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo) c:foo.bar.A(getCompareTo) c:foo.bar.A(getCOMPARETo)*/< b - a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo) c:foo.bar.A(getCompareTo) c:foo.bar.A(getCOMPARETo)*/>= b - a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo) c:foo.bar.A(getCompareTo) c:foo.bar.A(getCOMPARETo)*/<= b + a /*c:foo.bar.A(compareTo)*/> b + a /*c:foo.bar.A(compareTo)*/< b + a /*c:foo.bar.A(compareTo)*/>= b + a /*c:foo.bar.A(compareTo)*/<= b - a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo) c:foo.bar.A(getCompareTo) c:foo.bar.A(getCOMPARETo)*/> c - a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo) c:foo.bar.A(getCompareTo) c:foo.bar.A(getCOMPARETo)*/< c - a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo) c:foo.bar.A(getCompareTo) c:foo.bar.A(getCOMPARETo)*/>= c - a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo) c:foo.bar.A(getCompareTo) c:foo.bar.A(getCOMPARETo)*/<= c + a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo)*/> c + a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo)*/< c + a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo)*/>= c + a /*c:foo.bar.A(compareTo) p:foo.bar(compareTo) p:java.lang(compareTo) p:kotlin(compareTo) p:kotlin.annotation(compareTo) p:kotlin.jvm(compareTo) p:kotlin.io(compareTo)*/<= c } diff --git a/jps-plugin/testData/incremental/lookupTracker/conventions/declarations.kt b/jps-plugin/testData/incremental/lookupTracker/conventions/declarations.kt index e0dc43739f2..0dc0141f4f5 100644 --- a/jps-plugin/testData/incremental/lookupTracker/conventions/declarations.kt +++ b/jps-plugin/testData/incremental/lookupTracker/conventions/declarations.kt @@ -1,35 +1,35 @@ package foo.bar /*p:foo.bar*/class A { - fun plus(a: /*c:foo.bar.A p:foo.bar*/Int) = this - fun timesAssign(a: /*c:foo.bar.A p:foo.bar*/Any?) {} - fun inc(): /*c:foo.bar.A p:foo.bar*/A = this + operator fun plus(a: /*c:foo.bar.A p:foo.bar*/Int) = this + operator fun timesAssign(a: /*c:foo.bar.A p:foo.bar*/Any?) {} + operator fun inc(): /*c:foo.bar.A p:foo.bar*/A = this - fun get(i: /*c:foo.bar.A p:foo.bar*/Int) = 1 - fun contains(a: /*c:foo.bar.A p:foo.bar*/Int): /*c:foo.bar.A p:foo.bar*/Boolean = false - fun invoke() {} + operator fun get(i: /*c:foo.bar.A p:foo.bar*/Int) = 1 + operator fun contains(a: /*c:foo.bar.A p:foo.bar*/Int): /*c:foo.bar.A p:foo.bar*/Boolean = false + operator fun invoke() {} - fun compareTo(a: /*c:foo.bar.A p:foo.bar*/Int) = 0 + operator fun compareTo(a: /*c:foo.bar.A p:foo.bar*/Int) = 0 - fun component1() = this + operator fun component1() = this - fun iterator() = this - fun next() = this + operator fun iterator() = this + operator fun next() = this } -/*p:foo.bar*/fun /*p:foo.bar*/A.minus(a: /*p:foo.bar*/Int) = this -/*p:foo.bar*/fun /*p:foo.bar*/A.divAssign(a: /*p:foo.bar*/Any?) {} -/*p:foo.bar*/fun /*p:foo.bar*/A.dec(): /*p:foo.bar*/A = this +/*p:foo.bar*/operator fun /*p:foo.bar*/A.minus(a: /*p:foo.bar*/Int) = this +/*p:foo.bar*/operator fun /*p:foo.bar*/A.divAssign(a: /*p:foo.bar*/Any?) {} +/*p:foo.bar*/operator fun /*p:foo.bar*/A.dec(): /*p:foo.bar*/A = this -/*p:foo.bar*/fun /*p:foo.bar*/A.not() {} +/*p:foo.bar*/operator fun /*p:foo.bar*/A.not() {} -/*p:foo.bar*/fun /*p:foo.bar*/A.set(i: /*p:foo.bar*/Int, v: /*p:foo.bar*/Int) {} -/*p:foo.bar*/fun /*p:foo.bar*/A.contains(a: /*p:foo.bar*/Any): /*p:foo.bar*/Boolean = true -/*p:foo.bar*/fun /*p:foo.bar*/A.invoke(i: /*p:foo.bar*/Int) {} +/*p:foo.bar*/operator fun /*p:foo.bar*/A.set(i: /*p:foo.bar*/Int, v: /*p:foo.bar*/Int) {} +/*p:foo.bar*/operator fun /*p:foo.bar*/A.contains(a: /*p:foo.bar*/Any): /*p:foo.bar*/Boolean = true +/*p:foo.bar*/operator fun /*p:foo.bar*/A.invoke(i: /*p:foo.bar*/Int) {} -/*p:foo.bar*/fun /*p:foo.bar*/A.compareTo(a: /*p:foo.bar*/Any) = 0 +/*p:foo.bar*/operator fun /*p:foo.bar*/A.compareTo(a: /*p:foo.bar*/Any) = 0 -/*p:foo.bar*/fun /*p:foo.bar*/A.component2() = this +/*p:foo.bar*/operator fun /*p:foo.bar*/A.component2() = this -/*p:foo.bar*/fun /*p:foo.bar*/A?.iterator() = this!! -/*p:foo.bar*/fun /*p:foo.bar*/A.hasNext(): /*p:foo.bar*/Boolean = false +/*p:foo.bar*/operator fun /*p:foo.bar*/A?.iterator() = this!! +/*p:foo.bar*/operator fun /*p:foo.bar*/A.hasNext(): /*p:foo.bar*/Boolean = false diff --git a/jps-plugin/testData/incremental/lookupTracker/conventions/delegateProperty.kt b/jps-plugin/testData/incremental/lookupTracker/conventions/delegateProperty.kt index 80e5fb200f1..d444859d877 100644 --- a/jps-plugin/testData/incremental/lookupTracker/conventions/delegateProperty.kt +++ b/jps-plugin/testData/incremental/lookupTracker/conventions/delegateProperty.kt @@ -3,28 +3,28 @@ package foo.bar import kotlin.reflect./*p:kotlin.reflect*/KProperty /*p:foo.bar*/class D1 { - fun get(t: /*c:foo.bar.D1 p:foo.bar*/Any?, p: /*c:foo.bar.D1*/KProperty<*>) = 1 + operator fun getValue(t: /*c:foo.bar.D1 p:foo.bar*/Any?, p: /*c:foo.bar.D1*/KProperty<*>) = 1 } -/*p:foo.bar*/fun /*p:foo.bar*/D1.set(t: /*p:foo.bar*/Any?, p: KProperty<*>, v: /*p:foo.bar*/Int) {} +/*p:foo.bar*/operator fun /*p:foo.bar*/D1.setValue(t: /*p:foo.bar*/Any?, p: KProperty<*>, v: /*p:foo.bar*/Int) {} /*p:foo.bar(D2)*/open class D2 { - fun set(t: /*c:foo.bar.D2 p:foo.bar*/Any?, p: /*c:foo.bar.D2*/KProperty<*>, v: /*c:foo.bar.D2 p:foo.bar*/Int) {} + operator fun setValue(t: /*c:foo.bar.D2 p:foo.bar*/Any?, p: /*c:foo.bar.D2*/KProperty<*>, v: /*c:foo.bar.D2 p:foo.bar*/Int) {} } -/*p:foo.bar*/fun /*p:foo.bar*/D2.get(t: /*p:foo.bar*/Any?, p: KProperty<*>) = 1 -/*p:foo.bar*/fun /*p:foo.bar*/D2.propertyDelegated(p: /*p:foo.bar*/Any?) {} +/*p:foo.bar*/operator fun /*p:foo.bar*/D2.getValue(t: /*p:foo.bar*/Any?, p: KProperty<*>) = 1 +/*p:foo.bar*/operator fun /*p:foo.bar*/D2.propertyDelegated(p: /*p:foo.bar*/Any?) {} /*p:foo.bar*/class D3 : /*p:foo.bar*/D2() { fun propertyDelegated(p: /*c:foo.bar.D3 c:foo.bar.D2 p:foo.bar*/Any?) {} } -/*p:foo.bar*/val x1 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D1(getValue) p:foo.bar(getValue) p:java.lang(getValue) p:kotlin(getValue) p:kotlin.annotation(getValue) p:kotlin.jvm(getValue) p:kotlin.io(getValue) c:foo.bar.D1(getGetValue) c:foo.bar.D1(getGETValue) c:foo.bar.D1(get) c:foo.bar.D1(propertyDelegated) p:foo.bar(propertyDelegated) p:java.lang(propertyDelegated) p:kotlin(propertyDelegated) p:kotlin.annotation(propertyDelegated) p:kotlin.jvm(propertyDelegated) p:kotlin.io(propertyDelegated) c:foo.bar.D1(getPropertyDelegated) c:foo.bar.D1(getPROPERTYDelegated)*/D1() -/*p:foo.bar*/var y1 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D1(getValue) p:foo.bar(getValue) p:java.lang(getValue) p:kotlin(getValue) p:kotlin.annotation(getValue) p:kotlin.jvm(getValue) p:kotlin.io(getValue) c:foo.bar.D1(getGetValue) c:foo.bar.D1(getGETValue) c:foo.bar.D1(get) c:foo.bar.D1(setValue) p:foo.bar(setValue) p:java.lang(setValue) p:kotlin(setValue) p:kotlin.annotation(setValue) p:kotlin.jvm(setValue) p:kotlin.io(setValue) c:foo.bar.D1(getSetValue) c:foo.bar.D1(getSETValue) c:foo.bar.D1(set) p:foo.bar(set) p:java.lang(set) p:kotlin(set) p:kotlin.annotation(set) p:kotlin.jvm(set) p:kotlin.io(set) c:foo.bar.D1(propertyDelegated) p:foo.bar(propertyDelegated) p:java.lang(propertyDelegated) p:kotlin(propertyDelegated) p:kotlin.annotation(propertyDelegated) p:kotlin.jvm(propertyDelegated) p:kotlin.io(propertyDelegated) c:foo.bar.D1(getPropertyDelegated) c:foo.bar.D1(getPROPERTYDelegated)*/D1() +/*p:foo.bar*/val x1 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D1(getValue) c:foo.bar.D1(propertyDelegated) p:foo.bar(propertyDelegated) p:java.lang(propertyDelegated) p:kotlin(propertyDelegated) p:kotlin.annotation(propertyDelegated) p:kotlin.jvm(propertyDelegated) p:kotlin.io(propertyDelegated) c:foo.bar.D1(getPropertyDelegated) c:foo.bar.D1(getPROPERTYDelegated)*/D1() +/*p:foo.bar*/var y1 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D1(getValue) c:foo.bar.D1(setValue) p:foo.bar(setValue) p:java.lang(setValue) p:kotlin(setValue) p:kotlin.annotation(setValue) p:kotlin.jvm(setValue) p:kotlin.io(setValue) c:foo.bar.D1(propertyDelegated) p:foo.bar(propertyDelegated) p:java.lang(propertyDelegated) p:kotlin(propertyDelegated) p:kotlin.annotation(propertyDelegated) p:kotlin.jvm(propertyDelegated) p:kotlin.io(propertyDelegated) c:foo.bar.D1(getPropertyDelegated) c:foo.bar.D1(getPROPERTYDelegated)*/D1() -/*p:foo.bar*/val x2 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D2(getValue) p:foo.bar(getValue) p:java.lang(getValue) p:kotlin(getValue) p:kotlin.annotation(getValue) p:kotlin.jvm(getValue) p:kotlin.io(getValue) c:foo.bar.D2(getGetValue) c:foo.bar.D2(getGETValue) c:foo.bar.D2(get) p:foo.bar(get) p:java.lang(get) p:kotlin(get) p:kotlin.annotation(get) p:kotlin.jvm(get) p:kotlin.io(get) c:foo.bar.D2(propertyDelegated) p:foo.bar(propertyDelegated) p:java.lang(propertyDelegated) p:kotlin(propertyDelegated) p:kotlin.annotation(propertyDelegated) p:kotlin.jvm(propertyDelegated) p:kotlin.io(propertyDelegated)*/D2() -/*p:foo.bar*/var y2 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D2(getValue) p:foo.bar(getValue) p:java.lang(getValue) p:kotlin(getValue) p:kotlin.annotation(getValue) p:kotlin.jvm(getValue) p:kotlin.io(getValue) c:foo.bar.D2(getGetValue) c:foo.bar.D2(getGETValue) c:foo.bar.D2(get) p:foo.bar(get) p:java.lang(get) p:kotlin(get) p:kotlin.annotation(get) p:kotlin.jvm(get) p:kotlin.io(get) c:foo.bar.D2(setValue) p:foo.bar(setValue) p:java.lang(setValue) p:kotlin(setValue) p:kotlin.annotation(setValue) p:kotlin.jvm(setValue) p:kotlin.io(setValue) c:foo.bar.D2(getSetValue) c:foo.bar.D2(getSETValue) c:foo.bar.D2(set) c:foo.bar.D2(propertyDelegated) p:foo.bar(propertyDelegated) p:java.lang(propertyDelegated) p:kotlin(propertyDelegated) p:kotlin.annotation(propertyDelegated) p:kotlin.jvm(propertyDelegated) p:kotlin.io(propertyDelegated)*/D2() +/*p:foo.bar*/val x2 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D2(getValue) p:foo.bar(getValue) p:java.lang(getValue) p:kotlin(getValue) p:kotlin.annotation(getValue) p:kotlin.jvm(getValue) p:kotlin.io(getValue) c:foo.bar.D2(propertyDelegated) p:foo.bar(propertyDelegated) p:java.lang(propertyDelegated) p:kotlin(propertyDelegated) p:kotlin.annotation(propertyDelegated) p:kotlin.jvm(propertyDelegated) p:kotlin.io(propertyDelegated)*/D2() +/*p:foo.bar*/var y2 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D2(getValue) p:foo.bar(getValue) p:java.lang(getValue) p:kotlin(getValue) p:kotlin.annotation(getValue) p:kotlin.jvm(getValue) p:kotlin.io(getValue) c:foo.bar.D2(setValue) c:foo.bar.D2(propertyDelegated) p:foo.bar(propertyDelegated) p:java.lang(propertyDelegated) p:kotlin(propertyDelegated) p:kotlin.annotation(propertyDelegated) p:kotlin.jvm(propertyDelegated) p:kotlin.io(propertyDelegated)*/D2() -/*p:foo.bar*/val x3 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D3(getValue) p:foo.bar(getValue) p:java.lang(getValue) p:kotlin(getValue) p:kotlin.annotation(getValue) p:kotlin.jvm(getValue) p:kotlin.io(getValue) c:foo.bar.D3(getGetValue) c:foo.bar.D3(getGETValue) c:foo.bar.D3(get) p:foo.bar(get) p:java.lang(get) p:kotlin(get) p:kotlin.annotation(get) p:kotlin.jvm(get) p:kotlin.io(get) c:foo.bar.D3(propertyDelegated)*/D3() -/*p:foo.bar*/var y3 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D3(getValue) p:foo.bar(getValue) p:java.lang(getValue) p:kotlin(getValue) p:kotlin.annotation(getValue) p:kotlin.jvm(getValue) p:kotlin.io(getValue) c:foo.bar.D3(getGetValue) c:foo.bar.D3(getGETValue) c:foo.bar.D3(get) p:foo.bar(get) p:java.lang(get) p:kotlin(get) p:kotlin.annotation(get) p:kotlin.jvm(get) p:kotlin.io(get) c:foo.bar.D3(setValue) p:foo.bar(setValue) p:java.lang(setValue) p:kotlin(setValue) p:kotlin.annotation(setValue) p:kotlin.jvm(setValue) p:kotlin.io(setValue) c:foo.bar.D3(getSetValue) c:foo.bar.D3(getSETValue) c:foo.bar.D3(set) c:foo.bar.D3(propertyDelegated)*/D3() +/*p:foo.bar*/val x3 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D3(getValue) p:foo.bar(getValue) p:java.lang(getValue) p:kotlin(getValue) p:kotlin.annotation(getValue) p:kotlin.jvm(getValue) p:kotlin.io(getValue) c:foo.bar.D3(propertyDelegated)*/D3() +/*p:foo.bar*/var y3 by /*p:foo.bar p:java.lang p:kotlin p:kotlin.annotation p:kotlin.jvm p:kotlin.io c:foo.bar.D3(getValue) p:foo.bar(getValue) p:java.lang(getValue) p:kotlin(getValue) p:kotlin.annotation(getValue) p:kotlin.jvm(getValue) p:kotlin.io(getValue) c:foo.bar.D3(setValue) c:foo.bar.D3(propertyDelegated)*/D3() diff --git a/jps-plugin/testData/incremental/lookupTracker/conventions/mathematicalLike.kt b/jps-plugin/testData/incremental/lookupTracker/conventions/mathematicalLike.kt index 07fad84d3bf..69c457b8ef9 100644 --- a/jps-plugin/testData/incremental/lookupTracker/conventions/mathematicalLike.kt +++ b/jps-plugin/testData/incremental/lookupTracker/conventions/mathematicalLike.kt @@ -3,22 +3,22 @@ package foo.bar /*p:foo.bar*/fun testOperators(a: /*p:foo.bar*/A, b: /*p:foo.bar*/Int) { var d = a - d/*c:foo.bar.A(inc) p:foo.bar(inc) p:java.lang(inc) p:kotlin(inc) p:kotlin.annotation(inc) p:kotlin.jvm(inc) p:kotlin.io(inc) c:foo.bar.A(getInc) c:foo.bar.A(getINC)*/++ - /*c:foo.bar.A(inc) p:foo.bar(inc) p:java.lang(inc) p:kotlin(inc) p:kotlin.annotation(inc) p:kotlin.jvm(inc) p:kotlin.io(inc) c:foo.bar.A(getInc) c:foo.bar.A(getINC)*/++d - d/*c:foo.bar.A(dec) p:foo.bar(dec) p:java.lang(dec) p:kotlin(dec) p:kotlin.annotation(dec) p:kotlin.jvm(dec) p:kotlin.io(dec) c:foo.bar.A(getDec) c:foo.bar.A(getDEC)*/-- - /*c:foo.bar.A(dec) p:foo.bar(dec) p:java.lang(dec) p:kotlin(dec) p:kotlin.annotation(dec) p:kotlin.jvm(dec) p:kotlin.io(dec) c:foo.bar.A(getDec) c:foo.bar.A(getDEC)*/--d + d/*c:foo.bar.A(inc)*/++ + /*c:foo.bar.A(inc)*/++d + d/*c:foo.bar.A(dec) p:foo.bar(dec) p:java.lang(dec) p:kotlin(dec) p:kotlin.annotation(dec) p:kotlin.jvm(dec) p:kotlin.io(dec)*/-- + /*c:foo.bar.A(dec) p:foo.bar(dec) p:java.lang(dec) p:kotlin(dec) p:kotlin.annotation(dec) p:kotlin.jvm(dec) p:kotlin.io(dec)*/--d - a /*c:foo.bar.A(plus) p:foo.bar(plus) p:java.lang(plus) p:kotlin(plus) p:kotlin.annotation(plus) p:kotlin.jvm(plus) p:kotlin.io(plus) c:foo.bar.A(getPlus) c:foo.bar.A(getPLUS)*/+ b - a /*c:foo.bar.A(minus) p:foo.bar(minus) p:java.lang(minus) p:kotlin(minus) p:kotlin.annotation(minus) p:kotlin.jvm(minus) p:kotlin.io(minus) c:foo.bar.A(getMinus) c:foo.bar.A(getMINUS)*/- b - /*c:foo.bar.A(not) p:foo.bar(not) p:java.lang(not) p:kotlin(not) p:kotlin.annotation(not) p:kotlin.jvm(not) p:kotlin.io(not) c:foo.bar.A(getNot) c:foo.bar.A(getNOT)*/!a + a /*c:foo.bar.A(plus)*/+ b + a /*c:foo.bar.A(minus) p:foo.bar(minus) p:java.lang(minus) p:kotlin(minus) p:kotlin.annotation(minus) p:kotlin.jvm(minus) p:kotlin.io(minus)*/- b + /*c:foo.bar.A(not) p:foo.bar(not) p:java.lang(not) p:kotlin(not) p:kotlin.annotation(not) p:kotlin.jvm(not) p:kotlin.io(not)*/!a // for val - a /*c:foo.bar.A(timesAssign) p:foo.bar(timesAssign) p:java.lang(timesAssign) p:kotlin(timesAssign) p:kotlin.annotation(timesAssign) p:kotlin.jvm(timesAssign) p:kotlin.io(timesAssign) c:foo.bar.A(getTimesAssign) c:foo.bar.A(getTIMESAssign)*/*= b - a /*c:foo.bar.A(divAssign) p:foo.bar(divAssign) p:java.lang(divAssign) p:kotlin(divAssign) p:kotlin.annotation(divAssign) p:kotlin.jvm(divAssign) p:kotlin.io(divAssign) c:foo.bar.A(getDivAssign) c:foo.bar.A(getDIVAssign)*//= b + a /*c:foo.bar.A(timesAssign)*/*= b + a /*c:foo.bar.A(divAssign) p:foo.bar(divAssign) p:java.lang(divAssign) p:kotlin(divAssign) p:kotlin.annotation(divAssign) p:kotlin.jvm(divAssign) p:kotlin.io(divAssign)*//= b // for var - d /*c:foo.bar.A(plusAssign) p:foo.bar(plusAssign) p:java.lang(plusAssign) p:kotlin(plusAssign) p:kotlin.annotation(plusAssign) p:kotlin.jvm(plusAssign) p:kotlin.io(plusAssign) c:foo.bar.A(getPlusAssign) c:foo.bar.A(getPLUSAssign) c:foo.bar.A(plus) p:foo.bar(plus) p:java.lang(plus) p:kotlin(plus) p:kotlin.annotation(plus) p:kotlin.jvm(plus) p:kotlin.io(plus) c:foo.bar.A(getPlus) c:foo.bar.A(getPLUS)*/+= b - d /*c:foo.bar.A(minusAssign) p:foo.bar(minusAssign) p:java.lang(minusAssign) p:kotlin(minusAssign) p:kotlin.annotation(minusAssign) p:kotlin.jvm(minusAssign) p:kotlin.io(minusAssign) c:foo.bar.A(getMinusAssign) c:foo.bar.A(getMINUSAssign) c:foo.bar.A(minus) p:foo.bar(minus) p:java.lang(minus) p:kotlin(minus) p:kotlin.annotation(minus) p:kotlin.jvm(minus) p:kotlin.io(minus) c:foo.bar.A(getMinus) c:foo.bar.A(getMINUS)*/-= b - d /*c:foo.bar.A(timesAssign) p:foo.bar(timesAssign) p:java.lang(timesAssign) p:kotlin(timesAssign) p:kotlin.annotation(timesAssign) p:kotlin.jvm(timesAssign) p:kotlin.io(timesAssign) c:foo.bar.A(getTimesAssign) c:foo.bar.A(getTIMESAssign) c:foo.bar.A(times) p:foo.bar(times) p:java.lang(times) p:kotlin(times) p:kotlin.annotation(times) p:kotlin.jvm(times) p:kotlin.io(times) c:foo.bar.A(getTimes) c:foo.bar.A(getTIMES)*/*= b - d /*c:foo.bar.A(divAssign) p:foo.bar(divAssign) p:java.lang(divAssign) p:kotlin(divAssign) p:kotlin.annotation(divAssign) p:kotlin.jvm(divAssign) p:kotlin.io(divAssign) c:foo.bar.A(getDivAssign) c:foo.bar.A(getDIVAssign) c:foo.bar.A(div) p:foo.bar(div) p:java.lang(div) p:kotlin(div) p:kotlin.annotation(div) p:kotlin.jvm(div) p:kotlin.io(div) c:foo.bar.A(getDiv) c:foo.bar.A(getDIV)*//= b + d /*c:foo.bar.A(plusAssign) p:foo.bar(plusAssign) p:java.lang(plusAssign) p:kotlin(plusAssign) p:kotlin.annotation(plusAssign) p:kotlin.jvm(plusAssign) p:kotlin.io(plusAssign) c:foo.bar.A(getPlusAssign) c:foo.bar.A(getPLUSAssign) c:foo.bar.A(plus)*/+= b + d /*c:foo.bar.A(minusAssign) p:foo.bar(minusAssign) p:java.lang(minusAssign) p:kotlin(minusAssign) p:kotlin.annotation(minusAssign) p:kotlin.jvm(minusAssign) p:kotlin.io(minusAssign) c:foo.bar.A(getMinusAssign) c:foo.bar.A(getMINUSAssign) c:foo.bar.A(minus) p:foo.bar(minus) p:java.lang(minus) p:kotlin(minus) p:kotlin.annotation(minus) p:kotlin.jvm(minus) p:kotlin.io(minus)*/-= b + d /*c:foo.bar.A(timesAssign) c:foo.bar.A(times) p:foo.bar(times) p:java.lang(times) p:kotlin(times) p:kotlin.annotation(times) p:kotlin.jvm(times) p:kotlin.io(times) c:foo.bar.A(getTimes) c:foo.bar.A(getTIMES)*/*= b + d /*c:foo.bar.A(divAssign) p:foo.bar(divAssign) p:java.lang(divAssign) p:kotlin(divAssign) p:kotlin.annotation(divAssign) p:kotlin.jvm(divAssign) p:kotlin.io(divAssign) c:foo.bar.A(div) p:foo.bar(div) p:java.lang(div) p:kotlin(div) p:kotlin.annotation(div) p:kotlin.jvm(div) p:kotlin.io(div) c:foo.bar.A(getDiv) c:foo.bar.A(getDIV)*//= b } diff --git a/jps-plugin/testData/incremental/lookupTracker/conventions/other.kt b/jps-plugin/testData/incremental/lookupTracker/conventions/other.kt index d6d7481e2a1..9e9e8aa46d4 100644 --- a/jps-plugin/testData/incremental/lookupTracker/conventions/other.kt +++ b/jps-plugin/testData/incremental/lookupTracker/conventions/other.kt @@ -1,16 +1,16 @@ package foo.bar /*p:foo.bar*/fun testOther(a: /*p:foo.bar*/A, b: /*p:foo.bar*/Int, c: /*p:foo.bar*/Any, na: /*p:foo.bar*/A?) { - /*c:foo.bar.A(set) p:foo.bar(set) p:java.lang(set) p:kotlin(set) p:kotlin.annotation(set) p:kotlin.jvm(set) p:kotlin.io(set) c:foo.bar.A(getSet) c:foo.bar.A(getSET)*/a[1] = /*c:foo.bar.A(get) p:foo.bar(get) p:java.lang(get) p:kotlin(get) p:kotlin.annotation(get) p:kotlin.jvm(get) p:kotlin.io(get) c:foo.bar.A(getGet) c:foo.bar.A(getGET)*/a[2] + /*c:foo.bar.A(set) p:foo.bar(set) p:java.lang(set) p:kotlin(set) p:kotlin.annotation(set) p:kotlin.jvm(set) p:kotlin.io(set)*/a[1] = /*c:foo.bar.A(get)*/a[2] - b /*c:foo.bar.A(contains) p:foo.bar(contains) p:java.lang(contains) p:kotlin(contains) p:kotlin.annotation(contains) p:kotlin.jvm(contains) p:kotlin.io(contains) c:foo.bar.A(getContains) c:foo.bar.A(getCONTAINS)*/in a - "s" /*c:foo.bar.A(contains) p:foo.bar(contains) p:java.lang(contains) p:kotlin(contains) p:kotlin.annotation(contains) p:kotlin.jvm(contains) p:kotlin.io(contains) c:foo.bar.A(getContains) c:foo.bar.A(getCONTAINS)*/!in a + b /*c:foo.bar.A(contains)*/in a + "s" /*c:foo.bar.A(contains) p:foo.bar(contains) p:java.lang(contains) p:kotlin(contains) p:kotlin.annotation(contains) p:kotlin.jvm(contains) p:kotlin.io(contains)*/!in a - /*c:foo.bar.A(invoke) p:foo.bar(invoke) p:java.lang(invoke) p:kotlin(invoke) p:kotlin.annotation(invoke) p:kotlin.jvm(invoke) p:kotlin.io(invoke)*/a() + /*c:foo.bar.A(invoke)*/a() /*c:foo.bar.A(invoke) p:foo.bar(invoke) p:java.lang(invoke) p:kotlin(invoke) p:kotlin.annotation(invoke) p:kotlin.jvm(invoke) p:kotlin.io(invoke)*/a(1) - val (/*c:foo.bar.A(component1) p:foo.bar(component1) p:java.lang(component1) p:kotlin(component1) p:kotlin.annotation(component1) p:kotlin.jvm(component1) p:kotlin.io(component1) c:foo.bar.A(getComponent1)*/h, /*c:foo.bar.A(component2) p:foo.bar(component2) p:java.lang(component2) p:kotlin(component2) p:kotlin.annotation(component2) p:kotlin.jvm(component2) p:kotlin.io(component2) c:foo.bar.A(getComponent2)*/t) = a; + val (/*c:foo.bar.A(component1)*/h, /*c:foo.bar.A(component2) p:foo.bar(component2) p:java.lang(component2) p:kotlin(component2) p:kotlin.annotation(component2) p:kotlin.jvm(component2) p:kotlin.io(component2)*/t) = a; - for ((/*c:foo.bar.A(component1) p:foo.bar(component1) p:java.lang(component1) p:kotlin(component1) p:kotlin.annotation(component1) p:kotlin.jvm(component1) p:kotlin.io(component1) c:foo.bar.A(getComponent1)*/f, /*c:foo.bar.A(component2) p:foo.bar(component2) p:java.lang(component2) p:kotlin(component2) p:kotlin.annotation(component2) p:kotlin.jvm(component2) p:kotlin.io(component2) c:foo.bar.A(getComponent2)*/s) in /*c:foo.bar.A(iterator) c:foo.bar.A(hasNext) p:foo.bar(hasNext) p:java.lang(hasNext) p:kotlin(hasNext) p:kotlin.annotation(hasNext) p:kotlin.jvm(hasNext) p:kotlin.io(hasNext) c:foo.bar.A(next)*/a); - for ((/*c:foo.bar.A(component1) p:foo.bar(component1) p:java.lang(component1) p:kotlin(component1) p:kotlin.annotation(component1) p:kotlin.jvm(component1) p:kotlin.io(component1) c:foo.bar.A(getComponent1)*/f, /*c:foo.bar.A(component2) p:foo.bar(component2) p:java.lang(component2) p:kotlin(component2) p:kotlin.annotation(component2) p:kotlin.jvm(component2) p:kotlin.io(component2) c:foo.bar.A(getComponent2)*/s) in /*c:foo.bar.A(iterator) p:foo.bar(iterator) p:java.lang(iterator) p:kotlin(iterator) p:kotlin.annotation(iterator) p:kotlin.jvm(iterator) p:kotlin.io(iterator) c:foo.bar.A(hasNext) p:foo.bar(hasNext) p:java.lang(hasNext) p:kotlin(hasNext) p:kotlin.annotation(hasNext) p:kotlin.jvm(hasNext) p:kotlin.io(hasNext) c:foo.bar.A(next)*/na); + for ((/*c:foo.bar.A(component1)*/f, /*c:foo.bar.A(component2) p:foo.bar(component2) p:java.lang(component2) p:kotlin(component2) p:kotlin.annotation(component2) p:kotlin.jvm(component2) p:kotlin.io(component2)*/s) in /*c:foo.bar.A(iterator) c:foo.bar.A(hasNext) p:foo.bar(hasNext) p:java.lang(hasNext) p:kotlin(hasNext) p:kotlin.annotation(hasNext) p:kotlin.jvm(hasNext) p:kotlin.io(hasNext) c:foo.bar.A(next)*/a); + for ((/*c:foo.bar.A(component1)*/f, /*c:foo.bar.A(component2) p:foo.bar(component2) p:java.lang(component2) p:kotlin(component2) p:kotlin.annotation(component2) p:kotlin.jvm(component2) p:kotlin.io(component2)*/s) in /*c:foo.bar.A(iterator) p:foo.bar(iterator) p:java.lang(iterator) p:kotlin(iterator) p:kotlin.annotation(iterator) p:kotlin.jvm(iterator) p:kotlin.io(iterator) c:foo.bar.A(hasNext) p:foo.bar(hasNext) p:java.lang(hasNext) p:kotlin(hasNext) p:kotlin.annotation(hasNext) p:kotlin.jvm(hasNext) p:kotlin.io(hasNext) c:foo.bar.A(next)*/na); } diff --git a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineGet.kt b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineGet.kt index a5ca9157e97..310ee0540d5 100644 --- a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineGet.kt +++ b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineGet.kt @@ -2,6 +2,6 @@ package inline import kotlin.reflect.KProperty -inline fun Inline.getValue(receiver: Any?, prop: KProperty<*>): Int { +inline operator fun Inline.getValue(receiver: Any?, prop: KProperty<*>): Int { return 0 } diff --git a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineGet.kt.new.1 b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineGet.kt.new.1 index c1e548cf52c..48363763f12 100644 --- a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineGet.kt.new.1 +++ b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineGet.kt.new.1 @@ -2,6 +2,6 @@ package inline import kotlin.reflect.KProperty -inline fun Inline.getValue(receiver: Any?, prop: KProperty<*>): Int { +inline operator fun Inline.getValue(receiver: Any?, prop: KProperty<*>): Int { return 1 } diff --git a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineSet.kt b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineSet.kt index 36754dd7b0e..6f6684e1595 100644 --- a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineSet.kt +++ b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineSet.kt @@ -2,6 +2,6 @@ package inline import kotlin.reflect.KProperty -inline fun Inline.setValue(receiver: Any?, prop: KProperty<*>, value: Int) { +inline operator fun Inline.setValue(receiver: Any?, prop: KProperty<*>, value: Int) { println(value) } diff --git a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineSet.kt.new.2 b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineSet.kt.new.2 index bec3dc03047..d85c786fbf5 100644 --- a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineSet.kt.new.2 +++ b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineExtensionAccessor/inlineSet.kt.new.2 @@ -2,6 +2,6 @@ package inline import kotlin.reflect.KProperty -inline fun Inline.setValue(receiver: Any?, prop: KProperty<*>, value: Int) { +inline operator fun Inline.setValue(receiver: Any?, prop: KProperty<*>, value: Int) { println(value * 2) } diff --git a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt index 059a1a9379d..4e82a0cda3f 100644 --- a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt +++ b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt @@ -3,11 +3,11 @@ package inline import kotlin.reflect.KProperty class Inline { - inline fun getValue(receiver: Any?, prop: KProperty<*>): Int { + inline operator fun getValue(receiver: Any?, prop: KProperty<*>): Int { return 0 } - inline fun setValue(receiver: Any?, prop: KProperty<*>, value: Int) { + inline operator fun setValue(receiver: Any?, prop: KProperty<*>, value: Int) { println(value) } } diff --git a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt.new.1 b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt.new.1 index b983f8237cb..fcf08146bf5 100644 --- a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt.new.1 +++ b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt.new.1 @@ -3,11 +3,11 @@ package inline import kotlin.reflect.KProperty class Inline { - inline fun getValue(receiver: Any?, prop: KProperty<*>): Int { + inline operator fun getValue(receiver: Any?, prop: KProperty<*>): Int { return 1 } - inline fun setValue(receiver: Any?, prop: KProperty<*>, value: Int) { + inline operator fun setValue(receiver: Any?, prop: KProperty<*>, value: Int) { println(value) } } diff --git a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt.new.2 b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt.new.2 index f65f3c2cf62..05c7f9e1835 100644 --- a/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt.new.2 +++ b/jps-plugin/testData/incremental/pureKotlin/delegatedPropertyInlineMethodAccessor/inline.kt.new.2 @@ -3,11 +3,11 @@ package inline import kotlin.reflect.KProperty class Inline { - inline fun getValue(receiver: Any?, prop: KProperty<*>): Int { + inline operator fun getValue(receiver: Any?, prop: KProperty<*>): Int { return 1 } - inline fun setValue(receiver: Any?, prop: KProperty<*>, value: Int) { + inline operator fun setValue(receiver: Any?, prop: KProperty<*>, value: Int) { println(value * 2) } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionTest.java index 01dfb0ce76e..b759f920f49 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionTest.java @@ -147,10 +147,6 @@ public class FunctionTest extends AbstractExpressionTest { checkFooBoxIsOk(); } - public void testInfixCall() throws Exception { - checkFooBoxIsOk(); - } - public void testLambdaOrLocalFunInsideEnumMethod() throws Exception { checkFooBoxIsOk(); } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InvokeConventionTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InvokeConventionTest.java index 1fc30e34685..e0d591598ff 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InvokeConventionTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InvokeConventionTest.java @@ -54,10 +54,6 @@ public final class InvokeConventionTest extends AbstractExpressionTest { fooBoxTest(); } - public void testInfixCall() throws Exception { - checkFooBoxIsOk(); - } - public void testInheritFromFunctionTraits() throws Exception { checkFooBoxIsOk(); } diff --git a/js/js.translator/testData/callableReference/property/cases/delegated.kt b/js/js.translator/testData/callableReference/property/cases/delegated.kt index 322c8658a9f..b8ae3bdb880 100644 --- a/js/js.translator/testData/callableReference/property/cases/delegated.kt +++ b/js/js.translator/testData/callableReference/property/cases/delegated.kt @@ -4,7 +4,7 @@ package foo import kotlin.reflect.KProperty object NumberDecrypter { - fun getValue(instance: Any?, data: KProperty<*>) = when (data.name) { + operator fun getValue(instance: Any?, data: KProperty<*>) = when (data.name) { "four" -> 4 "two" -> 2 else -> throw Exception() diff --git a/js/js.translator/testData/callableReference/property/cases/delegatedMutable.kt b/js/js.translator/testData/callableReference/property/cases/delegatedMutable.kt index a717d474f7e..a6e1ebd7acb 100644 --- a/js/js.translator/testData/callableReference/property/cases/delegatedMutable.kt +++ b/js/js.translator/testData/callableReference/property/cases/delegatedMutable.kt @@ -6,11 +6,11 @@ import kotlin.reflect.KProperty object Delegate { var value = "lol" - fun getValue(instance: Any?, data: KProperty<*>): String { + operator fun getValue(instance: Any?, data: KProperty<*>): String { return value } - fun setValue(instance: Any?, data: KProperty<*>, newValue: String) { + operator fun setValue(instance: Any?, data: KProperty<*>, newValue: String) { value = newValue } } diff --git a/js/js.translator/testData/callableReference/property/cases/simpleExtension.kt b/js/js.translator/testData/callableReference/property/cases/simpleExtension.kt index 655a1c39653..d2ff14ba96e 100644 --- a/js/js.translator/testData/callableReference/property/cases/simpleExtension.kt +++ b/js/js.translator/testData/callableReference/property/cases/simpleExtension.kt @@ -7,7 +7,7 @@ val String.id: String fun box(): String { val pr = String::id - if (pr["123"] != "123") return "Fail value: ${pr["123"]}" + if (pr.get("123") != "123") return "Fail value: ${pr.get("123")}" if (pr.name != "id") return "Fail name: ${pr.name}" diff --git a/js/js.translator/testData/callableReference/property/cases/simpleMutableExtension.kt b/js/js.translator/testData/callableReference/property/cases/simpleMutableExtension.kt index e83bb4de126..284dfdd68ed 100644 --- a/js/js.translator/testData/callableReference/property/cases/simpleMutableExtension.kt +++ b/js/js.translator/testData/callableReference/property/cases/simpleMutableExtension.kt @@ -13,9 +13,9 @@ var Int.foo: Int fun box(): String { val pr = Int::foo - if (pr.get(42) != 42) return "Fail 1: ${pr[42]}" + if (pr.get(42) != 42) return "Fail 1: ${pr.get(42)}" pr.set(200, 39) - if (pr.get(-239) != 0) return "Fail 2: ${pr[-239]}" + if (pr.get(-239) != 0) return "Fail 2: ${pr.get(-239)}" if (storage != 239) return "Fail 3: $storage" return "OK" } diff --git a/js/js.translator/testData/callableReference/property/cases/simpleMutableMember.kt b/js/js.translator/testData/callableReference/property/cases/simpleMutableMember.kt index 5bac4db5fff..3462a324335 100644 --- a/js/js.translator/testData/callableReference/property/cases/simpleMutableMember.kt +++ b/js/js.translator/testData/callableReference/property/cases/simpleMutableMember.kt @@ -7,9 +7,9 @@ fun box(): String { val o = Box("lorem") val prop = Box::value - if (prop.get(o) != "lorem") return "Fail 1: ${prop[o]}" + if (prop.get(o) != "lorem") return "Fail 1: ${prop.get(o)}" prop.set(o, "ipsum") - if (prop.get(o) != "ipsum") return "Fail 2: ${prop[o]}" + if (prop.get(o) != "ipsum") return "Fail 2: ${prop.get(o)}" if (o.value != "ipsum") return "Fail 3: ${o.value}" o.value = "dolor" if (prop.get(o) != "dolor") return "Fail 4: ${prop.get(o)}" diff --git a/js/js.translator/testData/delegateProperty/cases/delegateByExtensionProperty.kt b/js/js.translator/testData/delegateProperty/cases/delegateByExtensionProperty.kt index 02ae478e30a..f7f58ecc12c 100644 --- a/js/js.translator/testData/delegateProperty/cases/delegateByExtensionProperty.kt +++ b/js/js.translator/testData/delegateProperty/cases/delegateByExtensionProperty.kt @@ -10,12 +10,12 @@ fun format(event: String, property: String, value: Int): String object LoggerDelegate { var log = "" - fun getValue(state: State, desc: KProperty<*>): Int { + operator fun getValue(state: State, desc: KProperty<*>): Int { log += format("get", desc.name, state.realValue) return state.realValue } - fun setValue(state: State, desc: KProperty<*>, value: Int) { + operator fun setValue(state: State, desc: KProperty<*>, value: Int) { log += format("set", desc.name, value) state.realValue = value } diff --git a/js/js.translator/testData/delegateProperty/cases/delegateByTopLevelFun.kt b/js/js.translator/testData/delegateProperty/cases/delegateByTopLevelFun.kt index cdf4a00e766..c3a6ac4a4cf 100644 --- a/js/js.translator/testData/delegateProperty/cases/delegateByTopLevelFun.kt +++ b/js/js.translator/testData/delegateProperty/cases/delegateByTopLevelFun.kt @@ -4,8 +4,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } diff --git a/js/js.translator/testData/delegateProperty/cases/delegateByTopLevelProperty.kt b/js/js.translator/testData/delegateProperty/cases/delegateByTopLevelProperty.kt index 16ded5256f0..47315182d8b 100644 --- a/js/js.translator/testData/delegateProperty/cases/delegateByTopLevelProperty.kt +++ b/js/js.translator/testData/delegateProperty/cases/delegateByTopLevelProperty.kt @@ -4,8 +4,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } diff --git a/js/js.translator/testData/delegateProperty/cases/delegateWithPropertyAccess.kt b/js/js.translator/testData/delegateProperty/cases/delegateWithPropertyAccess.kt index 16ded5256f0..47315182d8b 100644 --- a/js/js.translator/testData/delegateProperty/cases/delegateWithPropertyAccess.kt +++ b/js/js.translator/testData/delegateProperty/cases/delegateWithPropertyAccess.kt @@ -4,8 +4,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } diff --git a/js/js.translator/testData/delegateProperty/cases/getAsExtensionFun.kt b/js/js.translator/testData/delegateProperty/cases/getAsExtensionFun.kt index 1a087c0ad36..337d4e872f6 100644 --- a/js/js.translator/testData/delegateProperty/cases/getAsExtensionFun.kt +++ b/js/js.translator/testData/delegateProperty/cases/getAsExtensionFun.kt @@ -5,7 +5,7 @@ import kotlin.reflect.KProperty class Delegate { } -fun Delegate.getValue(t: Any?, p: KProperty<*>): Int = 1 +operator fun Delegate.getValue(t: Any?, p: KProperty<*>): Int = 1 class A { val prop: Int by Delegate() diff --git a/js/js.translator/testData/delegateProperty/cases/propertyMetadata.kt b/js/js.translator/testData/delegateProperty/cases/propertyMetadata.kt index 3e5b3e1f6d7..82f3ffb2837 100644 --- a/js/js.translator/testData/delegateProperty/cases/propertyMetadata.kt +++ b/js/js.translator/testData/delegateProperty/cases/propertyMetadata.kt @@ -7,10 +7,10 @@ interface WithName { } class GetPropertyName() { - fun getValue(withName: WithName, property: KProperty<*>): String { + operator fun getValue(withName: WithName, property: KProperty<*>): String { return withName.name + ":" + property.name; } - fun setValue(withName: WithName, property: KProperty<*>, value: String) { + operator fun setValue(withName: WithName, property: KProperty<*>, value: String) { withName.name = value + ":" + property.name } } diff --git a/js/js.translator/testData/delegateProperty/cases/setAsExtensionFun.kt b/js/js.translator/testData/delegateProperty/cases/setAsExtensionFun.kt index 9185cb272a7..848a4bc0a68 100644 --- a/js/js.translator/testData/delegateProperty/cases/setAsExtensionFun.kt +++ b/js/js.translator/testData/delegateProperty/cases/setAsExtensionFun.kt @@ -4,10 +4,10 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner } -fun Delegate.setValue(t: Any?, p: KProperty<*>, i: Int) { +operator fun Delegate.setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } diff --git a/js/js.translator/testData/delegateProperty/cases/simple.kt b/js/js.translator/testData/delegateProperty/cases/simple.kt index a1b20662e84..a4dac4db85e 100644 --- a/js/js.translator/testData/delegateProperty/cases/simple.kt +++ b/js/js.translator/testData/delegateProperty/cases/simple.kt @@ -7,10 +7,10 @@ interface WithNumber { } class IncNumber(val inc: Int) { - fun getValue(withNumber: WithNumber, property: KProperty<*>): Int { + operator fun getValue(withNumber: WithNumber, property: KProperty<*>): Int { return withNumber.number + inc; } - fun setValue(withNumber: WithNumber, property: KProperty<*>, value: Int) { + operator fun setValue(withNumber: WithNumber, property: KProperty<*>, value: Int) { withNumber.number = value; } } diff --git a/js/js.translator/testData/delegateProperty/cases/topLevelVal.kt b/js/js.translator/testData/delegateProperty/cases/topLevelVal.kt index b9eea14798f..d1391dacaf8 100644 --- a/js/js.translator/testData/delegateProperty/cases/topLevelVal.kt +++ b/js/js.translator/testData/delegateProperty/cases/topLevelVal.kt @@ -3,7 +3,7 @@ package foo import kotlin.reflect.KProperty class Delegate { - fun getValue(t: Any?, p: KProperty<*>): Int = 1 + operator fun getValue(t: Any?, p: KProperty<*>): Int = 1 } val prop: Int by Delegate() diff --git a/js/js.translator/testData/delegateProperty/cases/topLevelVar.kt b/js/js.translator/testData/delegateProperty/cases/topLevelVar.kt index f84c8ce0d96..56b64283a1b 100644 --- a/js/js.translator/testData/delegateProperty/cases/topLevelVar.kt +++ b/js/js.translator/testData/delegateProperty/cases/topLevelVar.kt @@ -4,8 +4,8 @@ import kotlin.reflect.KProperty class Delegate { var inner = 1 - fun getValue(t: Any?, p: KProperty<*>): Int = inner - fun setValue(t: Any?, p: KProperty<*>, i: Int) { + operator fun getValue(t: Any?, p: KProperty<*>): Int = inner + operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i } } diff --git a/js/js.translator/testData/delegateProperty/cases/withGenerics.kt b/js/js.translator/testData/delegateProperty/cases/withGenerics.kt index 2b092cf3796..0c5665355dd 100644 --- a/js/js.translator/testData/delegateProperty/cases/withGenerics.kt +++ b/js/js.translator/testData/delegateProperty/cases/withGenerics.kt @@ -8,13 +8,13 @@ interface Getter { class Delegate(val getter: Getter) { var t: T? = null - fun getValue(obj: Any, property: KProperty<*>): T { + operator fun getValue(obj: Any, property: KProperty<*>): T { if (t != null) { return t!! } return getter.get() } - fun setValue(obj: Any, property: KProperty<*>, value: T) { + operator fun setValue(obj: Any, property: KProperty<*>, value: T) { t = value } } diff --git a/js/js.translator/testData/delegation/cases/delegationExtensionPropertyDelegated.kt b/js/js.translator/testData/delegation/cases/delegationExtensionPropertyDelegated.kt index a91e1a93ef3..b6a8585d538 100644 --- a/js/js.translator/testData/delegation/cases/delegationExtensionPropertyDelegated.kt +++ b/js/js.translator/testData/delegation/cases/delegationExtensionPropertyDelegated.kt @@ -9,9 +9,9 @@ interface Base { } class Delegate(val multiplier: Int) { - fun getValue(state: State, desc: KProperty<*>): Int = multiplier * state.value + operator fun getValue(state: State, desc: KProperty<*>): Int = multiplier * state.value - fun setValue(state: State, desc: KProperty<*>, value: Int) { + operator fun setValue(state: State, desc: KProperty<*>, value: Int) { state.value = value / multiplier } diff --git a/js/js.translator/testData/dynamic/cases/equals.kt b/js/js.translator/testData/dynamic/cases/equals.kt index 06b91799211..a0e7d3465cc 100644 --- a/js/js.translator/testData/dynamic/cases/equals.kt +++ b/js/js.translator/testData/dynamic/cases/equals.kt @@ -38,11 +38,6 @@ fun box(): String { testTrue { a.equals(12) } testFalse { a.equals("12") } - testFalse { a equals 34 } - testFalse { a equals "34" } - testTrue { a equals 12 } - testFalse { a equals "12" } - val ff: dynamic = f testFalse { ff.equals(v) } assertTrue(f.equalsCalled, "f.equalsCalled") diff --git a/js/js.translator/testData/examples/cases/overloadBinaryOperator.kt b/js/js.translator/testData/examples/cases/overloadBinaryOperator.kt index 4afd53c97fc..9682dad1385 100644 --- a/js/js.translator/testData/examples/cases/overloadBinaryOperator.kt +++ b/js/js.translator/testData/examples/cases/overloadBinaryOperator.kt @@ -7,7 +7,7 @@ class ArrayWrapper() { contents.add(item) } - fun plus(b: ArrayWrapper): ArrayWrapper { + operator fun plus(b: ArrayWrapper): ArrayWrapper { val result = ArrayWrapper() result.contents.addAll(contents) result.contents.addAll(b.contents) diff --git a/js/js.translator/testData/examples/cases/overloadPlusAssignReturn.kt b/js/js.translator/testData/examples/cases/overloadPlusAssignReturn.kt index b6d0c3c0282..4e107093ddd 100644 --- a/js/js.translator/testData/examples/cases/overloadPlusAssignReturn.kt +++ b/js/js.translator/testData/examples/cases/overloadPlusAssignReturn.kt @@ -7,7 +7,7 @@ class ArrayWrapper() { contents.add(item) } - fun plusAssign(rhs: ArrayWrapper) { + operator fun plusAssign(rhs: ArrayWrapper) { contents.addAll(rhs.contents) } diff --git a/js/js.translator/testData/examples/cases/overloadPlusToPlusAssign.kt b/js/js.translator/testData/examples/cases/overloadPlusToPlusAssign.kt index c5236b0ace4..7b6863a7ab9 100644 --- a/js/js.translator/testData/examples/cases/overloadPlusToPlusAssign.kt +++ b/js/js.translator/testData/examples/cases/overloadPlusToPlusAssign.kt @@ -7,7 +7,7 @@ class ArrayWrapper() { contents.add(item) } - fun plus(rhs: ArrayWrapper): ArrayWrapper { + operator fun plus(rhs: ArrayWrapper): ArrayWrapper { val result = ArrayWrapper() result.contents.addAll(contents) result.contents.addAll(rhs.contents) diff --git a/js/js.translator/testData/examples/cases/overloadUnaryOperator.kt b/js/js.translator/testData/examples/cases/overloadUnaryOperator.kt index 865bf78c98c..3dc4581518e 100644 --- a/js/js.translator/testData/examples/cases/overloadUnaryOperator.kt +++ b/js/js.translator/testData/examples/cases/overloadUnaryOperator.kt @@ -7,7 +7,7 @@ class ArrayWrapper() { contents.add(item) } - fun minus(): ArrayWrapper { + operator fun unaryMinus(): ArrayWrapper { val result = ArrayWrapper() result.contents.addAll(contents) var i = contents.size(); @@ -17,7 +17,7 @@ class ArrayWrapper() { return result } - fun get(index: Int): T { + operator fun get(index: Int): T { return contents.get(index) } } diff --git a/js/js.translator/testData/expression/compareTo/cases/customCompareToMethod.kt b/js/js.translator/testData/expression/compareTo/cases/customCompareToMethod.kt index dd9dbade87d..563bcb3f30d 100644 --- a/js/js.translator/testData/expression/compareTo/cases/customCompareToMethod.kt +++ b/js/js.translator/testData/expression/compareTo/cases/customCompareToMethod.kt @@ -1,20 +1,20 @@ package foo class A(val value: Int) : Comparable { - override public fun compareTo(other: A): Int = other.value compareTo value + override public fun compareTo(other: A): Int = other.value.compareTo(value) } class B(val value: Int) fun testExtensionFunctionAsCompareTo() { - val compareTo: B.( B ) -> Int = { other -> other.value compareTo this.value } + val compareTo: B.( B ) -> Int = { other -> other.value.compareTo(this.value) } val x: B = B(100) val y: B = B(200) assertEquals(false, x < y, "ext fun: x < y") assertEquals(true, x > y, "ext fun: x > y") - assertEquals(1, x compareTo y, "ext fun: x compareTo y") + assertEquals(1, x.compareTo(y), "ext fun: x compareTo y") } fun testMethodAsCompareTo() { @@ -23,12 +23,12 @@ fun testMethodAsCompareTo() { assertEquals(false, x < y, "meth: x < y") assertEquals(true, x > y, "meth: x > y") - assertEquals(1, x compareTo y, "meth: x compareTo y") + assertEquals(1, x.compareTo(y), "meth: x compareTo y") val comparable: Comparable = x assertEquals(false, comparable < y, "meth: (x: Comparable) < y") assertEquals(true, comparable > y, "meth: (x: Comparable) > y") - assertEquals(1, comparable compareTo y, "meth: (x: Comparable) compareTo y") + assertEquals(1, comparable.compareTo(y), "meth: (x: Comparable) compareTo y") } fun box(): String { diff --git a/js/js.translator/testData/expression/equals/cases/explicitEqualsMethod.kt b/js/js.translator/testData/expression/equals/cases/explicitEqualsMethod.kt index eef5d7ab1b0..2fe7cb3de26 100644 --- a/js/js.translator/testData/expression/equals/cases/explicitEqualsMethod.kt +++ b/js/js.translator/testData/expression/equals/cases/explicitEqualsMethod.kt @@ -18,11 +18,11 @@ fun box(): Boolean { val b = Foo("abc") val c = Foo("def") - if (!(a equals b)) return false - if (a equals c) return false - if (Bar() equals Bar()) return false + if (!(a.equals(b))) return false + if (a.equals(c)) return false + if (Bar().equals(Bar())) return false val g = Bar() - if (!(g equals g)) return false - if (g equals Bar()) return false + if (!(g.equals(g))) return false + if (g.equals(Bar())) return false return true } \ No newline at end of file diff --git a/js/js.translator/testData/expression/equals/cases/explicitEqualsMethodForPrimitives.kt b/js/js.translator/testData/expression/equals/cases/explicitEqualsMethodForPrimitives.kt index 8a38f166c6f..261ae345cb1 100644 --- a/js/js.translator/testData/expression/equals/cases/explicitEqualsMethodForPrimitives.kt +++ b/js/js.translator/testData/expression/equals/cases/explicitEqualsMethodForPrimitives.kt @@ -2,20 +2,20 @@ package foo fun box(): Boolean { val a = 2 - if (!(a equals a)) return false - if (!(a equals 2)) return false - if (!(a equals 2.0)) return false + if (!(a.equals(a))) return false + if (!(a.equals(2))) return false + if (!(a.equals(2.0))) return false val c = "a" - if (!("a" equals c)) return false + if (!("a".equals(c))) return false if (!((null as Any?)?.equals(null) ?: true)) return false val d = 5.6 - if (!(d.toShort() equals 5.toShort())) return false - if (!(d.toByte() equals 5.toByte())) return false - if (!(d.toFloat() equals 5.6.toFloat())) return false - if (!(d.toInt() equals 5)) return false - if (true equals false) return false + if (!(d.toShort().equals(5.toShort()))) return false + if (!(d.toByte().equals(5.toByte()))) return false + if (!(d.toFloat().equals(5.6.toFloat()))) return false + if (!(d.toInt().equals(5))) return false + if (true.equals(false)) return false val n: Number = 3 - if (!(n equals 3.3.toInt())) return false + if (!(n.equals(3.3.toInt()))) return false return true } \ No newline at end of file diff --git a/js/js.translator/testData/expression/for/cases/forIteratesOverSomethingWithIterator.kt b/js/js.translator/testData/expression/for/cases/forIteratesOverSomethingWithIterator.kt index 45f49493790..a54f7edd582 100644 --- a/js/js.translator/testData/expression/for/cases/forIteratesOverSomethingWithIterator.kt +++ b/js/js.translator/testData/expression/for/cases/forIteratesOverSomethingWithIterator.kt @@ -2,12 +2,12 @@ package foo class Iter(val upper: Int) { var count: Int = 0 - fun hasNext(): Boolean = count < upper - fun next(): Int = count++ + operator fun hasNext(): Boolean = count < upper + operator fun next(): Int = count++ } class A(val upper: Int) { - fun iterator(): Iter = Iter(upper) + operator fun iterator(): Iter = Iter(upper) } fun box(): String { diff --git a/js/js.translator/testData/expression/for/cases/forWithSideEffectImElementAccessAndWithEmptyBody.kt b/js/js.translator/testData/expression/for/cases/forWithSideEffectImElementAccessAndWithEmptyBody.kt index 58541782541..6bc2c99db3f 100644 --- a/js/js.translator/testData/expression/for/cases/forWithSideEffectImElementAccessAndWithEmptyBody.kt +++ b/js/js.translator/testData/expression/for/cases/forWithSideEffectImElementAccessAndWithEmptyBody.kt @@ -3,18 +3,18 @@ package foo var log = "" class T(val id: Int) { - fun component1(): Int { + operator fun component1(): Int { log += "($id).component1();" return 1 } - fun component2(): String { + operator fun component2(): String { log += "($id).component2();" return "1" } } class C { - fun iterator(): Iterator = object: Iterator { + operator fun iterator(): Iterator = object: Iterator { var i = 0 var data = arrayOf(T(3), T(1), T(2)) override fun hasNext(): Boolean { diff --git a/js/js.translator/testData/expression/function/cases/infixCall.kt b/js/js.translator/testData/expression/function/cases/infixCall.kt deleted file mode 100644 index cdb75d00d23..00000000000 --- a/js/js.translator/testData/expression/function/cases/infixCall.kt +++ /dev/null @@ -1,19 +0,0 @@ -// EA-56241 -package foo - -fun Int.foo(a: Int) = this + a - -val bar = fun Int.(a: Int): Int = this * a - -fun test(op: Int.(Int) -> Int) = 3 op 20 - -fun box(): String { - val op = fun Int.(a: Int): Int = this / a - - assertEquals(41, 34 foo 7) - assertEquals(28, 4 bar 7) - assertEquals(-17, test { this - it }) - assertEquals(7, 49 op 7) - - return "OK" -} diff --git a/js/js.translator/testData/expression/identityEquals/cases/identityEqualsMethod.kt b/js/js.translator/testData/expression/identityEquals/cases/identityEqualsMethod.kt index 9f90f0daf61..d455f9feb6a 100644 --- a/js/js.translator/testData/expression/identityEquals/cases/identityEqualsMethod.kt +++ b/js/js.translator/testData/expression/identityEquals/cases/identityEqualsMethod.kt @@ -10,12 +10,12 @@ fun box(): String { val c = a if (!c.identityEquals(a)) return "c = a; c !== a" - if (X() identityEquals a) return "X() identityEquals a" + if (X().identityEquals(a)) return "X() identityEquals a" - val t = !(X() identityEquals a) + val t = !(X().identityEquals(a)) if (!t) return "t = !(X() identityEquals a); t == false" - val f = !!(X() identityEquals a) + val f = !!(X().identityEquals(a)) if (f) return "f = !!(X() identityEquals null); f == true" return "OK"; } \ No newline at end of file diff --git a/js/js.translator/testData/expression/identityEquals/cases/identityEqualsMethodForPrimitives.kt b/js/js.translator/testData/expression/identityEquals/cases/identityEqualsMethodForPrimitives.kt index 857edfc23e3..a0414aa1daf 100644 --- a/js/js.translator/testData/expression/identityEquals/cases/identityEqualsMethodForPrimitives.kt +++ b/js/js.translator/testData/expression/identityEquals/cases/identityEqualsMethodForPrimitives.kt @@ -2,12 +2,12 @@ package foo fun box(): String { if (!null.identityEquals(null)) return "null !== null" - if (!("ab" identityEquals "ab")) return "ab !== ab" - if (("ab" identityEquals "a")) return "ab === a" + if (!("ab".identityEquals("ab"))) return "ab !== ab" + if (("ab".identityEquals("a"))) return "ab === a" - if ("0" identityEquals 0) return "'0' === 0" - if (!(0 identityEquals 0)) return "0 !== 0" - if (0 identityEquals 1) return "0 === 1" + if ("0".identityEquals(0)) return "'0' === 0" + if (!(0.identityEquals(0))) return "0 !== 0" + if (0.identityEquals(1)) return "0 === 1" return "OK"; diff --git a/js/js.translator/testData/expression/invoke/cases/infixCall.kt b/js/js.translator/testData/expression/invoke/cases/infixCall.kt deleted file mode 100644 index 0e1bc571b4d..00000000000 --- a/js/js.translator/testData/expression/invoke/cases/infixCall.kt +++ /dev/null @@ -1,22 +0,0 @@ -// KT-3998 Infix call doesn't work for function literals and another classes which implements invoke convention (in JS backend) -package foo - -fun test(): String { - val a: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->String = { "a" } - val b: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->String = { - val aa = this as @Extension Function2; - val cc = it as @Extension Function2; - "${null.aa(null)} b ${null.cc(null)}" - } - val c: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->String = { "c" } - - val f = a.b(c) // works - val s = a b c //compiler crashes - return "$f | $s" -} - -fun box(): String { - assertEquals("a b c | a b c", test()) - - return "OK" -} diff --git a/js/js.translator/testData/expression/invoke/cases/inheritFromFunctionTraits.kt b/js/js.translator/testData/expression/invoke/cases/inheritFromFunctionTraits.kt index f47ecace2e5..2564890a063 100644 --- a/js/js.translator/testData/expression/invoke/cases/inheritFromFunctionTraits.kt +++ b/js/js.translator/testData/expression/invoke/cases/inheritFromFunctionTraits.kt @@ -10,19 +10,19 @@ package foo class Bar/* : Function0*/ { - fun invoke() = "Bar.invoke()" + operator fun invoke() = "Bar.invoke()" } class Baz/* : Function2*/ { - fun invoke(i: Int, b: Boolean) = "Baz.invoke($i, $b)" + operator fun invoke(i: Int, b: Boolean) = "Baz.invoke($i, $b)" } class Mixed/* : Function1, Function2*/ { - fun invoke(i: Int) = "Mixed.invoke($i)" - fun invoke(i: Int, b: Boolean) = "Mixed.invoke($i, $b)" + operator fun invoke(i: Int) = "Mixed.invoke($i)" + operator fun invoke(i: Int, b: Boolean) = "Mixed.invoke($i, $b)" } fun box(): String { diff --git a/js/js.translator/testData/expression/invoke/cases/invokeMethod.kt b/js/js.translator/testData/expression/invoke/cases/invokeMethod.kt index afe8921e969..7c051d19ee8 100644 --- a/js/js.translator/testData/expression/invoke/cases/invokeMethod.kt +++ b/js/js.translator/testData/expression/invoke/cases/invokeMethod.kt @@ -1,7 +1,7 @@ package foo class Foo(val postfix: String) { - public fun invoke(text: String): String { + operator fun invoke(text: String): String { return text + postfix } } diff --git a/js/js.translator/testData/expression/invoke/cases/invokeOnExprByConvention.kt b/js/js.translator/testData/expression/invoke/cases/invokeOnExprByConvention.kt index b18ca3e1f19..dfaec260132 100644 --- a/js/js.translator/testData/expression/invoke/cases/invokeOnExprByConvention.kt +++ b/js/js.translator/testData/expression/invoke/cases/invokeOnExprByConvention.kt @@ -1,8 +1,8 @@ package foo class A { - fun invoke() = "##" - fun invoke(i: Int) = "#${i}" + operator fun invoke() = "##" + operator fun invoke(i: Int) = "#${i}" } fun foo() = A() diff --git a/js/js.translator/testData/expression/invoke/cases/invokeWithDispatchReceiver.kt b/js/js.translator/testData/expression/invoke/cases/invokeWithDispatchReceiver.kt index 921719f95f3..17bc211c384 100644 --- a/js/js.translator/testData/expression/invoke/cases/invokeWithDispatchReceiver.kt +++ b/js/js.translator/testData/expression/invoke/cases/invokeWithDispatchReceiver.kt @@ -1,7 +1,7 @@ package foo class A { - fun invoke(i: Int) = i + operator fun invoke(i: Int) = i } fun box(): Boolean { diff --git a/js/js.translator/testData/expression/invoke/cases/invokeWithExtensionReceiver.kt b/js/js.translator/testData/expression/invoke/cases/invokeWithExtensionReceiver.kt index 98ad6219c11..c4ed18f31e7 100644 --- a/js/js.translator/testData/expression/invoke/cases/invokeWithExtensionReceiver.kt +++ b/js/js.translator/testData/expression/invoke/cases/invokeWithExtensionReceiver.kt @@ -1,6 +1,6 @@ package foo -fun Int.invoke(x: Int) = this + x +operator fun Int.invoke(x: Int) = this + x fun box(): Boolean { return 1(2) == 3 } diff --git a/js/js.translator/testData/expression/misc/cases/KT-1361-2.kt b/js/js.translator/testData/expression/misc/cases/KT-1361-2.kt index d55fb39f489..3fdf7006d82 100644 --- a/js/js.translator/testData/expression/misc/cases/KT-1361-2.kt +++ b/js/js.translator/testData/expression/misc/cases/KT-1361-2.kt @@ -1,7 +1,7 @@ package foo class Data(val rawData: Array, val width: Int, val height: Int) { - fun get(x: Int, y: Int): ColorLike { + operator fun get(x: Int, y: Int): ColorLike { return object : ColorLike { override val red: Int = rawData[(y * width + x) * 4 + 0]; override val green: Int = rawData[(y * width + x) * 4 + 1]; @@ -9,7 +9,7 @@ class Data(val rawData: Array, val width: Int, val height: Int) { } } - fun set(x: Int, y: Int, color: ColorLike) { + operator fun set(x: Int, y: Int, color: ColorLike) { rawData[(y * width + x) * 4 + 0] = color.red; rawData[(y * width + x) * 4 + 1] = color.green; rawData[(y * width + x) * 4 + 2] = color.blue; diff --git a/js/js.translator/testData/expression/misc/cases/KT-2314.kt b/js/js.translator/testData/expression/misc/cases/KT-2314.kt index 365dbee22e5..58b628cf891 100644 --- a/js/js.translator/testData/expression/misc/cases/KT-2314.kt +++ b/js/js.translator/testData/expression/misc/cases/KT-2314.kt @@ -11,7 +11,7 @@ fun box(): Boolean { } -inline public fun myArrayList(vararg values: T): ArrayList { +inline public fun myArrayList(vararg values: T): ArrayList { val c = ArrayList() for (v in values) { c.add(v) diff --git a/js/js.translator/testData/expression/misc/cases/KT-740-2.kt b/js/js.translator/testData/expression/misc/cases/KT-740-2.kt index 555f4bef262..ff022465338 100644 --- a/js/js.translator/testData/expression/misc/cases/KT-740-2.kt +++ b/js/js.translator/testData/expression/misc/cases/KT-740-2.kt @@ -16,12 +16,12 @@ fun get1(): Int { class A() { var p = 0 - fun get(i: Int): Int { + operator fun get(i: Int): Int { c1++ return 0 } - fun set(i: Int, value: Int) { + operator fun set(i: Int, value: Int) { c2++ } } diff --git a/js/js.translator/testData/expression/misc/cases/KT-740-3.kt b/js/js.translator/testData/expression/misc/cases/KT-740-3.kt index ece0dec44bc..d9691d6c812 100644 --- a/js/js.translator/testData/expression/misc/cases/KT-740-3.kt +++ b/js/js.translator/testData/expression/misc/cases/KT-740-3.kt @@ -6,10 +6,10 @@ var c2 = 0 class A() { var p = 0 - fun divAssign(a: Int) { + operator fun divAssign(a: Int) { c1++; } - fun times(a: Int): A { + operator fun times(a: Int): A { c2++; return this; } diff --git a/js/js.translator/testData/expression/misc/cases/intRange.kt b/js/js.translator/testData/expression/misc/cases/intRange.kt index b7123ab725e..d03f191f6be 100644 --- a/js/js.translator/testData/expression/misc/cases/intRange.kt +++ b/js/js.translator/testData/expression/misc/cases/intRange.kt @@ -4,7 +4,7 @@ class RangeIterator(val start: Int, var count: Int, val reversed: Boolean) { var i = start - fun next(): Int { + operator fun next(): Int { --count if (reversed) { i-- @@ -17,7 +17,7 @@ class RangeIterator(val start: Int, var count: Int, val reversed: Boolean) { } - fun hasNext() = (count > 0); + operator fun hasNext() = (count > 0); } class NumberRange(val start: Int, val size: Int, val reversed: Boolean) { @@ -34,7 +34,7 @@ class NumberRange(val start: Int, val size: Int, val reversed: Boolean) { } } - fun iterator() = RangeIterator(start, size, reversed); + operator fun iterator() = RangeIterator(start, size, reversed); } diff --git a/js/js.translator/testData/extensionFunction/cases/extensionFunctionCalledFromFor.kt b/js/js.translator/testData/extensionFunction/cases/extensionFunctionCalledFromFor.kt index b9ef9cbc45e..676d023da5f 100644 --- a/js/js.translator/testData/extensionFunction/cases/extensionFunctionCalledFromFor.kt +++ b/js/js.translator/testData/extensionFunction/cases/extensionFunctionCalledFromFor.kt @@ -12,12 +12,12 @@ class SimpleEnumerator { } class SimpleEnumeratorWrapper(private val enumerator: SimpleEnumerator) { - fun hasNext(): Boolean = enumerator.hasMoreElements() + operator fun hasNext(): Boolean = enumerator.hasMoreElements() - fun next() = enumerator.getNext() + operator fun next() = enumerator.getNext() } -fun SimpleEnumerator.iterator(): SimpleEnumeratorWrapper { +operator fun SimpleEnumerator.iterator(): SimpleEnumeratorWrapper { return SimpleEnumeratorWrapper(this) } diff --git a/js/js.translator/testData/inheritance/cases/overrideAnyMethods.kt b/js/js.translator/testData/inheritance/cases/overrideAnyMethods.kt index 232d685c88d..b534d6bf02a 100644 --- a/js/js.translator/testData/inheritance/cases/overrideAnyMethods.kt +++ b/js/js.translator/testData/inheritance/cases/overrideAnyMethods.kt @@ -17,7 +17,7 @@ fun String.myHashCode(): Int { class Foo(val name: String) { override fun equals(other: Any?): Boolean { if (other is Foo) return name == other.name - return this identityEquals other + return this.identityEquals(other) } override fun hashCode(): Int = name.myHashCode() override fun toString(): String = "Foo($name)" diff --git a/js/js.translator/testData/inline/cases/identityEquals.kt b/js/js.translator/testData/inline/cases/identityEquals.kt index 983e683425a..5e93abcaacb 100644 --- a/js/js.translator/testData/inline/cases/identityEquals.kt +++ b/js/js.translator/testData/inline/cases/identityEquals.kt @@ -3,11 +3,11 @@ package foo class A inline fun compare1(a: A): Boolean { - return a identityEquals a + return a.identityEquals(a) } inline fun compare2(a1: A, a2: A): Boolean { - return a1 identityEquals a2 + return a1.identityEquals(a2) } fun box(): String { diff --git a/js/js.translator/testData/inline/cases/multiDeclaration.kt b/js/js.translator/testData/inline/cases/multiDeclaration.kt index 9f3d175f8d4..1316f0d6b6a 100644 --- a/js/js.translator/testData/inline/cases/multiDeclaration.kt +++ b/js/js.translator/testData/inline/cases/multiDeclaration.kt @@ -5,8 +5,8 @@ package foo class A(val a: Int, val b: Int) -inline fun A.component1(): Int = a -inline fun A.component2(): Int = b +inline operator fun A.component1(): Int = a +inline operator fun A.component2(): Int = b fun box(): String { val (a, b) = A(1, 2) diff --git a/js/js.translator/testData/inlineEvaluationOrder/cases/multiDeclaration.kt b/js/js.translator/testData/inlineEvaluationOrder/cases/multiDeclaration.kt index 565610c6b37..6c74b935c1b 100644 --- a/js/js.translator/testData/inlineEvaluationOrder/cases/multiDeclaration.kt +++ b/js/js.translator/testData/inlineEvaluationOrder/cases/multiDeclaration.kt @@ -4,10 +4,9 @@ package foo class A(val x: Int, val y: Int) -fun A.component1(): Int = fizz(x) +operator fun A.component1(): Int = fizz(x) -inline -fun A.component2(): Int = buzz(y) +inline operator fun A.component2(): Int = buzz(y) fun box(): String { val (a, b) = A(1, 2) diff --git a/js/js.translator/testData/inlineEvaluationOrder/cases/multiDeclarationComplex.kt b/js/js.translator/testData/inlineEvaluationOrder/cases/multiDeclarationComplex.kt index 5b02c0a358e..ee8443e904f 100644 --- a/js/js.translator/testData/inlineEvaluationOrder/cases/multiDeclarationComplex.kt +++ b/js/js.translator/testData/inlineEvaluationOrder/cases/multiDeclarationComplex.kt @@ -6,18 +6,15 @@ package foo class A(val a: Int, val b: Int, val c: Int, val d: Int, val e: Int) -fun A.component1(): Int = fizz(a) +operator fun A.component1(): Int = fizz(a) -inline -fun A.component2(): Int = buzz(b) +inline operator fun A.component2(): Int = buzz(b) -inline -fun A.component3(): Int = buzz(c) +inline operator fun A.component3(): Int = buzz(c) -fun A.component4(): Int = fizz(d) +operator fun A.component4(): Int = fizz(d) -inline -fun A.component5(): Int = buzz(e) +inline operator fun A.component5(): Int = buzz(e) fun box(): String { val (a, b, c, d, e) = A(1, 2, 3, 4, 5) diff --git a/js/js.translator/testData/inlineMultiFile/cases/builders/builders.2.kt b/js/js.translator/testData/inlineMultiFile/cases/builders/builders.2.kt index 88b38dbd239..ee5241df59a 100644 --- a/js/js.translator/testData/inlineMultiFile/cases/builders/builders.2.kt +++ b/js/js.translator/testData/inlineMultiFile/cases/builders/builders.2.kt @@ -28,7 +28,7 @@ abstract class Tag(val name: String) : Element() { val children = ArrayList() val attributes = HashMap() - inline protected fun initTag(tag: T, init: T.() -> Unit): T { + inline protected fun initTag(tag: T, init: T.() -> Unit): T { tag.init() children.add(tag) return tag @@ -52,7 +52,7 @@ abstract class Tag(val name: String) : Element() { } abstract class TagWithText(name: String) : Tag(name) { - fun String.plus() { + operator fun String.unaryPlus() { children.add(TextElement(this)) } } diff --git a/js/js.translator/testData/inlineMultiFile/cases/buildersAndLambdaCapturing/buildersAndLambdaCapturing.2.kt b/js/js.translator/testData/inlineMultiFile/cases/buildersAndLambdaCapturing/buildersAndLambdaCapturing.2.kt index 1324303525b..6747c44046d 100644 --- a/js/js.translator/testData/inlineMultiFile/cases/buildersAndLambdaCapturing/buildersAndLambdaCapturing.2.kt +++ b/js/js.translator/testData/inlineMultiFile/cases/buildersAndLambdaCapturing/buildersAndLambdaCapturing.2.kt @@ -28,7 +28,7 @@ abstract class Tag(val name: String) : Element() { val children = ArrayList() val attributes = HashMap() - inline protected fun initTag(tag: T, init: T.() -> Unit): T { + inline protected fun initTag(tag: T, init: T.() -> Unit): T { tag.init() children.add(tag) return tag @@ -52,7 +52,7 @@ abstract class Tag(val name: String) : Element() { } abstract class TagWithText(name: String) : Tag(name) { - fun String.plus() { + operator fun String.unaryPlus() { children.add(TextElement(this)) } } diff --git a/js/js.translator/testData/inlineMultiFile/cases/with/with.2.kt b/js/js.translator/testData/inlineMultiFile/cases/with/with.2.kt index 373f634bde1..ae490946a64 100644 --- a/js/js.translator/testData/inlineMultiFile/cases/with/with.2.kt +++ b/js/js.translator/testData/inlineMultiFile/cases/with/with.2.kt @@ -32,4 +32,4 @@ public fun Input.copyTo(output: Output, size: Int): Int { return output.doOutput(this.data()) } -public inline fun with2(receiver : T, crossinline body : T.() -> Unit) : Unit = {receiver.body()}() +public inline fun with2(receiver : T, crossinline body : T.() -> Unit) : Unit = {receiver.body()}() diff --git a/js/js.translator/testData/inlineMultiModule/cases/callableReference/lib/lib.kt b/js/js.translator/testData/inlineMultiModule/cases/callableReference/lib/lib.kt index d06bad389f8..b8d49264199 100644 --- a/js/js.translator/testData/inlineMultiModule/cases/callableReference/lib/lib.kt +++ b/js/js.translator/testData/inlineMultiModule/cases/callableReference/lib/lib.kt @@ -1,5 +1,5 @@ package utils inline -public fun apply(x: T, fn: (T)->R): R = +public fun apply(x: T, fn: (T)->R): R = fn(x) \ No newline at end of file diff --git a/js/js.translator/testData/inlineMultiModule/cases/extensionLambda/lib/lib.kt b/js/js.translator/testData/inlineMultiModule/cases/extensionLambda/lib/lib.kt index fc56406dbf4..c4759cbe8ea 100644 --- a/js/js.translator/testData/inlineMultiModule/cases/extensionLambda/lib/lib.kt +++ b/js/js.translator/testData/inlineMultiModule/cases/extensionLambda/lib/lib.kt @@ -1,5 +1,5 @@ package utils inline -public fun apply(x: T, fn: T.()->R): R = +public fun apply(x: T, fn: T.()->R): R = x.fn() diff --git a/js/js.translator/testData/inlineMultiModule/cases/lambda/lib/lib.kt b/js/js.translator/testData/inlineMultiModule/cases/lambda/lib/lib.kt index d06bad389f8..b8d49264199 100644 --- a/js/js.translator/testData/inlineMultiModule/cases/lambda/lib/lib.kt +++ b/js/js.translator/testData/inlineMultiModule/cases/lambda/lib/lib.kt @@ -1,5 +1,5 @@ package utils inline -public fun apply(x: T, fn: (T)->R): R = +public fun apply(x: T, fn: (T)->R): R = fn(x) \ No newline at end of file diff --git a/js/js.translator/testData/inlineMultiModule/cases/lambdaCalledInObjectLiteral/lib/lib.kt b/js/js.translator/testData/inlineMultiModule/cases/lambdaCalledInObjectLiteral/lib/lib.kt index cfcebf3719c..19fedbfaf41 100644 --- a/js/js.translator/testData/inlineMultiModule/cases/lambdaCalledInObjectLiteral/lib/lib.kt +++ b/js/js.translator/testData/inlineMultiModule/cases/lambdaCalledInObjectLiteral/lib/lib.kt @@ -1,7 +1,7 @@ package utils inline -public fun apply(x: T, crossinline fn: (T)->R): R { +public fun apply(x: T, crossinline fn: (T)->R): R { val result = object { val x = fn(x) } diff --git a/js/js.translator/testData/inlineMultiModule/cases/lambdaWithClosure/lib/lib.kt b/js/js.translator/testData/inlineMultiModule/cases/lambdaWithClosure/lib/lib.kt index d06bad389f8..b8d49264199 100644 --- a/js/js.translator/testData/inlineMultiModule/cases/lambdaWithClosure/lib/lib.kt +++ b/js/js.translator/testData/inlineMultiModule/cases/lambdaWithClosure/lib/lib.kt @@ -1,5 +1,5 @@ package utils inline -public fun apply(x: T, fn: (T)->R): R = +public fun apply(x: T, fn: (T)->R): R = fn(x) \ No newline at end of file diff --git a/js/js.translator/testData/inlineMultiModule/cases/localNameClash/lib/lib.kt b/js/js.translator/testData/inlineMultiModule/cases/localNameClash/lib/lib.kt index 943d0d1bac0..778dfb8a0aa 100644 --- a/js/js.translator/testData/inlineMultiModule/cases/localNameClash/lib/lib.kt +++ b/js/js.translator/testData/inlineMultiModule/cases/localNameClash/lib/lib.kt @@ -1,7 +1,7 @@ package utils inline -public fun apply(x: T, fn: (T)->R): R { +public fun apply(x: T, fn: (T)->R): R { val y = fn(x) return y } \ No newline at end of file diff --git a/js/js.translator/testData/inlineSizeReduction/cases/simpleReturnFunction.kt b/js/js.translator/testData/inlineSizeReduction/cases/simpleReturnFunction.kt index 9531e616919..ce7adf0078d 100644 --- a/js/js.translator/testData/inlineSizeReduction/cases/simpleReturnFunction.kt +++ b/js/js.translator/testData/inlineSizeReduction/cases/simpleReturnFunction.kt @@ -6,7 +6,7 @@ package foo // A copy of stdlib run function. // Copied to not to depend on run implementation. // It's important, that the body is just `return fn()`. -internal inline fun evaluate(fn: ()->T): T = fn() +internal inline fun evaluate(fn: ()->T): T = fn() internal fun test(x: Int): Int = evaluate { diff --git a/js/js.translator/testData/multideclaration/cases/multiValForArray.kt b/js/js.translator/testData/multideclaration/cases/multiValForArray.kt index 054c545873c..68c32807daf 100644 --- a/js/js.translator/testData/multideclaration/cases/multiValForArray.kt +++ b/js/js.translator/testData/multideclaration/cases/multiValForArray.kt @@ -1,9 +1,9 @@ package foo class A { - fun component1(): Int = 1 + operator fun component1(): Int = 1 } -fun A.component2(): String = "n" +operator fun A.component2(): String = "n" fun box(): String { val list = Array(1, { A() }) diff --git a/js/js.translator/testData/multideclaration/cases/multiValForMap.kt b/js/js.translator/testData/multideclaration/cases/multiValForMap.kt index e18e5d3f774..f25618ae205 100644 --- a/js/js.translator/testData/multideclaration/cases/multiValForMap.kt +++ b/js/js.translator/testData/multideclaration/cases/multiValForMap.kt @@ -3,18 +3,18 @@ package foo import java.util.HashMap -public fun Map.iterator(): Iterator> { +operator fun Map.iterator(): Iterator> { val entrySet = this.entrySet() return entrySet.iterator() } /** Returns the key of the entry */ -fun Map.Entry.component1(): K { +operator fun Map.Entry.component1(): K { return getKey() } /** Returns the value of the entry */ -fun Map.Entry.component2(): V { +operator fun Map.Entry.component2(): V { return getValue() } diff --git a/js/js.translator/testData/multideclaration/cases/multiValForRange.kt b/js/js.translator/testData/multideclaration/cases/multiValForRange.kt index 1813c2eb8c5..ebf3345ce84 100644 --- a/js/js.translator/testData/multideclaration/cases/multiValForRange.kt +++ b/js/js.translator/testData/multideclaration/cases/multiValForRange.kt @@ -23,9 +23,9 @@ fun ComparableRange.iterator(): Iterator { } open class A { - fun component1(): Int = 1 + operator fun component1(): Int = 1 } -fun A.component2(): String = "n" +operator fun A.component2(): String = "n" fun box(): String { var i = 0; diff --git a/js/js.translator/testData/multideclaration/cases/multiValInFor.kt b/js/js.translator/testData/multideclaration/cases/multiValInFor.kt index e614482aa32..268f7e818cb 100644 --- a/js/js.translator/testData/multideclaration/cases/multiValInFor.kt +++ b/js/js.translator/testData/multideclaration/cases/multiValInFor.kt @@ -3,9 +3,9 @@ package foo import java.util.ArrayList class A { - fun component1(): Int = 1 + operator fun component1(): Int = 1 } -fun A.component2(): String = "n" +operator fun A.component2(): String = "n" fun box(): String { val list = ArrayList() diff --git a/js/js.translator/testData/multideclaration/cases/multiValInIntFor.kt b/js/js.translator/testData/multideclaration/cases/multiValInIntFor.kt index b34903d2a9e..b54e917329f 100644 --- a/js/js.translator/testData/multideclaration/cases/multiValInIntFor.kt +++ b/js/js.translator/testData/multideclaration/cases/multiValInIntFor.kt @@ -1,10 +1,10 @@ package foo -fun Int.component1(): Int { +operator fun Int.component1(): Int { return this + 10; } -fun Int.component2(): String = "b" +operator fun Int.component2(): String = "b" fun box(): String { var i = 0; diff --git a/js/js.translator/testData/multideclaration/cases/multiValInIntRangeFor.kt b/js/js.translator/testData/multideclaration/cases/multiValInIntRangeFor.kt index 0ca4fa5126d..d48c87be9c7 100644 --- a/js/js.translator/testData/multideclaration/cases/multiValInIntRangeFor.kt +++ b/js/js.translator/testData/multideclaration/cases/multiValInIntRangeFor.kt @@ -1,10 +1,10 @@ package foo -fun Int.component1(): Int { +operator fun Int.component1(): Int { return this + 10; } -fun Int.component2(): String = "b" +operator fun Int.component2(): String = "b" fun box(): String { var i = 0; diff --git a/js/js.translator/testData/multideclaration/cases/multiValOrVar.kt b/js/js.translator/testData/multideclaration/cases/multiValOrVar.kt index ff0e77ef75d..ac2381b6b20 100644 --- a/js/js.translator/testData/multideclaration/cases/multiValOrVar.kt +++ b/js/js.translator/testData/multideclaration/cases/multiValOrVar.kt @@ -1,18 +1,18 @@ package foo class A { - fun component1(): Int = 1 + operator fun component1(): Int = 1 } -fun A.component2(): String = "n" +operator fun A.component2(): String = "n" class B { - fun component1(): Int = 1 - fun component2(): Int = 2 - fun component3(): Int = 3 + operator fun component1(): Int = 1 + operator fun component2(): Int = 2 + operator fun component3(): Int = 3 } class C { - fun component1(): Int = 42 + operator fun component1(): Int = 42 } fun box(): String { diff --git a/js/js.translator/testData/native/cases/kt2323.kt b/js/js.translator/testData/native/cases/kt2323.kt index 14568c788e8..e353152ecb2 100644 --- a/js/js.translator/testData/native/cases/kt2323.kt +++ b/js/js.translator/testData/native/cases/kt2323.kt @@ -8,6 +8,6 @@ val classes: Map = noImpl val classesMutable: HashMap = noImpl fun box(): Boolean { - classesMutable["why"] = "?" - return classes["answer"] == 42 && classesMutable["why"] == "?" + classesMutable.set("why", "?") + return classes.get("answer") == 42 && classesMutable.get("why") == "?" } \ No newline at end of file diff --git a/js/js.translator/testData/native/cases/nativeGetterAndNativeSetter.kt b/js/js.translator/testData/native/cases/nativeGetterAndNativeSetter.kt index fb91d262fef..69f7fec6fdb 100644 --- a/js/js.translator/testData/native/cases/nativeGetterAndNativeSetter.kt +++ b/js/js.translator/testData/native/cases/nativeGetterAndNativeSetter.kt @@ -3,10 +3,10 @@ package foo @native("Object") class JsObject { @nativeGetter - fun get(a: String): Any? = noImpl + operator fun get(a: String): Any? = noImpl @nativeSetter - fun set(a: String, v: Any?): Unit = noImpl + operator fun set(a: String, v: Any?): Unit = noImpl @nativeGetter fun take(a: Int): Any? = noImpl @@ -16,10 +16,10 @@ class JsObject { } @nativeGetter -fun JsObject.get(a: Int): Any? = noImpl +operator fun JsObject.get(a: Int): Any? = noImpl @nativeSetter -fun JsObject.set(a: Int, v: Any?): Unit = noImpl +operator fun JsObject.set(a: Int, v: Any?): Unit = noImpl @nativeGetter fun JsObject.take(a: String): Any? = noImpl diff --git a/js/js.translator/testData/native/cases/nativeInvoke.kt b/js/js.translator/testData/native/cases/nativeInvoke.kt index d9bc7c960cc..1943cb076f2 100644 --- a/js/js.translator/testData/native/cases/nativeInvoke.kt +++ b/js/js.translator/testData/native/cases/nativeInvoke.kt @@ -3,14 +3,14 @@ package foo @native class Function(vararg argsAndCode: String) { @nativeInvoke - fun invoke(a: Any?): Any? = noImpl + operator fun invoke(a: Any?): Any? = noImpl @nativeInvoke fun baz(a: Any?, b: Any?): Any? = noImpl } @nativeInvoke -fun Function.invoke(a: Any?, b: Any?): Any? = noImpl +operator fun Function.invoke(a: Any?, b: Any?): Any? = noImpl @nativeInvoke fun Function.bar(a: Any?, b: Any?): Any? = noImpl diff --git a/js/js.translator/testData/number/cases/numberCompareTo.kt b/js/js.translator/testData/number/cases/numberCompareTo.kt index 90110777da7..0bbf48d406c 100644 --- a/js/js.translator/testData/number/cases/numberCompareTo.kt +++ b/js/js.translator/testData/number/cases/numberCompareTo.kt @@ -12,113 +12,113 @@ fun box(): String { assertEquals(-1, 1.compareTo(2)) assertEquals(-1, (1 as Comparable).compareTo(2)) - assertEquals(-1, 1 compareTo 2L) - assertEquals(-1, 1 compareTo 2L) - assertEquals(-1, 1 compareTo 7540113804746346429L) - assertEquals(-1, 1 compareTo 2.toShort()) - assertEquals(-1, 1 compareTo 2.toByte()) - assertEquals(-1, 1 compareTo 2.0) - assertEquals(-1, 1 compareTo 2.0f) + assertEquals(-1, 1.compareTo(2L)) + assertEquals(-1, 1.compareTo(2L)) + assertEquals(-1, 1.compareTo(7540113804746346429L)) + assertEquals(-1, 1.compareTo(2.toShort())) + assertEquals(-1, 1.compareTo(2.toByte())) + assertEquals(-1, 1.compareTo(2.0)) + assertEquals(-1, 1.compareTo(2.0f)) - assertEquals(1, 10 compareTo 2L) - assertEquals(1, 10 compareTo 2) - assertEquals(1, 10 compareTo 2.toShort()) - assertEquals(1, 10 compareTo 2.toByte()) - assertEquals(1, 10 compareTo 2.0) - assertEquals(1, 10 compareTo 2.0f) + assertEquals(1, 10.compareTo(2L)) + assertEquals(1, 10.compareTo(2)) + assertEquals(1, 10.compareTo(2.toShort())) + assertEquals(1, 10.compareTo(2.toByte())) + assertEquals(1, 10.compareTo(2.0)) + assertEquals(1, 10.compareTo(2.0f)) - assertEquals(0, 2 compareTo 2L) - assertEquals(0, 2 compareTo 2) - assertEquals(0, 2 compareTo 2.toShort()) - assertEquals(0, 2 compareTo 2.toByte()) - assertEquals(0, 2 compareTo 2.0) - assertEquals(0, 2 compareTo 2.0f) + assertEquals(0, 2.compareTo(2L)) + assertEquals(0, 2.compareTo(2)) + assertEquals(0, 2.compareTo(2.toShort())) + assertEquals(0, 2.compareTo(2.toByte())) + assertEquals(0, 2.compareTo(2.0)) + assertEquals(0, 2.compareTo(2.0f)) - assertEquals(-1, 1.toShort() compareTo 2L) - assertEquals(-1, 1.toShort() compareTo 7540113804746346429L) - assertEquals(-1, 1.toShort() compareTo 2) - assertEquals(-1, 1.toShort() compareTo 2.toShort()) - assertEquals(-1, (1.toShort() as Comparable) compareTo 2.toShort()) - assertEquals(-1, 1.toShort() compareTo 2.toByte()) - assertEquals(-1, 1.toShort() compareTo 2.0) - assertEquals(-1, 1.toShort() compareTo 2.0f) + assertEquals(-1, 1.toShort().compareTo(2L)) + assertEquals(-1, 1.toShort().compareTo(7540113804746346429L)) + assertEquals(-1, 1.toShort().compareTo(2)) + assertEquals(-1, 1.toShort().compareTo(2.toShort())) + assertEquals(-1, (1.toShort() as Comparable).compareTo(2.toShort())) + assertEquals(-1, 1.toShort().compareTo(2.toByte())) + assertEquals(-1, 1.toShort().compareTo(2.0)) + assertEquals(-1, 1.toShort().compareTo(2.0f)) - assertEquals(1, 10.toByte() compareTo 2L) - assertEquals(-1, 10.toByte() compareTo 7540113804746346429L) - assertEquals(1, 10.toByte() compareTo 2) - assertEquals(1, 10.toByte() compareTo 2.toShort()) - assertEquals(1, 10.toByte() compareTo 2.toByte()) - assertEquals(1, (10.toByte() as Comparable) compareTo 2.toByte()) - assertEquals(1, 10.toByte() compareTo 2.0) - assertEquals(1, 10.toByte() compareTo 2.0f) + assertEquals(1, 10.toByte().compareTo(2L)) + assertEquals(-1, 10.toByte().compareTo(7540113804746346429L)) + assertEquals(1, 10.toByte().compareTo(2)) + assertEquals(1, 10.toByte().compareTo(2.toShort())) + assertEquals(1, 10.toByte().compareTo(2.toByte())) + assertEquals(1, (10.toByte() as Comparable).compareTo(2.toByte())) + assertEquals(1, 10.toByte().compareTo(2.0)) + assertEquals(1, 10.toByte().compareTo(2.0f)) - assertEquals(0, 2.0 compareTo 2L) - assertEquals(-1, 2.0 compareTo 7540113804746346429L) - assertEquals(0, 2.0 compareTo 2) - assertEquals(0, 2.0 compareTo 2.toShort()) - assertEquals(0, 2.0 compareTo 2.toByte()) - assertEquals(0, 2.0 compareTo 2.0) - assertEquals(0, (2.0 as Comparable) compareTo 2.0) - assertEquals(0, 2.0 compareTo 2.0f) + assertEquals(0, 2.0.compareTo(2L)) + assertEquals(-1, 2.0.compareTo(7540113804746346429L)) + assertEquals(0, 2.0.compareTo(2)) + assertEquals(0, 2.0.compareTo(2.toShort())) + assertEquals(0, 2.0.compareTo(2.toByte())) + assertEquals(0, 2.0.compareTo(2.0)) + assertEquals(0, (2.0 as Comparable).compareTo(2.0)) + assertEquals(0, 2.0.compareTo(2.0f)) - assertEquals(1, 3.0f compareTo 2L) - assertEquals(-1, 3.0f compareTo 7540113804746346429L) - assertEquals(1, 3.0f compareTo 2) - assertEquals(1, 3.0f compareTo 2.toShort()) - assertEquals(1, 3.0f compareTo 2.toByte()) - assertEquals(1, 3.0f compareTo 2.0) - assertEquals(1, 3.0f compareTo 2.0f) - assertEquals(1, (3.0f as Comparable) compareTo 2.0f) + assertEquals(1, 3.0f.compareTo(2L)) + assertEquals(-1, 3.0f.compareTo(7540113804746346429L)) + assertEquals(1, 3.0f.compareTo(2)) + assertEquals(1, 3.0f.compareTo(2.toShort())) + assertEquals(1, 3.0f.compareTo(2.toByte())) + assertEquals(1, 3.0f.compareTo(2.0)) + assertEquals(1, 3.0f.compareTo(2.0f)) + assertEquals(1, (3.0f as Comparable).compareTo(2.0f)) - assertEquals(1, 10L compareTo 2L) - assertEquals(-1, 10L compareTo 7540113804746346429L) - assertEquals(1, (10L as Comparable) compareTo 2L) - assertEquals(1, 10L compareTo 2) - assertEquals(1, 10L compareTo 2.toShort()) - assertEquals(1, 10L compareTo 2.toByte()) - assertEquals(1, 10L compareTo 2.0) - assertEquals(1, 10L compareTo 2.0f) + assertEquals(1, 10L.compareTo(2L)) + assertEquals(-1, 10L.compareTo(7540113804746346429L)) + assertEquals(1, (10L as Comparable).compareTo(2L)) + assertEquals(1, 10L.compareTo(2)) + assertEquals(1, 10L.compareTo(2.toShort())) + assertEquals(1, 10L.compareTo(2.toByte())) + assertEquals(1, 10L.compareTo(2.0)) + assertEquals(1, 10L.compareTo(2.0f)) - assertEquals(0, 'A' compareTo 'A') + assertEquals(0, 'A'.compareTo('A')) - assertEquals(-1, 1L compareTo 2L) - assertEquals(-1, 1L compareTo 2) - assertEquals(-1, 1L compareTo 2.toShort()) - assertEquals(-1, 1L compareTo 2.toByte()) - assertEquals(-1, 1L compareTo 2.0) - assertEquals(-1, 1L compareTo 2.0f) + assertEquals(-1, 1L.compareTo(2L)) + assertEquals(-1, 1L.compareTo(2)) + assertEquals(-1, 1L.compareTo(2.toShort())) + assertEquals(-1, 1L.compareTo(2.toByte())) + assertEquals(-1, 1L.compareTo(2.0)) + assertEquals(-1, 1L.compareTo(2.0f)) - assertEquals(0, 7540113804746346429L compareTo 7540113804746346429L) - assertEquals(1, 7540113804746346429L compareTo 2L) - assertEquals(0, 2L compareTo 2L) - assertEquals(0, 2L compareTo 2) - assertEquals(0, 2L compareTo 2.toShort()) - assertEquals(0, 2L compareTo 2.toByte()) - assertEquals(0, 2L compareTo 2.0) - assertEquals(0, 2L compareTo 2.0f) + assertEquals(0, 7540113804746346429L.compareTo(7540113804746346429L)) + assertEquals(1, 7540113804746346429L.compareTo(2L)) + assertEquals(0, 2L.compareTo(2L)) + assertEquals(0, 2L.compareTo(2)) + assertEquals(0, 2L.compareTo(2.toShort())) + assertEquals(0, 2L.compareTo(2.toByte())) + assertEquals(0, 2L.compareTo(2.0)) + assertEquals(0, 2L.compareTo(2.0f)) - assertEquals(1, 10L compareTo 2L) - assertEquals(1, 10L compareTo 2) - assertEquals(1, 10L compareTo 2.toShort()) - assertEquals(1, 10L compareTo 2.toByte()) - assertEquals(1, 10L compareTo 2.0) - assertEquals(1, 10L compareTo 2.0f) + assertEquals(1, 10L.compareTo(2L)) + assertEquals(1, 10L.compareTo(2)) + assertEquals(1, 10L.compareTo(2.toShort())) + assertEquals(1, 10L.compareTo(2.toByte())) + assertEquals(1, 10L.compareTo(2.0)) + assertEquals(1, 10L.compareTo(2.0f)) - assertEquals(-1, 1L compareTo 2L) - assertEquals(-1, 1L compareTo 2) - assertEquals(-1, 1L compareTo 2.toShort()) - assertEquals(-1, 1L compareTo 2.toByte()) - assertEquals(-1, 1L compareTo 2.0) - assertEquals(-1, 1L compareTo 2.0f) + assertEquals(-1, 1L.compareTo(2L)) + assertEquals(-1, 1L.compareTo(2)) + assertEquals(-1, 1L.compareTo(2.toShort())) + assertEquals(-1, 1L.compareTo(2.toByte())) + assertEquals(-1, 1L.compareTo(2.0)) + assertEquals(-1, 1L.compareTo(2.0f)) - assertEquals(0, 2L compareTo 2L) - assertEquals(0, 2L compareTo 2) - assertEquals(0, 2L compareTo 2.toShort()) - assertEquals(0, 2L compareTo 2.toByte()) - assertEquals(0, 2L compareTo 2.0) - assertEquals(0, 2L compareTo 2.0f) + assertEquals(0, 2L.compareTo(2L)) + assertEquals(0, 2L.compareTo(2)) + assertEquals(0, 2L.compareTo(2.toShort())) + assertEquals(0, 2L.compareTo(2.toByte())) + assertEquals(0, 2L.compareTo(2.0)) + assertEquals(0, 2L.compareTo(2.0f)) - assertEquals(1, id("A", 10) compareTo id("B", 5)) + assertEquals(1, id("A", 10).compareTo(id("B", 5))) assertEquals("AB", global) return "OK" diff --git a/js/js.translator/testData/operatorOverloading/cases/binaryDivOverload.kt b/js/js.translator/testData/operatorOverloading/cases/binaryDivOverload.kt index 0e93f2616c6..d9bf109ce50 100644 --- a/js/js.translator/testData/operatorOverloading/cases/binaryDivOverload.kt +++ b/js/js.translator/testData/operatorOverloading/cases/binaryDivOverload.kt @@ -2,7 +2,7 @@ package foo class A() { - fun div(other: A) = "hooray" + operator fun div(other: A) = "hooray" } diff --git a/js/js.translator/testData/operatorOverloading/cases/compareTo.kt b/js/js.translator/testData/operatorOverloading/cases/compareTo.kt index 9bc2bce596d..e353778db6c 100644 --- a/js/js.translator/testData/operatorOverloading/cases/compareTo.kt +++ b/js/js.translator/testData/operatorOverloading/cases/compareTo.kt @@ -3,7 +3,7 @@ package foo class A(t: Int) { var i = t - fun compareTo(other: A) = (this.i - other.i) + operator fun compareTo(other: A) = (this.i - other.i) } fun box(): Boolean { diff --git a/js/js.translator/testData/operatorOverloading/cases/compareToByName.kt b/js/js.translator/testData/operatorOverloading/cases/compareToByName.kt index 37263efa632..fa583af3b1e 100644 --- a/js/js.translator/testData/operatorOverloading/cases/compareToByName.kt +++ b/js/js.translator/testData/operatorOverloading/cases/compareToByName.kt @@ -3,7 +3,7 @@ package foo class A(t: Int) { var i = t - fun compareTo(other: A) = (this.i - other.i) + infix operator fun compareTo(other: A) = (this.i - other.i) } fun box(): Boolean = diff --git a/js/js.translator/testData/operatorOverloading/cases/notOverload.kt b/js/js.translator/testData/operatorOverloading/cases/notOverload.kt index 09a1064a6ed..23ea97dca26 100644 --- a/js/js.translator/testData/operatorOverloading/cases/notOverload.kt +++ b/js/js.translator/testData/operatorOverloading/cases/notOverload.kt @@ -2,7 +2,7 @@ package foo class A() { - fun not() = "hooray" + operator fun not() = "hooray" } diff --git a/js/js.translator/testData/operatorOverloading/cases/operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.kt b/js/js.translator/testData/operatorOverloading/cases/operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.kt index e2472b45cf1..9034fc50c84 100644 --- a/js/js.translator/testData/operatorOverloading/cases/operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.kt +++ b/js/js.translator/testData/operatorOverloading/cases/operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.kt @@ -2,7 +2,7 @@ package foo class MyInt(i: Int) { var b = i - fun inc(): MyInt { + operator fun inc(): MyInt { b = b + 1; return this; } diff --git a/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignArrayList.kt b/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignArrayList.kt index 8cb1eaeb584..e670f8f2d4b 100644 --- a/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignArrayList.kt +++ b/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignArrayList.kt @@ -9,7 +9,7 @@ class ArrayWrapper() { contents.add(item) } - fun plusAssign(rhs: ArrayWrapper) { + operator fun plusAssign(rhs: ArrayWrapper) { contents.addAll(rhs.contents) } diff --git a/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignViaExtensionFunction.kt b/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignViaExtensionFunction.kt index 0ca71493344..4b060a81184 100644 --- a/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignViaExtensionFunction.kt +++ b/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignViaExtensionFunction.kt @@ -8,7 +8,7 @@ class A(val list: MutableList) { } } -fun A.plusAssign(other: Collection) { +operator fun A.plusAssign(other: Collection) { addAll(other) } diff --git a/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignViaPlusExtensionFunction.kt b/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignViaPlusExtensionFunction.kt index 7c7d5f155c2..3e5c8ca2683 100644 --- a/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignViaPlusExtensionFunction.kt +++ b/js/js.translator/testData/operatorOverloading/cases/overloadPlusAssignViaPlusExtensionFunction.kt @@ -3,10 +3,10 @@ package foo open class Foo(open val value: T) open class MutableFoo(override var value: T): Foo(value) -fun Foo.plus(x: T): Foo = Foo(x) +operator fun Foo.plus(x: T): Foo = Foo(x) // overloading: -fun MutableFoo.plus(x: T): MutableFoo = MutableFoo(x) +operator fun MutableFoo.plus(x: T): MutableFoo = MutableFoo(x) fun box(): Boolean { diff --git a/js/js.translator/testData/operatorOverloading/cases/overloadPlusViaExtensionFunction.kt b/js/js.translator/testData/operatorOverloading/cases/overloadPlusViaExtensionFunction.kt index 8062301d277..53d70a312ba 100644 --- a/js/js.translator/testData/operatorOverloading/cases/overloadPlusViaExtensionFunction.kt +++ b/js/js.translator/testData/operatorOverloading/cases/overloadPlusViaExtensionFunction.kt @@ -2,7 +2,7 @@ package foo import java.util.* -fun ArrayList.plus(other: Collection): List { +operator fun ArrayList.plus(other: Collection): List { val c = ArrayList() c.addAll(this) c.addAll(other) diff --git a/js/js.translator/testData/operatorOverloading/cases/overloadUnaryOperationsViaExtensionFunctions.kt b/js/js.translator/testData/operatorOverloading/cases/overloadUnaryOperationsViaExtensionFunctions.kt index 219cd22c5fe..10a71286862 100644 --- a/js/js.translator/testData/operatorOverloading/cases/overloadUnaryOperationsViaExtensionFunctions.kt +++ b/js/js.translator/testData/operatorOverloading/cases/overloadUnaryOperationsViaExtensionFunctions.kt @@ -4,8 +4,8 @@ class A(val c: Int) { } -fun A.inc() = A(5) -fun A.dec() = A(10) +operator fun A.inc() = A(5) +operator fun A.dec() = A(10) fun box(): Boolean { var a = A(1) diff --git a/js/js.translator/testData/operatorOverloading/cases/overloadedCallOnProperty.kt b/js/js.translator/testData/operatorOverloading/cases/overloadedCallOnProperty.kt index 2daccf41a6a..d56d9025e90 100644 --- a/js/js.translator/testData/operatorOverloading/cases/overloadedCallOnProperty.kt +++ b/js/js.translator/testData/operatorOverloading/cases/overloadedCallOnProperty.kt @@ -5,7 +5,7 @@ var a = MyInt() class MyInt() { var b = 0 - fun inc(): MyInt { + operator fun inc(): MyInt { val res = MyInt(); res.b = b; res.b++; diff --git a/js/js.translator/testData/operatorOverloading/cases/plusAndMinusAsAnExpression.kt b/js/js.translator/testData/operatorOverloading/cases/plusAndMinusAsAnExpression.kt index fdd66ad6be3..04980fb0036 100644 --- a/js/js.translator/testData/operatorOverloading/cases/plusAndMinusAsAnExpression.kt +++ b/js/js.translator/testData/operatorOverloading/cases/plusAndMinusAsAnExpression.kt @@ -2,8 +2,8 @@ package foo class A() { - fun plus() = "hooray" - fun minus() = "not really" + operator fun unaryPlus() = "hooray" + operator fun unaryMinus() = "not really" } diff --git a/js/js.translator/testData/operatorOverloading/cases/plusAssignNoReassign.kt b/js/js.translator/testData/operatorOverloading/cases/plusAssignNoReassign.kt index 48c8e9616b4..ec651ca1d2a 100644 --- a/js/js.translator/testData/operatorOverloading/cases/plusAssignNoReassign.kt +++ b/js/js.translator/testData/operatorOverloading/cases/plusAssignNoReassign.kt @@ -3,7 +3,7 @@ package foo class A() { var message = "" - fun plusAssign(other: A) { + operator fun plusAssign(other: A) { message = message + "!" } diff --git a/js/js.translator/testData/operatorOverloading/cases/plusOverload.kt b/js/js.translator/testData/operatorOverloading/cases/plusOverload.kt index bd4396c0a97..47ace977009 100644 --- a/js/js.translator/testData/operatorOverloading/cases/plusOverload.kt +++ b/js/js.translator/testData/operatorOverloading/cases/plusOverload.kt @@ -3,7 +3,7 @@ package foo class myInt(a: Int) { val value = a; - fun plus(other: myInt): myInt = myInt(value + other.value) + operator fun plus(other: myInt): myInt = myInt(value + other.value) } fun box(): Boolean { diff --git a/js/js.translator/testData/operatorOverloading/cases/postfixInc.kt b/js/js.translator/testData/operatorOverloading/cases/postfixInc.kt index d5292dc656f..d1f4a2d38f0 100644 --- a/js/js.translator/testData/operatorOverloading/cases/postfixInc.kt +++ b/js/js.translator/testData/operatorOverloading/cases/postfixInc.kt @@ -3,7 +3,7 @@ package foo class MyInt() { var b = 0 - fun inc(): MyInt { + operator fun inc(): MyInt { val res = MyInt() res.b++; return res; diff --git a/js/js.translator/testData/operatorOverloading/cases/postfixOnProperty.kt b/js/js.translator/testData/operatorOverloading/cases/postfixOnProperty.kt index 3a9c59a065d..08b428a76b0 100644 --- a/js/js.translator/testData/operatorOverloading/cases/postfixOnProperty.kt +++ b/js/js.translator/testData/operatorOverloading/cases/postfixOnProperty.kt @@ -5,7 +5,7 @@ var a = MyInt() class MyInt() { var b = 0 - fun inc(): MyInt { + operator fun inc(): MyInt { b = b + 1; return this; } diff --git a/js/js.translator/testData/operatorOverloading/cases/prefixDecOverload.kt b/js/js.translator/testData/operatorOverloading/cases/prefixDecOverload.kt index 31d22751532..9421e7b5be6 100644 --- a/js/js.translator/testData/operatorOverloading/cases/prefixDecOverload.kt +++ b/js/js.translator/testData/operatorOverloading/cases/prefixDecOverload.kt @@ -3,7 +3,7 @@ package foo class MyInt() { var b = 0 - fun dec(): MyInt { + operator fun dec(): MyInt { val res = MyInt() res.b++; return res; diff --git a/js/js.translator/testData/operatorOverloading/cases/prefixIncReturnsCorrectValue.kt b/js/js.translator/testData/operatorOverloading/cases/prefixIncReturnsCorrectValue.kt index ba9d0bb1538..3db3bc69bae 100644 --- a/js/js.translator/testData/operatorOverloading/cases/prefixIncReturnsCorrectValue.kt +++ b/js/js.translator/testData/operatorOverloading/cases/prefixIncReturnsCorrectValue.kt @@ -3,7 +3,7 @@ package foo class MyInt() { var b = 0 - fun dec(): MyInt { + operator fun dec(): MyInt { b = b + 1; return this; } diff --git a/js/js.translator/testData/operatorOverloading/cases/unaryOnIntProperty.kt b/js/js.translator/testData/operatorOverloading/cases/unaryOnIntProperty.kt index 29f2dfeaca1..7330174351c 100644 --- a/js/js.translator/testData/operatorOverloading/cases/unaryOnIntProperty.kt +++ b/js/js.translator/testData/operatorOverloading/cases/unaryOnIntProperty.kt @@ -2,7 +2,7 @@ package foo class MyInt(i: Int) { var b = i - fun inc(): MyInt { + operator fun inc(): MyInt { b = b++; return this; } diff --git a/js/js.translator/testData/operatorOverloading/cases/unaryOnIntPropertyAsStatement.kt b/js/js.translator/testData/operatorOverloading/cases/unaryOnIntPropertyAsStatement.kt index f5bd9a49de7..92600286c2b 100644 --- a/js/js.translator/testData/operatorOverloading/cases/unaryOnIntPropertyAsStatement.kt +++ b/js/js.translator/testData/operatorOverloading/cases/unaryOnIntPropertyAsStatement.kt @@ -2,7 +2,7 @@ package foo class MyInt(i: Int) { var b = i - fun inc(): MyInt { + operator fun inc(): MyInt { b++; return this; } diff --git a/js/js.translator/testData/operatorOverloading/cases/usingModInCaseModAssignNotAvailable.kt b/js/js.translator/testData/operatorOverloading/cases/usingModInCaseModAssignNotAvailable.kt index b303d6c5986..d5683116bad 100644 --- a/js/js.translator/testData/operatorOverloading/cases/usingModInCaseModAssignNotAvailable.kt +++ b/js/js.translator/testData/operatorOverloading/cases/usingModInCaseModAssignNotAvailable.kt @@ -2,7 +2,7 @@ package foo class A() { var p = "yeah" - fun mod(other: A): A { + operator fun mod(other: A): A { return A(); } } diff --git a/js/js.translator/testData/range/cases/intUpTo.kt b/js/js.translator/testData/range/cases/intUpTo.kt index f051b34c0e1..f5439eb2d05 100644 --- a/js/js.translator/testData/range/cases/intUpTo.kt +++ b/js/js.translator/testData/range/cases/intUpTo.kt @@ -4,7 +4,7 @@ import java.util.ArrayList fun box(): Boolean { var elems = ArrayList() - for (i in 0 rangeTo 5) { + for (i in 0.rangeTo(5)) { elems.add(i) } return elems[0] == 0 && elems[1] == 1 && elems[2] == 2 && elems[3] == 3 && elems[4] == 4 && elems[5] == 5 diff --git a/js/js.translator/testData/range/cases/rangeToDoesNotIterate.kt b/js/js.translator/testData/range/cases/rangeToDoesNotIterate.kt index 0972ea91c7e..f15dad5c27a 100644 --- a/js/js.translator/testData/range/cases/rangeToDoesNotIterate.kt +++ b/js/js.translator/testData/range/cases/rangeToDoesNotIterate.kt @@ -3,7 +3,7 @@ package foo import java.util.ArrayList fun box(): Boolean { - for (i in 0 rangeTo -1) { + for (i in 0.rangeTo(-1)) { return false } return true diff --git a/js/js.translator/testData/reified/_commonFiles/isInstance.kt b/js/js.translator/testData/reified/_commonFiles/isInstance.kt index bbe8a1c81d9..0ea11339dab 100644 --- a/js/js.translator/testData/reified/_commonFiles/isInstance.kt +++ b/js/js.translator/testData/reified/_commonFiles/isInstance.kt @@ -1,4 +1,4 @@ package foo -inline fun isInstance(x: Any): Boolean = +inline fun isInstance(x: Any): Boolean = x is T \ No newline at end of file diff --git a/js/js.translator/testData/safeCall/cases/safeCallAndSideEffect.kt b/js/js.translator/testData/safeCall/cases/safeCallAndSideEffect.kt index d9f81fced00..62d3ecc8550 100644 --- a/js/js.translator/testData/safeCall/cases/safeCallAndSideEffect.kt +++ b/js/js.translator/testData/safeCall/cases/safeCallAndSideEffect.kt @@ -38,7 +38,7 @@ fun A.extFun(): Int { } class B { - fun invoke(): Int { + operator fun invoke(): Int { c5++ return 2 } diff --git a/js/js.translator/testData/webDemoCanvasExamples/cases/Traffic light.kt b/js/js.translator/testData/webDemoCanvasExamples/cases/Traffic light.kt index cf6f4c79e28..48e79bef228 100644 --- a/js/js.translator/testData/webDemoCanvasExamples/cases/Traffic light.kt +++ b/js/js.translator/testData/webDemoCanvasExamples/cases/Traffic light.kt @@ -72,7 +72,7 @@ class Image(val src: String, override var pos: Vector, var imageSize: Vector) : imageSize.x, imageSize.y) } - fun contains(mousePos: Vector): Boolean = mousePos.isInRect(pos, imageSize) + operator fun contains(mousePos: Vector): Boolean = mousePos.isInRect(pos, imageSize) } class Button(val src: String, override var pos: Vector, var imageSize: Vector) : Shape() { @@ -121,7 +121,7 @@ class Button(val src: String, override var pos: Vector, var imageSize: Vector) : } - fun contains(mousePos: Vector): Boolean = mousePos.isInRect(pos, imageSize) + operator fun contains(mousePos: Vector): Boolean = mousePos.isInRect(pos, imageSize) } class Border() : Shape() { @@ -484,9 +484,9 @@ abstract class Shape() { class Vector(val x: Double = 0.0, val y: Double = 0.0) { operator fun plus(v: Vector) = v(x + v.x, y + v.y) - operator fun minus() = v(-x, -y) + operator fun unaryMinus() = v(-x, -y) operator fun minus(v: Vector) = v(x - v.x, y - v.y) - fun times(koef: Double) = v(x * koef, y * koef) + operator fun times(koef: Double) = v(x * koef, y * koef) fun distanceTo(v: Vector) = Math.sqrt((this - v).sqr) fun rotatedBy(theta: Double): Vector { val sin = Math.sin(theta) diff --git a/js/js.translator/testData/webDemoExamples2/cases/life.kt b/js/js.translator/testData/webDemoExamples2/cases/life.kt index eeb66387ccc..3833dbd9487 100644 --- a/js/js.translator/testData/webDemoExamples2/cases/life.kt +++ b/js/js.translator/testData/webDemoExamples2/cases/life.kt @@ -36,7 +36,7 @@ class Field( liveCount(i + 1, j + 1) // You can say field[i, j], and this function gets called - fun get(i: Int, j: Int) = live[i][j] + operator fun get(i: Int, j: Int) = live[i][j] } /** diff --git a/libraries/stdlib/test/MathTest.kt b/libraries/stdlib/test/MathTest.kt index e7428b869cc..36031f567b2 100644 --- a/libraries/stdlib/test/MathTest.kt +++ b/libraries/stdlib/test/MathTest.kt @@ -18,7 +18,7 @@ class MathTest { assertEquals(BigInteger("0"), a / b) assertEquals(BigInteger("-2"), -a) assertEquals(BigInteger("1"), -a % b) - assertEquals(BigInteger("-2"), -a remainder b) + assertEquals(BigInteger("-2"), (-a).remainder(b)) } @test fun testBigDecimal() { diff --git a/libraries/stdlib/test/collections/MapJVMTest.kt b/libraries/stdlib/test/collections/MapJVMTest.kt index a531ec034bd..c0354c9b6e2 100644 --- a/libraries/stdlib/test/collections/MapJVMTest.kt +++ b/libraries/stdlib/test/collections/MapJVMTest.kt @@ -26,7 +26,7 @@ class MapJVMTest { @test fun toSortedMapWithComparator() { val map = mapOf(Pair("c", 3), Pair("bc", 2), Pair("bd", 4), Pair("abc", 1)) - val sorted = map.toSortedMap(compareBy { it.length } thenBy { it }) + val sorted = map.toSortedMap(compareBy { it.length }.thenBy { it }) assertEquals(listOf("c", "bc", "bd", "abc"), sorted.keys.toList()) assertEquals(1, sorted["abc"]) assertEquals(2, sorted["bc"]) diff --git a/libraries/stdlib/test/concurrent/ThreadTest.kt b/libraries/stdlib/test/concurrent/ThreadTest.kt index 1a542f434f3..dfa7d6ce61b 100644 --- a/libraries/stdlib/test/concurrent/ThreadTest.kt +++ b/libraries/stdlib/test/concurrent/ThreadTest.kt @@ -13,7 +13,7 @@ class ThreadTest { val pool = Executors.newFixedThreadPool(1) val countDown = CountDownLatch(1) - pool execute { + pool.execute { countDown.countDown() } assertTrue(countDown.await(2, SECONDS), "Count down is executed") diff --git a/libraries/stdlib/test/numbers/CoercionTest.kt b/libraries/stdlib/test/numbers/CoercionTest.kt index 71c9c7cef28..83c46649cac 100644 --- a/libraries/stdlib/test/numbers/CoercionTest.kt +++ b/libraries/stdlib/test/numbers/CoercionTest.kt @@ -9,12 +9,12 @@ class CoercionTest { fun usage() { val n = 1 // infix usage - val n1 = n coerceAtLeast 2 + val n1 = n.coerceAtLeast(2) // function usage val n2 = n.coerceAtLeast(2) // infix with range - val n3 = n coerceIn 2..5 + val n3 = n.coerceIn(2..5) } @Test @@ -32,8 +32,8 @@ class CoercionTest { expect(value.coerceAtLeast(min)) { value.coerceIn(min, null) } expect(value.coerceAtMost(max)) { value.coerceIn(null, max) } expect(value.coerceAtLeast(min).coerceAtMost(max)) { value.coerceIn(min, max) } - expect(value.coerceAtMost(max).coerceAtLeast(min)) { value coerceIn range } - assertTrue((value coerceIn range) in range) + expect(value.coerceAtMost(max).coerceAtLeast(min)) { value.coerceIn(range) } + assertTrue((value.coerceIn(range)) in range) } assertFails { 1.coerceIn(1, 0) } @@ -55,8 +55,8 @@ class CoercionTest { expect(value.coerceAtLeast(min)) { value.coerceIn(min, null) } expect(value.coerceAtMost(max)) { value.coerceIn(null, max) } expect(value.coerceAtLeast(min).coerceAtMost(max)) { value.coerceIn(min, max) } - expect(value.coerceAtMost(max).coerceAtLeast(min)) { value coerceIn range } - assertTrue((value coerceIn range) in range) + expect(value.coerceAtMost(max).coerceAtLeast(min)) { value.coerceIn(range) } + assertTrue((value.coerceIn(range)) in range) } assertFails { 1L.coerceIn(1L, 0L) } @@ -80,8 +80,8 @@ class CoercionTest { expect(value.coerceAtLeast(min)) { value.coerceIn(min, null) } expect(value.coerceAtMost(max)) { value.coerceIn(null, max) } expect(value.coerceAtLeast(min).coerceAtMost(max)) { value.coerceIn(min, max) } - expect(value.coerceAtMost(max).coerceAtLeast(min)) { value coerceIn range } - assertTrue((value coerceIn range) in range) + expect(value.coerceAtMost(max).coerceAtLeast(min)) { value.coerceIn(range) } + assertTrue((value.coerceIn(range)) in range) } assertFails { 1.0.coerceIn(1.0, 0.0) } @@ -109,8 +109,8 @@ class CoercionTest { expect(value.coerceAtLeast(min)) { value.coerceIn(min, null) } expect(value.coerceAtMost(max)) { value.coerceIn(null, max) } expect(value.coerceAtLeast(min).coerceAtMost(max)) { value.coerceIn(min, max) } - expect(value.coerceAtMost(max).coerceAtLeast(min)) { value coerceIn range } - assertTrue((value coerceIn range) in range) + expect(value.coerceAtMost(max).coerceAtLeast(min)) { value.coerceIn(range) } + assertTrue((value.coerceIn(range)) in range) } assertFails { v[1].coerceIn(v[1], v[0]) } diff --git a/libraries/tools/idl2k/src/main/kotlin/gen.kt b/libraries/tools/idl2k/src/main/kotlin/gen.kt index 648800f4d91..338e7b50efb 100644 --- a/libraries/tools/idl2k/src/main/kotlin/gen.kt +++ b/libraries/tools/idl2k/src/main/kotlin/gen.kt @@ -182,8 +182,19 @@ fun generateUnions(ifaces: List, typedefs: Iterable unionType.memberTypes.filterIsInstance().map { unionMember -> unionMember.type to unionType.name } }.toMultiMap() merge - typedefsToBeGenerated.flatMap { typedef -> typedef.value.memberTypes.filterIsInstance().map { unionMember -> unionMember.type to typedef.name } }.toMultiMap() + val typeNamesToUnions = anonymousUnionTypes + .toList() + .flatMap { unionType -> + unionType.memberTypes + .filterIsInstance() + .map { unionMember -> unionMember.type to unionType.name } + }.toMultiMap() + .merge(typedefsToBeGenerated + .flatMap { typedef -> + typedef.value.memberTypes + .filterIsInstance() + .map { unionMember -> unionMember.type to typedef.name } + }.toMultiMap()) return GenerateUnionTypes( typeNamesToUnionsMap = typeNamesToUnions, diff --git a/libraries/tools/idl2k/src/main/kotlin/main.kt b/libraries/tools/idl2k/src/main/kotlin/main.kt index 153e70f9691..ad23b903c74 100644 --- a/libraries/tools/idl2k/src/main/kotlin/main.kt +++ b/libraries/tools/idl2k/src/main/kotlin/main.kt @@ -19,7 +19,7 @@ fun main(args: Array) { Repository( interfaces = acc.interfaces.mergeReduce(fileRepository.interfaces, ::merge), typeDefs = acc.typeDefs + fileRepository.typeDefs, - externals = acc.externals merge fileRepository.externals, + externals = acc.externals.merge(fileRepository.externals), enums = acc.enums + fileRepository.enums ) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt index c21346c86e7..611d135fe04 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt @@ -148,7 +148,7 @@ class Kotlin2JvmSourceSetProcessor( val aptConfiguration = project.createAptConfiguration(sourceSet.getName(), kotlinAnnotationProcessingDep) - project afterEvaluate { project -> + project.afterEvaluate { project -> if (project != null) { for (dir in sourceSet.getJava().getSrcDirs()) { kotlinDirSet?.srcDir(dir) @@ -318,7 +318,7 @@ open class KotlinAndroidPlugin @Inject constructor(val scriptHandler: ScriptHand project.createKaptExtension() - project afterEvaluate { project -> + project.afterEvaluate { project -> if (project != null) { val plugin = (project.getPlugins().findPlugin("android") ?: project.getPlugins().findPlugin("android-library")) as BasePlugin @@ -405,7 +405,7 @@ open class KotlinAndroidPlugin @Inject constructor(val scriptHandler: ScriptHand subpluginEnvironment.addSubpluginArguments(project, kotlinTask) - kotlinTask doFirst { + kotlinTask.doFirst { val androidRT = project.files(AndroidGradleWrapper.getRuntimeJars(androidPlugin, androidExt)) val fullClasspath = (javaTask.getClasspath() + androidRT) - project.files(kotlinTask.property("kotlinDestinationDir")) (it as AbstractCompile).setClasspath(fullClasspath) @@ -431,7 +431,7 @@ open class KotlinAndroidPlugin @Inject constructor(val scriptHandler: ScriptHand } } - javaTask doFirst { + javaTask.doFirst { javaTask.setClasspath(javaTask.getClasspath() + project.files(kotlinTask.property("kotlinDestinationDir"))) } } @@ -514,7 +514,7 @@ open class GradleUtils(val scriptHandler: ScriptHandler, val project: ProjectInt val dependencyHandler: DependencyHandler = scriptHandler.getDependencies() val configurationsContainer: ConfigurationContainer = scriptHandler.getConfigurations() - val deps = coordinates map { dependencyHandler.create(it) } + val deps = coordinates.map { dependencyHandler.create(it) } val configuration = configurationsContainer.detachedConfiguration(*deps.toTypedArray()) return configuration.getResolvedConfiguration().getFiles { true } diff --git a/libraries/tools/kotlin-js-tests-junit/src/main/kotlin/org/jetbrains/kotlin/js/qunit/SeleniumQUnit.kt b/libraries/tools/kotlin-js-tests-junit/src/main/kotlin/org/jetbrains/kotlin/js/qunit/SeleniumQUnit.kt index 1a38a426079..d34f911d334 100644 --- a/libraries/tools/kotlin-js-tests-junit/src/main/kotlin/org/jetbrains/kotlin/js/qunit/SeleniumQUnit.kt +++ b/libraries/tools/kotlin-js-tests-junit/src/main/kotlin/org/jetbrains/kotlin/js/qunit/SeleniumQUnit.kt @@ -82,7 +82,7 @@ public class SeleniumQUnit(val driver: WebDriver) { } } - private fun WebElement.get(id: String): String? = getAttribute(id) + private operator fun WebElement.get(id: String): String? = getAttribute(id) private val WebElement.classAttribute: String? get() = this["class"] diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-reflection/src/main/kotlin/main/main.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-reflection/src/main/kotlin/main/main.kt index 8173b3d92ac..bcebeb225b4 100644 --- a/libraries/tools/kotlin-maven-plugin-test/src/it/test-reflection/src/main/kotlin/main/main.kt +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-reflection/src/main/kotlin/main/main.kt @@ -33,7 +33,7 @@ fun box(): String { l() val ext = Int::extProp - if (ext.get(42) != 42) return "Fail ext: ${ext[42]}" + if (ext.get(42) != 42) return "Fail ext: ${ext.get(42)}" val a = A::class if (a.memberProperties.size() != 1) return "Fail: ${a.memberProperties}"