From 5d78b0a962e6c9e5d353f77e128b835c275a9341 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Fri, 26 Mar 2021 20:25:01 +0300 Subject: [PATCH] Report resolution ambiguity on '+=' by taking into account full resolution result including post type checking for '+' ^KT-45503 Fixed --- ...irOldFrontendDiagnosticsTestGenerated.java | 24 ++++ .../ExpressionTypingVisitorForStatements.java | 92 +++++++++++----- .../operatorsOverloading/kt45503_1.fir.kt | 15 +++ .../tests/operatorsOverloading/kt45503_1.kt | 15 +++ .../operatorsOverloading/kt45503_2.fir.kt | 15 +++ .../tests/operatorsOverloading/kt45503_2.kt | 15 +++ .../operatorsOverloading/kt45503_3.fir.kt | 17 +++ .../tests/operatorsOverloading/kt45503_3.kt | 17 +++ .../plusAssignOnVarAndCollections.fir.kt | 31 ++++++ .../plusAssignOnVarAndCollections.kt | 31 ++++++ .../plusAssignOnVarAndCollections.txt | 9 ++ .../test/runners/DiagnosticTestGenerated.java | 24 ++++ .../mutableList.kt | 1 - .../mutableMap.kt | 1 - .../mutableSet.kt | 1 - .../changeToVal/arrayList.kt | 7 -- .../changeToVal/arrayList.kt.after | 7 -- .../changeToVal/classVariable.kt | 14 --- .../changeToVal/hashMap.kt | 7 -- .../changeToVal/hashMap.kt.after | 7 -- .../changeToVal/hashSet.kt | 7 -- .../changeToVal/hashSet.kt.after | 7 -- .../changeToVal/mutableList.kt | 7 -- .../changeToVal/mutableList.kt.after | 7 -- .../changeToVal/mutableMap.kt | 7 -- .../changeToVal/mutableMap.kt.after | 7 -- .../changeToVal/mutableSet.kt | 7 -- .../changeToVal/mutableSet.kt.after | 7 -- .../replaceWithAssignCall/arrayList.kt | 7 -- .../replaceWithAssignCall/arrayList.kt.after | 7 -- .../replaceWithAssignCall/hashMap.kt | 7 -- .../replaceWithAssignCall/hashMap.kt.after | 7 -- .../replaceWithAssignCall/hashSet.kt | 7 -- .../replaceWithAssignCall/hashSet.kt.after | 7 -- .../replaceWithAssignCall/mutableList.kt | 7 -- .../mutableList.kt.after | 7 -- .../replaceWithAssignCall/mutableMap.kt | 7 -- .../replaceWithAssignCall/mutableMap.kt.after | 7 -- .../replaceWithAssignCall/mutableSet.kt | 7 -- .../replaceWithAssignCall/mutableSet.kt.after | 7 -- .../QuickFixMultiFileTestGenerated.java | 39 ------- .../idea/quickfix/QuickFixTestGenerated.java | 104 ------------------ 42 files changed, 279 insertions(+), 354 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_1.fir.kt create mode 100644 compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_1.kt create mode 100644 compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_2.fir.kt create mode 100644 compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_2.kt create mode 100644 compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_3.fir.kt create mode 100644 compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_3.kt create mode 100644 compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.fir.kt create mode 100644 compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.kt create mode 100644 compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.txt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt.after delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/classVariable.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt.after delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt.after delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt.after delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt.after delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt.after delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt.after delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt.after delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt.after delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt.after delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt.after delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt delete mode 100644 idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt.after diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index f92870e4fa2..3f77f13bdcf 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -19429,6 +19429,24 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/operatorsOverloading/kt3450.kt"); } + @Test + @TestMetadata("kt45503_1.kt") + public void testKt45503_1() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_1.kt"); + } + + @Test + @TestMetadata("kt45503_2.kt") + public void testKt45503_2() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_2.kt"); + } + + @Test + @TestMetadata("kt45503_3.kt") + public void testKt45503_3() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_3.kt"); + } + @Test @TestMetadata("plusAssignOnArray.kt") public void testPlusAssignOnArray() throws Exception { @@ -19446,6 +19464,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti public void testPlusAssignOnProperty() throws Exception { runTest("compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnProperty.kt"); } + + @Test + @TestMetadata("plusAssignOnVarAndCollections.kt") + public void testPlusAssignOnVarAndCollections() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.kt"); + } } @Nested diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java index ce6e697dac1..2107a5763e4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.types.expressions; +import com.intellij.openapi.util.Ref; import com.intellij.psi.tree.IElementType; import kotlin.Pair; import org.jetbrains.annotations.NotNull; @@ -243,22 +244,23 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito TemporaryTraceAndCache temporaryForBinaryOperation = TemporaryTraceAndCache.create( context, "trace to check binary operation like '+' for", expression); TemporaryBindingTrace ignoreReportsTrace = TemporaryBindingTrace.create(context.trace, "Trace for checking assignability"); + ExpressionTypingContext contextForBinaryOperation = null; + boolean lhsAssignable = basic.checkLValue(ignoreReportsTrace, context, left, right, expression, false); + if (assignmentOperationType == null || lhsAssignable) { + contextForBinaryOperation = context.replaceTraceAndCache(temporaryForBinaryOperation).replaceScope(scope); // Check for '+' // We should clear calls info for coroutine inference within right side as here we analyze it a second time in another context if (context.inferenceSession instanceof BuilderInferenceSession) { ((BuilderInferenceSession) context.inferenceSession).clearCallsInfoByContainingElement(right); } Name counterpartName = OperatorConventions.BINARY_OPERATION_NAMES.get(OperatorConventions.ASSIGNMENT_OPERATION_COUNTERPARTS.get(operationType)); - binaryOperationDescriptors = components.callResolver.resolveBinaryCall( - context.replaceTraceAndCache(temporaryForBinaryOperation).replaceScope(scope), - receiver, expression, counterpartName - ); + binaryOperationDescriptors = + components.callResolver.resolveBinaryCall(contextForBinaryOperation, receiver, expression, counterpartName); binaryOperationType = OverloadResolutionResultsUtil.getResultingType(binaryOperationDescriptors, context); - } - else { + } else { binaryOperationDescriptors = OverloadResolutionResultsImpl.nameNotFound(); binaryOperationType = null; } @@ -270,7 +272,22 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito boolean hasRemBinaryOperation = atLeastOneOperation(binaryOperationDescriptors.getResultingCalls(), OperatorNameConventions.REM); boolean oneTypeOfModRemOperations = hasRemAssignOperation == hasRemBinaryOperation; - if (assignmentOperationDescriptors.isSuccess() && binaryOperationDescriptors.isSuccess() && oneTypeOfModRemOperations) { + + boolean maybeAmbiguity = assignmentOperationDescriptors.isSuccess() && binaryOperationDescriptors.isSuccess() && oneTypeOfModRemOperations; + boolean isResolvedToPlusAssign = assignmentOperationType != null && + (assignmentOperationDescriptors.isSuccess() || !binaryOperationDescriptors.isSuccess()) && + (!hasRemBinaryOperation || !binaryOperationDescriptors.isSuccess()); + + KotlinTypeInfo rhsResolutionResult; + // We complete resolution for 'plus' only if there may be ambiguity (in this case we can disambiguate it), + // or it definitely won't be resolved to plus assign (in this case we would analyse right side twice) + if (maybeAmbiguity || !isResolvedToPlusAssign) { + rhsResolutionResult = completePlusResolution(contextForBinaryOperation, expression, binaryOperationType, left, leftInfo); + } else { + rhsResolutionResult = null; + } + + if (maybeAmbiguity && rhsResolutionResult != null) { // Both 'plus()' and 'plusAssign()' available => ambiguity OverloadResolutionResults ambiguityResolutionResults = OverloadResolutionResultsUtil.ambiguity(assignmentOperationDescriptors, binaryOperationDescriptors); context.trace.report(ASSIGN_OPERATOR_AMBIGUITY.on(operationSign, ambiguityResolutionResults.getResultingCalls())); @@ -278,39 +295,62 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito for (ResolvedCall resolvedCall : ambiguityResolutionResults.getResultingCalls()) { descriptors.add(resolvedCall.getResultingDescriptor()); } - rightInfo = facade.getTypeInfo(right, context.replaceDataFlowInfo(leftInfo.getDataFlowInfo())); + rightInfo = rhsResolutionResult; context.trace.record(AMBIGUOUS_REFERENCE_TARGET, operationSign, descriptors); - } - else if (assignmentOperationType != null && - (assignmentOperationDescriptors.isSuccess() || !binaryOperationDescriptors.isSuccess()) && - (!hasRemBinaryOperation || !binaryOperationDescriptors.isSuccess())) { + } else if (isResolvedToPlusAssign) { // There's 'plusAssign()', so we do a.plusAssign(b) temporaryForAssignmentOperation.commit(); if (!KotlinTypeChecker.DEFAULT.equalTypes(components.builtIns.getUnitType(), assignmentOperationType)) { context.trace.report(ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT.on(operationSign, assignmentOperationDescriptors.getResultingDescriptor(), operationSign)); } - } - else { + } else { + if (rhsResolutionResult != null) { + rightInfo = rhsResolutionResult; + } // There's only 'plus()', so we try 'a = a + b' temporaryForBinaryOperation.commit(); context.trace.record(VARIABLE_REASSIGNMENT, expression); - if (left instanceof KtArrayAccessExpression) { - ExpressionTypingContext contextForResolve = context.replaceScope(scope).replaceBindingTrace(TemporaryBindingTrace.create( - context.trace, "trace to resolve array set method for assignment", expression)); - basic.resolveImplicitArrayAccessSetMethod((KtArrayAccessExpression) left, right, contextForResolve, context.trace); - } - rightInfo = facade.getTypeInfo(right, context.replaceDataFlowInfo(leftInfo.getDataFlowInfo())); - - KotlinType expectedType = refineTypeFromPropertySetterIfPossible(context.trace.getBindingContext(), leftOperand, leftType); - - components.dataFlowAnalyzer.checkType(binaryOperationType, expression, context.replaceExpectedType(expectedType) - .replaceDataFlowInfo(rightInfo.getDataFlowInfo()).replaceCallPosition(new CallPosition.PropertyAssignment(left, false))); - basic.checkLValue(context.trace, context, leftOperand, right, expression, false); } temporary.commit(); return rightInfo.replaceType(checkAssignmentType(type, expression, contextWithExpectedType)); } + private KotlinTypeInfo completePlusResolution( + ExpressionTypingContext context, + KtBinaryExpression expression, + KotlinType binaryOperationType, + KtExpression leftDeparentized, + KotlinTypeInfo leftInfo + ) { + KtExpression leftOperand = expression.getLeft(); + KtExpression rightOperand = expression.getRight(); + + if (leftOperand == null || rightOperand == null) return null; + + if (leftDeparentized instanceof KtArrayAccessExpression) { + ExpressionTypingContext contextForResolve = context.replaceScope(scope).replaceBindingTrace(TemporaryBindingTrace.create( + context.trace, "trace to resolve array set method for assignment", expression)); + basic.resolveImplicitArrayAccessSetMethod((KtArrayAccessExpression) leftDeparentized, rightOperand, contextForResolve, context.trace); + } + KotlinTypeInfo rightInfo = facade.getTypeInfo(rightOperand, context.replaceDataFlowInfo(leftInfo.getDataFlowInfo())); + + KotlinType expectedType = refineTypeFromPropertySetterIfPossible(context.trace.getBindingContext(), leftOperand, leftInfo.getType()); + + Ref hasErrorsOnTypeChecking = Ref.create(false); + components.dataFlowAnalyzer.checkType( + binaryOperationType, + expression, + context.replaceExpectedType(expectedType) + .replaceDataFlowInfo(rightInfo.getDataFlowInfo()) + .replaceCallPosition(new CallPosition.PropertyAssignment(leftDeparentized, false)), + hasErrorsOnTypeChecking, + true + ); + basic.checkLValue(context.trace, context, leftOperand, rightOperand, expression, false); + + return !hasErrorsOnTypeChecking.get() ? rightInfo : null; + } + private static boolean atLeastOneOperation(Collection> calls, Name operationName) { for (ResolvedCall call : calls) { if (call.getCandidateDescriptor().getName().equals(operationName)) { diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_1.fir.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_1.fir.kt new file mode 100644 index 00000000000..598f42586d7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_1.fir.kt @@ -0,0 +1,15 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// WITH_RUNTIME +// SKIP_TXT + +class A +class B(val x: MutableList) : MutableList by x + +class C { + operator fun get(k: A): T = TODO() + operator fun set(k: A, v: T): Unit = TODO() +} + +fun foo() { + C()[A>()] += 2 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_1.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_1.kt new file mode 100644 index 00000000000..598f42586d7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_1.kt @@ -0,0 +1,15 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// WITH_RUNTIME +// SKIP_TXT + +class A +class B(val x: MutableList) : MutableList by x + +class C { + operator fun get(k: A): T = TODO() + operator fun set(k: A, v: T): Unit = TODO() +} + +fun foo() { + C()[A>()] += 2 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_2.fir.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_2.fir.kt new file mode 100644 index 00000000000..079c7fcc754 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_2.fir.kt @@ -0,0 +1,15 @@ +// WITH_RUNTIME +// SKIP_TXT + +class A(var x: T) + +interface I + +class C { + operator fun get(k: A): T = k.x + operator fun set(k: A, v: T) { k.x = v } +} + +fun foo() { + C()[A(mutableListOf(1))] += 2 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_2.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_2.kt new file mode 100644 index 00000000000..079c7fcc754 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_2.kt @@ -0,0 +1,15 @@ +// WITH_RUNTIME +// SKIP_TXT + +class A(var x: T) + +interface I + +class C { + operator fun get(k: A): T = k.x + operator fun set(k: A, v: T) { k.x = v } +} + +fun foo() { + C()[A(mutableListOf(1))] += 2 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_3.fir.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_3.fir.kt new file mode 100644 index 00000000000..eda076143a6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_3.fir.kt @@ -0,0 +1,17 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// WITH_RUNTIME +// SKIP_TXT + +class A +class C +interface I + +class E { + operator fun get(k: A): T = TODO() + operator fun set(k: A, v: T) { TODO() } + operator fun set(k: A, v: C) { TODO() } +} + +fun foo() { + E()[A>()] += 1 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_3.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_3.kt new file mode 100644 index 00000000000..eda076143a6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_3.kt @@ -0,0 +1,17 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// WITH_RUNTIME +// SKIP_TXT + +class A +class C +interface I + +class E { + operator fun get(k: A): T = TODO() + operator fun set(k: A, v: T) { TODO() } + operator fun set(k: A, v: C) { TODO() } +} + +fun foo() { + E()[A>()] += 1 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.fir.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.fir.kt new file mode 100644 index 00000000000..3be6956ba69 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.fir.kt @@ -0,0 +1,31 @@ +// WITH_RUNTIME + +fun test1() { + var list = ArrayList() + list -= 2 +} + +fun test2() { + var set = HashMap() + set += 2 to 2 +} + +fun test3() { + var set = HashSet() + set -= 2 +} + +fun test4() { + var list = mutableListOf(1) + list += 2 +} + +fun test5() { + var map = mutableMapOf(1 to 1) + map += 2 to 2 +} + +fun test6() { + var set = mutableSetOf(1) + set += 2 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.kt new file mode 100644 index 00000000000..5eff7fc7f4e --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.kt @@ -0,0 +1,31 @@ +// WITH_RUNTIME + +fun test1() { + var list = ArrayList() + list -= 2 +} + +fun test2() { + var set = HashMap() + set += 2 to 2 +} + +fun test3() { + var set = HashSet() + set -= 2 +} + +fun test4() { + var list = mutableListOf(1) + list += 2 +} + +fun test5() { + var map = mutableMapOf(1 to 1) + map += 2 to 2 +} + +fun test6() { + var set = mutableSetOf(1) + set += 2 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.txt b/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.txt new file mode 100644 index 00000000000..fbf11856125 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.txt @@ -0,0 +1,9 @@ +package + +public fun test1(): kotlin.Unit +public fun test2(): kotlin.Unit +public fun test3(): kotlin.Unit +public fun test4(): kotlin.Unit +public fun test5(): kotlin.Unit +public fun test6(): kotlin.Unit + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index a40ac9529ee..358114f811c 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -19435,6 +19435,24 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/operatorsOverloading/kt3450.kt"); } + @Test + @TestMetadata("kt45503_1.kt") + public void testKt45503_1() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_1.kt"); + } + + @Test + @TestMetadata("kt45503_2.kt") + public void testKt45503_2() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_2.kt"); + } + + @Test + @TestMetadata("kt45503_3.kt") + public void testKt45503_3() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/kt45503_3.kt"); + } + @Test @TestMetadata("plusAssignOnArray.kt") public void testPlusAssignOnArray() throws Exception { @@ -19452,6 +19470,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { public void testPlusAssignOnProperty() throws Exception { runTest("compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnProperty.kt"); } + + @Test + @TestMetadata("plusAssignOnVarAndCollections.kt") + public void testPlusAssignOnVarAndCollections() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnVarAndCollections.kt"); + } } @Nested diff --git a/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableList.kt b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableList.kt index c2c41cc1e98..398af02b8b6 100644 --- a/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableList.kt +++ b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableList.kt @@ -1,5 +1,4 @@ // PROBLEM: none -// ERROR: Assignment operators ambiguity:
public operator fun Collection.plus(element: Int): List defined in kotlin.collections
public inline operator fun MutableCollection.plusAssign(element: Int): Unit defined in kotlin.collections // WITH_RUNTIME fun test() { var list = mutableListOf(1) diff --git a/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableMap.kt b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableMap.kt index 4d06e9ad979..ebd2d3db091 100644 --- a/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableMap.kt +++ b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableMap.kt @@ -1,5 +1,4 @@ // PROBLEM: none -// ERROR: Assignment operators ambiguity:
public operator fun Map.plus(pair: Pair): Map defined in kotlin.collections
public inline operator fun MutableMap.plusAssign(pair: Pair): Unit defined in kotlin.collections // WITH_RUNTIME fun test() { var map = mutableMapOf(1 to 2) diff --git a/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableSet.kt b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableSet.kt index 9736296ca45..58dfcaab366 100644 --- a/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableSet.kt +++ b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/mutableSet.kt @@ -1,5 +1,4 @@ // PROBLEM: none -// ERROR: Assignment operators ambiguity:
public operator fun Set.plus(element: Int): Set defined in kotlin.collections
public inline operator fun MutableCollection.plusAssign(element: Int): Unit defined in kotlin.collections // WITH_RUNTIME fun test() { var set = mutableSetOf(1) diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt deleted file mode 100644 index c900e2a5832..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'list' to val" "true" -// WITH_RUNTIME - -fun test() { - var list = ArrayList() - list -= 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt.after deleted file mode 100644 index 39847df38f3..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'list' to val" "true" -// WITH_RUNTIME - -fun test() { - val list = ArrayList() - list -= 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/classVariable.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/classVariable.kt deleted file mode 100644 index 8d4fbff5b16..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/classVariable.kt +++ /dev/null @@ -1,14 +0,0 @@ -// "Change 'list' to val" "false" -// ACTION: Replace overloaded operator with function call -// ACTION: Replace with 'plusAssign()' call -// ACTION: Replace with ordinary assignment -// ERROR: Assignment operators ambiguity:
public operator fun Collection.plus(element: Int): List defined in kotlin.collections
public inline operator fun MutableCollection.plusAssign(element: Int): Unit defined in kotlin.collections -// WITH_RUNTIME - -class Test { - var list = mutableListOf(1) - - fun test() { - list += 2 - } -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt deleted file mode 100644 index 6612a6a9668..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'set' to val" "true" -// WITH_RUNTIME - -fun test() { - var set = HashMap() - set += 2 to 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt.after deleted file mode 100644 index a06e0582ccf..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'set' to val" "true" -// WITH_RUNTIME - -fun test() { - val set = HashMap() - set += 2 to 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt deleted file mode 100644 index bf1d53e7977..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'set' to val" "true" -// WITH_RUNTIME - -fun test() { - var set = HashSet() - set -= 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt.after deleted file mode 100644 index ce9f2687a03..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'set' to val" "true" -// WITH_RUNTIME - -fun test() { - val set = HashSet() - set -= 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt deleted file mode 100644 index 283c8c7ac84..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'list' to val" "true" -// WITH_RUNTIME - -fun test() { - var list = mutableListOf(1) - list += 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt.after deleted file mode 100644 index cb011859d16..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'list' to val" "true" -// WITH_RUNTIME - -fun test() { - val list = mutableListOf(1) - list += 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt deleted file mode 100644 index 32791b97092..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'map' to val" "true" -// WITH_RUNTIME - -fun test() { - var map = mutableMapOf(1 to 1) - map += 2 to 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt.after deleted file mode 100644 index 1c914036f5f..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'map' to val" "true" -// WITH_RUNTIME - -fun test() { - val map = mutableMapOf(1 to 1) - map += 2 to 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt deleted file mode 100644 index 31f037b82a2..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'set' to val" "true" -// WITH_RUNTIME - -fun test() { - var set = mutableSetOf(1) - set += 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt.after deleted file mode 100644 index 84c720a8006..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Change 'set' to val" "true" -// WITH_RUNTIME - -fun test() { - val set = mutableSetOf(1) - set += 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt deleted file mode 100644 index a9de5690e1c..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'minusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var list = ArrayList() - list -= 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt.after deleted file mode 100644 index b16b2d15a36..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'minusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var list = ArrayList() - list.minusAssign(2) -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt deleted file mode 100644 index 5d1b92dd6a0..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'plusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var set = HashMap() - set += 2 to 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt.after deleted file mode 100644 index adb873157d5..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'plusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var set = HashMap() - set.plusAssign(2 to 2) -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt deleted file mode 100644 index 46b4fff36df..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'minusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var set = HashSet() - set -= 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt.after deleted file mode 100644 index 81c6bd046cb..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'minusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var set = HashSet() - set.minusAssign(2) -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt deleted file mode 100644 index fe454153c94..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'plusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var list = mutableListOf(1) - list += 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt.after deleted file mode 100644 index ed092503640..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'plusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var list = mutableListOf(1) - list.plusAssign(2) -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt deleted file mode 100644 index 42db4a6e15a..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'plusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var map = mutableMapOf(1 to 1) - map += 2 to 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt.after deleted file mode 100644 index 8cf53f69210..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'plusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var map = mutableMapOf(1 to 1) - map.plusAssign(2 to 2) -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt deleted file mode 100644 index e12e96d3ba4..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'plusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var set = mutableSetOf(1) - set += 2 -} \ No newline at end of file diff --git a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt.after b/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt.after deleted file mode 100644 index 6191d03a02c..00000000000 --- a/idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with 'plusAssign()' call" "true" -// WITH_RUNTIME - -fun test() { - var set = mutableSetOf(1) - set.plusAssign(2) -} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java index 6cdc220de86..7788b38ae3d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java @@ -496,45 +496,6 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes } } - @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class AssignOperatorAmbiguity extends AbstractQuickFixMultiFileTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTestWithExtraFile, this, testDataFilePath); - } - - public void testAllFilesPresentInAssignOperatorAmbiguity() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), null, true); - } - - @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ChangeToVal extends AbstractQuickFixMultiFileTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTestWithExtraFile, this, testDataFilePath); - } - - public void testAllFilesPresentInChangeToVal() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), null, true); - } - } - - @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ReplaceWithAssignCall extends AbstractQuickFixMultiFileTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTestWithExtraFile, this, testDataFilePath); - } - - public void testAllFilesPresentInReplaceWithAssignCall() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), null, true); - } - } - } - @TestMetadata("idea/testData/quickfix/assignToProperty") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 8455ad864ed..387f2af94cb 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -1761,110 +1761,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { } } - @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class AssignOperatorAmbiguity extends AbstractQuickFixTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInAssignOperatorAmbiguity() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true); - } - - @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ChangeToVal extends AbstractQuickFixTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInChangeToVal() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true); - } - - @TestMetadata("arrayList.kt") - public void testArrayList() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/arrayList.kt"); - } - - @TestMetadata("classVariable.kt") - public void testClassVariable() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/classVariable.kt"); - } - - @TestMetadata("hashMap.kt") - public void testHashMap() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashMap.kt"); - } - - @TestMetadata("hashSet.kt") - public void testHashSet() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/hashSet.kt"); - } - - @TestMetadata("mutableList.kt") - public void testMutableList() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableList.kt"); - } - - @TestMetadata("mutableMap.kt") - public void testMutableMap() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableMap.kt"); - } - - @TestMetadata("mutableSet.kt") - public void testMutableSet() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/changeToVal/mutableSet.kt"); - } - } - - @TestMetadata("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ReplaceWithAssignCall extends AbstractQuickFixTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInReplaceWithAssignCall() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true); - } - - @TestMetadata("arrayList.kt") - public void testArrayList() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/arrayList.kt"); - } - - @TestMetadata("hashMap.kt") - public void testHashMap() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashMap.kt"); - } - - @TestMetadata("hashSet.kt") - public void testHashSet() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/hashSet.kt"); - } - - @TestMetadata("mutableList.kt") - public void testMutableList() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableList.kt"); - } - - @TestMetadata("mutableMap.kt") - public void testMutableMap() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableMap.kt"); - } - - @TestMetadata("mutableSet.kt") - public void testMutableSet() throws Exception { - runTest("idea/testData/quickfix/assignOperatorAmbiguity/replaceWithAssignCall/mutableSet.kt"); - } - } - } - @TestMetadata("idea/testData/quickfix/assignToProperty") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)