From e54d2c7c32fd5b12a39c392cbc1d8ca40598481e Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 30 Aug 2019 12:27:53 +0300 Subject: [PATCH] Support named arguments in their own position ^KT-7745 In Proggress --- .../fir/FirDiagnosticsSmokeTestGenerated.java | 38 +++++++++++++ .../components/ArgumentsToParametersMapper.kt | 35 ++++++++---- .../box/mixedNamedPosition/defaults.kt | 23 ++++++++ .../codegen/box/mixedNamedPosition/simple.kt | 15 +++++ .../codegen/box/mixedNamedPosition/varargs.kt | 31 ++++++++++ .../mixedNamedPosition/defaults.kt | 28 +++++++++ .../mixedNamedPosition/disabledFeature.kt | 20 +++++++ .../mixedNamedPosition/oldInference.kt | 20 +++++++ .../mixedNamedPosition/simple.kt | 20 +++++++ .../mixedNamedPosition/varargs.kt | 57 +++++++++++++++++++ .../checkers/DiagnosticsTestGenerated.java | 38 +++++++++++++ .../DiagnosticsUsingJavacTestGenerated.java | 38 +++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 28 +++++++++ .../LightAnalysisModeTestGenerated.java | 28 +++++++++ .../ir/IrBlackBoxCodegenTestGenerated.java | 28 +++++++++ .../kotlin/config/LanguageVersionSettings.kt | 1 + .../IrJsCodegenBoxTestGenerated.java | 28 +++++++++ .../semantics/JsCodegenBoxTestGenerated.java | 28 +++++++++ 18 files changed, 494 insertions(+), 10 deletions(-) create mode 100644 compiler/testData/codegen/box/mixedNamedPosition/defaults.kt create mode 100644 compiler/testData/codegen/box/mixedNamedPosition/simple.kt create mode 100644 compiler/testData/codegen/box/mixedNamedPosition/varargs.kt create mode 100644 compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/defaults.kt create mode 100644 compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/disabledFeature.kt create mode 100644 compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/oldInference.kt create mode 100644 compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/simple.kt create mode 100644 compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/varargs.kt diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java index 5aa753a86d3..3bf4508ebc4 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java @@ -14143,6 +14143,44 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok public void testNamedArgumentsInOverrides() throws Exception { runTest("compiler/testData/diagnostics/tests/namedArguments/namedArgumentsInOverrides.kt"); } + + @TestMetadata("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MixedNamedPosition extends AbstractFirDiagnosticsSmokeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInMixedNamedPosition() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("defaults.kt") + public void testDefaults() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/defaults.kt"); + } + + @TestMetadata("disabledFeature.kt") + public void testDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/disabledFeature.kt"); + } + + @TestMetadata("oldInference.kt") + public void testOldInference() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/oldInference.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/simple.kt"); + } + + @TestMetadata("varargs.kt") + public void testVarargs() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/varargs.kt"); + } + } } @TestMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts") diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ArgumentsToParametersMapper.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ArgumentsToParametersMapper.kt index d065ead6099..3786ee94f23 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ArgumentsToParametersMapper.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ArgumentsToParametersMapper.kt @@ -16,6 +16,8 @@ package org.jetbrains.kotlin.resolve.calls.components +import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor @@ -23,7 +25,12 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.model.* import java.util.* -class ArgumentsToParametersMapper { +class ArgumentsToParametersMapper( + languageVersionSettings: LanguageVersionSettings +) { + + private val allowMixedNamedAndPositionArguments = + languageVersionSettings.supportsFeature(LanguageFeature.MixedNamedArgumentsInTheirOwnPosition) data class ArgumentMapping( // This map should be ordered by arguments as written, e.g.: @@ -48,7 +55,7 @@ class ArgumentsToParametersMapper { if (argumentsInParenthesis.isEmpty() && externalArgument == null && descriptor.valueParameters.isEmpty()) { return EmptyArgumentMapping } else { - val processor = CallArgumentProcessor(descriptor) + val processor = CallArgumentProcessor(descriptor, allowMixedNamedAndPositionArguments) processor.processArgumentsInParenthesis(argumentsInParenthesis) if (externalArgument != null) { @@ -60,7 +67,10 @@ class ArgumentsToParametersMapper { } } - private class CallArgumentProcessor(val descriptor: CallableDescriptor) { + private class CallArgumentProcessor( + val descriptor: CallableDescriptor, + val allowMixedNamedAndPositionArguments: Boolean + ) { val result: MutableMap = LinkedHashMap() private var state = State.POSITION_ARGUMENTS @@ -70,7 +80,7 @@ class ArgumentsToParametersMapper { private var nameToParameter: Map? = null private var varargArguments: MutableList? = null - private var currentParameterIndex = 0 + private var currentPositionedParameterIndex = 0 private fun addDiagnostic(diagnostic: KotlinCallDiagnostic) { if (diagnostics == null) { @@ -98,30 +108,30 @@ class ArgumentsToParametersMapper { private enum class State { POSITION_ARGUMENTS, VARARG_POSITION, - NAMED_ARGUMENT + NAMED_ONLY_ARGUMENTS } private fun completeVarargPositionArguments() { assert(state == State.VARARG_POSITION) { "Incorrect state: $state" } - val parameter = parameters[currentParameterIndex] + val parameter = parameters[currentPositionedParameterIndex] result.put(parameter.original, ResolvedCallArgument.VarargArgument(varargArguments!!)) } // return true, if it was mapped to vararg parameter private fun processPositionArgument(argument: KotlinCallArgument): Boolean { - if (state == State.NAMED_ARGUMENT) { + if (state == State.NAMED_ONLY_ARGUMENTS) { addDiagnostic(MixingNamedAndPositionArguments(argument)) return false } - val parameter = parameters.getOrNull(currentParameterIndex) + val parameter = parameters.getOrNull(currentPositionedParameterIndex) if (parameter == null) { addDiagnostic(TooManyArguments(argument, descriptor)) return false } if (!parameter.isVararg) { - currentParameterIndex++ + currentPositionedParameterIndex++ result.put(parameter.original, ResolvedCallArgument.SimpleArgument(argument)) return false @@ -148,6 +158,11 @@ class ArgumentsToParametersMapper { } result[parameter.original] = ResolvedCallArgument.SimpleArgument(argument) + + if (allowMixedNamedAndPositionArguments && parameters.getOrNull(currentPositionedParameterIndex)?.original == parameter.original) { + state = State.POSITION_ARGUMENTS + currentPositionedParameterIndex++ + } } private fun ValueParameterDescriptor.getOverriddenParameterWithOtherName() = overriddenDescriptors.firstOrNull { @@ -197,7 +212,7 @@ class ArgumentsToParametersMapper { if (state == State.VARARG_POSITION) { completeVarargPositionArguments() } - state = State.NAMED_ARGUMENT + state = State.NAMED_ONLY_ARGUMENTS processNamedArgument(argument, argumentName) } diff --git a/compiler/testData/codegen/box/mixedNamedPosition/defaults.kt b/compiler/testData/codegen/box/mixedNamedPosition/defaults.kt new file mode 100644 index 00000000000..2e9f155f135 --- /dev/null +++ b/compiler/testData/codegen/box/mixedNamedPosition/defaults.kt @@ -0,0 +1,23 @@ +// !LANGUAGE: +NewInference +MixedNamedArgumentsInTheirOwnPosition + +fun foo( + p1: Int = 1, + p2: String = "2", + p3: Double = 3.0, + p4: Char = '4' +) = "$p1 $p2 ${p3.toInt()} $p4" + +fun box(): String { + if (foo(p1 = 1, "2", 3.0) != "1 2 3 4") return "fail 1" + if (foo(1, p2 = "2", 3.0) != "1 2 3 4") return "fail 2" + if (foo(1, "2", p3 = 3.0) != "1 2 3 4") return "fail 3" + + if (foo(p1 = 1) != "1 2 3 4") return "fail 4" + if (foo(1, p2 = "2") != "1 2 3 4") return "fail 5" + + if (foo(p1 = 1, p2 = "2", 3.0) != "1 2 3 4") return "fail 6" + + if (foo(1, p2 = "2") != "1 2 3 4") return "fail 7" + + return "OK" +} diff --git a/compiler/testData/codegen/box/mixedNamedPosition/simple.kt b/compiler/testData/codegen/box/mixedNamedPosition/simple.kt new file mode 100644 index 00000000000..d036eb4c1cc --- /dev/null +++ b/compiler/testData/codegen/box/mixedNamedPosition/simple.kt @@ -0,0 +1,15 @@ +// !LANGUAGE: +NewInference +MixedNamedArgumentsInTheirOwnPosition + +fun foo( + p1: Int, + p2: String, + p3: Double +) = "$p1 $p2 ${p3.toInt()}" + +fun box(): String { + if (foo(p1 = 1, "2", 3.0) != "1 2 3") return "fail 1" + if (foo(1, "2", p3 = 3.0) != "1 2 3") return "fail 2" + if (foo(p1 = 1, p2 = "2", 3.0) != "1 2 3") return "fail 3" + + return "OK" +} diff --git a/compiler/testData/codegen/box/mixedNamedPosition/varargs.kt b/compiler/testData/codegen/box/mixedNamedPosition/varargs.kt new file mode 100644 index 00000000000..b2f5196341d --- /dev/null +++ b/compiler/testData/codegen/box/mixedNamedPosition/varargs.kt @@ -0,0 +1,31 @@ +// !LANGUAGE: +NewInference +MixedNamedArgumentsInTheirOwnPosition + +fun foo1( + vararg p1: Int, + p2: String, + p3: Double +) = "${p1[0]} ${p1[1]} $p2 ${p3.toInt()}" + +fun foo2( + p1: Int, + vararg p2: String, + p3: Double +) = "$p1 ${p2[0]} ${p2[1]} ${p3.toInt()}" + +fun foo3( + p1: Int, + p2: String, + vararg p3: Double +) = "$p1 $p2 ${p3[0].toInt()} ${p3[1].toInt()}" + +fun box(): String { + if (foo1(p1 = *intArrayOf(1, 2), "3", p3 = 4.0) != "1 2 3 4") return "fail 2" + + if (foo2(p1 = 1, "2", "3", p3 = 4.0) != "1 2 3 4") return "fail 3" + if (foo2(1, p2 = *arrayOf("2", "3"), 4.0) != "1 2 3 4") return "fail 4" + + if (foo3(p1 = 1, "2", 3.0, 4.0) != "1 2 3 4") return "fail 5" + if (foo3(p1 = 1, "2", p3 = *doubleArrayOf(3.0, 4.0)) != "1 2 3 4") return "fail 6" + + return "OK" +} diff --git a/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/defaults.kt b/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/defaults.kt new file mode 100644 index 00000000000..944f8b744c2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/defaults.kt @@ -0,0 +1,28 @@ +// !LANGUAGE: +NewInference +MixedNamedArgumentsInTheirOwnPosition +// !DIAGNOSTICS: -UNUSED_PARAMETER +// SKIP_TXT + +fun foo( + p1: Int = 1, + p2: String = "", + p3: Double = 3.0, + p4: Char = '4' +) {} + +fun main() { + foo(p1 = 1, "2", 3.0) + foo(1, p2 = "2", 3.0) + foo(1, "2", p3 = 3.0) + + foo(p1 = 1) + foo(1, p2 = "2") + + foo(p1 = 1, p2 = "2", 3.0) + + foo() + foo(1, p2 = "") + foo(p3 = 4.0, '4') + + foo(1, p3 = 2.0, "") + foo(1, p3 = 2.0, 3.0) +} diff --git a/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/disabledFeature.kt b/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/disabledFeature.kt new file mode 100644 index 00000000000..2b1f273441e --- /dev/null +++ b/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/disabledFeature.kt @@ -0,0 +1,20 @@ +// !LANGUAGE: +NewInference -MixedNamedArgumentsInTheirOwnPosition +// !DIAGNOSTICS: -UNUSED_PARAMETER +// SKIP_TXT + +fun foo( + p1: Int, + p2: String, + p3: Double +) {} + +fun main() { + foo(p1 = 1, "2", 3.0) + foo(1, p2 = "2", 3.0) + foo(1, "2", p3 = 3.0) + + foo(p1 = 1, p2 = "2", 3.0) + + foo(1, p3 = 2.0, "") + foo(1, p3 = 2.0, 3.0) +} diff --git a/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/oldInference.kt b/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/oldInference.kt new file mode 100644 index 00000000000..b95d36b0942 --- /dev/null +++ b/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/oldInference.kt @@ -0,0 +1,20 @@ +// !LANGUAGE: -NewInference +MixedNamedArgumentsInTheirOwnPosition +// !DIAGNOSTICS: -UNUSED_PARAMETER +// SKIP_TXT + +fun foo( + p1: Int, + p2: String, + p3: Double +) {} + +fun main() { + foo(p1 = 1, "2", 3.0) + foo(1, p2 = "2", 3.0) + foo(1, "2", p3 = 3.0) + + foo(p1 = 1, p2 = "2", 3.0) + + foo(1, p3 = 2.0, "") + foo(1, p3 = 2.0, 3.0) +} diff --git a/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/simple.kt b/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/simple.kt new file mode 100644 index 00000000000..f54b81f774c --- /dev/null +++ b/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/simple.kt @@ -0,0 +1,20 @@ +// !LANGUAGE: +NewInference +MixedNamedArgumentsInTheirOwnPosition +// !DIAGNOSTICS: -UNUSED_PARAMETER +// SKIP_TXT + +fun foo( + p1: Int, + p2: String, + p3: Double +) {} + +fun main() { + foo(p1 = 1, "2", 3.0) + foo(1, p2 = "2", 3.0) + foo(1, "2", p3 = 3.0) + + foo(p1 = 1, p2 = "2", 3.0) + + foo(1, p3 = 2.0, "") + foo(1, p3 = 2.0, 3.0) +} diff --git a/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/varargs.kt b/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/varargs.kt new file mode 100644 index 00000000000..801f1e1eae3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/varargs.kt @@ -0,0 +1,57 @@ +// !LANGUAGE: +NewInference +MixedNamedArgumentsInTheirOwnPosition +// !DIAGNOSTICS: -UNUSED_PARAMETER +// SKIP_TXT + +fun foo1( + vararg p1: Int, + p2: String, + p3: Double +) {} + +fun foo2( + p1: Int, + vararg p2: String, + p3: Double +) {} + +fun foo3( + p1: Int, + p2: String, + vararg p3: Double +) {} + +fun foo4( + p1: Int, + vararg p2: String, + p3: Double, + p4: Int +) {} + +fun main() { + foo1(1, 2, p2 = "3", 4.0) + foo1(p1 = *intArrayOf(1, 2), "3", p3 = 4.0) + + foo1(p2 = "3", 4.0) + + foo2(p1 = 1, "2", "3", p3 = 4.0) + foo2(1, p2 = *arrayOf("2", "3"), 4.0) + foo2(1, p3 = 3.0) + + foo3(p1 = 1, "2", 3.0, 4.0) + foo3(p1 = 1, "2", p3 = *doubleArrayOf(3.0, 4.0)) + + foo4(p1 = 1, "2", "3", p3 = 4.0, 5) + foo4(1, "2", "3", p3 = 4.0, 5) + foo4(1, p3 = 4.0, 5) + + foo1(1, 2, p3 = 3.0, "4") + foo1(1, 2, p3 = 3.0, p2 = "4") + foo1(*intArrayOf(1, 2), p3 = 3.0, p2 = "4") + + foo2(1, p3 = 2.0, "4") + foo2(1, p3 = 2.0, *arrayOf("3", "4")) + foo2(1, p3 = 2.0, p2 = *arrayOf("3", "4")) + + foo3(1, p3 = *doubleArrayOf(2.0, 3.0), "4") + foo3(1, p3 = *doubleArrayOf(2.0, 3.0), p2 = "4") +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index c131f6088ea..a86edf4a008 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -14150,6 +14150,44 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { public void testNamedArgumentsInOverrides() throws Exception { runTest("compiler/testData/diagnostics/tests/namedArguments/namedArgumentsInOverrides.kt"); } + + @TestMetadata("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MixedNamedPosition extends AbstractDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInMixedNamedPosition() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition"), Pattern.compile("^(.*)\\.kts?$"), TargetBackend.ANY, true); + } + + @TestMetadata("defaults.kt") + public void testDefaults() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/defaults.kt"); + } + + @TestMetadata("disabledFeature.kt") + public void testDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/disabledFeature.kt"); + } + + @TestMetadata("oldInference.kt") + public void testOldInference() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/oldInference.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/simple.kt"); + } + + @TestMetadata("varargs.kt") + public void testVarargs() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/varargs.kt"); + } + } } @TestMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts") diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 458f5bdda73..4cdc35250f3 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -14145,6 +14145,44 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing public void testNamedArgumentsInOverrides() throws Exception { runTest("compiler/testData/diagnostics/tests/namedArguments/namedArgumentsInOverrides.kt"); } + + @TestMetadata("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MixedNamedPosition extends AbstractDiagnosticsUsingJavacTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInMixedNamedPosition() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("defaults.kt") + public void testDefaults() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/defaults.kt"); + } + + @TestMetadata("disabledFeature.kt") + public void testDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/disabledFeature.kt"); + } + + @TestMetadata("oldInference.kt") + public void testOldInference() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/oldInference.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/simple.kt"); + } + + @TestMetadata("varargs.kt") + public void testVarargs() throws Exception { + runTest("compiler/testData/diagnostics/tests/namedArguments/mixedNamedPosition/varargs.kt"); + } + } } @TestMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index c10ff3b4cd7..5c521576b25 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -15761,6 +15761,34 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @TestMetadata("compiler/testData/codegen/box/mixedNamedPosition") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MixedNamedPosition extends AbstractBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInMixedNamedPosition() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/mixedNamedPosition"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("defaults.kt") + public void testDefaults() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/defaults.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/simple.kt"); + } + + @TestMetadata("varargs.kt") + public void testVarargs() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/varargs.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/multiDecl") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 54f4a875268..931a913d92e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -15761,6 +15761,34 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/mixedNamedPosition") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MixedNamedPosition extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInMixedNamedPosition() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/mixedNamedPosition"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("defaults.kt") + public void testDefaults() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/defaults.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/simple.kt"); + } + + @TestMetadata("varargs.kt") + public void testVarargs() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/varargs.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/multiDecl") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index e34507c61c1..a232b96ead2 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -14646,6 +14646,34 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @TestMetadata("compiler/testData/codegen/box/mixedNamedPosition") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MixedNamedPosition extends AbstractIrBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInMixedNamedPosition() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/mixedNamedPosition"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); + } + + @TestMetadata("defaults.kt") + public void testDefaults() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/defaults.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/simple.kt"); + } + + @TestMetadata("varargs.kt") + public void testVarargs() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/varargs.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/multiDecl") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 05a2cc80589..bc807c585d8 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -107,6 +107,7 @@ enum class LanguageFeature( NonParenthesizedAnnotationsOnFunctionalTypes(KOTLIN_1_4), UseGetterNameForPropertyAnnotationsMethodOnJvm(KOTLIN_1_4), AllowBreakAndContinueInsideWhen(KOTLIN_1_4), + MixedNamedArgumentsInTheirOwnPosition(KOTLIN_1_4), ProperVisibilityForCompanionObjectInstanceField(sinceVersion = null, kind = BUG_FIX), // Temporarily disabled, see KT-27084/KT-22379 diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 32eb58d4b71..1d13dab1935 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -11951,6 +11951,34 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/mixedNamedPosition") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MixedNamedPosition extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInMixedNamedPosition() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/mixedNamedPosition"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); + } + + @TestMetadata("defaults.kt") + public void testDefaults() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/defaults.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/simple.kt"); + } + + @TestMetadata("varargs.kt") + public void testVarargs() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/varargs.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/multiDecl") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index daf8b745248..1bef4b8218c 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -13106,6 +13106,34 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/mixedNamedPosition") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MixedNamedPosition extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInMixedNamedPosition() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/mixedNamedPosition"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); + } + + @TestMetadata("defaults.kt") + public void testDefaults() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/defaults.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/simple.kt"); + } + + @TestMetadata("varargs.kt") + public void testVarargs() throws Exception { + runTest("compiler/testData/codegen/box/mixedNamedPosition/varargs.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/multiDecl") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)