diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 4761bd841a9..f98183daa83 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -5290,6 +5290,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag @TestMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis") @TestDataPath("$PROJECT_ROOT") public class ControlFlowAnalysis { + @Test + @TestMetadata("accessValueParameterInDefaultValue_after.kt") + public void testAccessValueParameterInDefaultValue_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.kt"); + } + + @Test + @TestMetadata("accessValueParameterInDefaultValue_before.kt") + public void testAccessValueParameterInDefaultValue_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.kt"); + } + @Test public void testAllFilesPresentInControlFlowAnalysis() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/controlFlowAnalysis"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); 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 87bfd05d05c..f557b7d3451 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 @@ -5290,6 +5290,18 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti @TestMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis") @TestDataPath("$PROJECT_ROOT") public class ControlFlowAnalysis { + @Test + @TestMetadata("accessValueParameterInDefaultValue_after.kt") + public void testAccessValueParameterInDefaultValue_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.kt"); + } + + @Test + @TestMetadata("accessValueParameterInDefaultValue_before.kt") + public void testAccessValueParameterInDefaultValue_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.kt"); + } + @Test public void testAllFilesPresentInControlFlowAnalysis() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/controlFlowAnalysis"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index 72f9116b78f..863becabf43 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -5290,6 +5290,18 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac @TestMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis") @TestDataPath("$PROJECT_ROOT") public class ControlFlowAnalysis { + @Test + @TestMetadata("accessValueParameterInDefaultValue_after.kt") + public void testAccessValueParameterInDefaultValue_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.kt"); + } + + @Test + @TestMetadata("accessValueParameterInDefaultValue_before.kt") + public void testAccessValueParameterInDefaultValue_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.kt"); + } + @Test public void testAllFilesPresentInControlFlowAnalysis() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/controlFlowAnalysis"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index aee14257b68..c6dd27ec7e6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -1032,6 +1032,7 @@ public interface Errors { DiagnosticFactory1 UNINITIALIZED_VARIABLE = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 UNINITIALIZED_PARAMETER = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 UNINITIALIZED_PARAMETER_WARNING = DiagnosticFactory1.create(WARNING); DiagnosticFactory1 UNINITIALIZED_ENUM_ENTRY = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 UNINITIALIZED_ENUM_COMPANION = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 UNINITIALIZED_ENUM_COMPANION_WARNING = DiagnosticFactory1.create(WARNING); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 9f72b3b0dcb..f8b999f6327 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -345,6 +345,7 @@ public class DefaultErrorMessages { MAP.put(UNINITIALIZED_VARIABLE, "Variable ''{0}'' must be initialized", NAME); MAP.put(UNINITIALIZED_PARAMETER, "Parameter ''{0}'' is uninitialized here", NAME); + MAP.put(UNINITIALIZED_PARAMETER_WARNING, "Parameter ''{0}'' is uninitialized here. This warning will be an error in future releases", NAME); MAP.put(UNINITIALIZED_ENUM_ENTRY, "Enum entry ''{0}'' is uninitialized here", NAME); MAP.put(UNINITIALIZED_ENUM_COMPANION, "Companion object of enum class ''{0}'' is uninitialized here", NAME); MAP.put(UNINITIALIZED_ENUM_COMPANION_WARNING, "Companion object of enum class ''{0}'' is uninitialized here. This warning will become an error in future releases", NAME); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt index 5ac9c4f7a4f..95ac5538457 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt @@ -48,6 +48,7 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf( SuspendFunctionAsSupertypeChecker, EnumCompanionInEnumConstructorCallChecker, ContextualDeclarationChecker, + ValueParameterUsageInDefaultArgumentChecker, ) private val DEFAULT_CALL_CHECKERS = listOf( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ValueParameterUsageInDefaultArgumentChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ValueParameterUsageInDefaultArgumentChecker.kt new file mode 100644 index 00000000000..bf894284983 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ValueParameterUsageInDefaultArgumentChecker.kt @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.resolve.checkers + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.config.LanguageFeature.ProhibitIllegalValueParameterUsageInDefaultArguments +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.calls.tower.NewVariableAsFunctionResolvedCallImpl +import org.jetbrains.kotlin.resolve.calls.util.getResolvedCall + +object ValueParameterUsageInDefaultArgumentChecker : DeclarationChecker { + override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { + if (declaration !is KtFunction || descriptor !is FunctionDescriptor) return + val allParameters = descriptor.valueParameters + val declaredParameters = mutableListOf() + // We can don't check last parameter, because all other parameters already declared + for ((parameter, parameterDescriptor) in declaration.valueParameters.zip(allParameters).dropLast(1)) { + checkParameter(parameter, allParameters, declaredParameters, context) + declaredParameters += parameterDescriptor + } + } + + private fun checkParameter( + parameter: KtParameter, + allParameters: List, + declaredParameters: List, + context: DeclarationCheckerContext + ) { + val defaultValue = parameter.defaultValue ?: return + val bindingContext = context.trace.bindingContext + + val visitor = object : KtVisitorVoid() { + override fun visitElement(element: PsiElement) { + element.acceptChildren(this) + } + + override fun visitSimpleNameExpression(expression: KtSimpleNameExpression) { + val resolvedDescriptor = expression.getResolvedCall(bindingContext) + ?.resultingDescriptor as? ValueParameterDescriptor + ?: return + checkParameter(expression, resolvedDescriptor) + } + + override fun visitCallExpression(expression: KtCallExpression) { + val resolvedCall = expression.getResolvedCall(bindingContext) + if (resolvedCall is NewVariableAsFunctionResolvedCallImpl) { + val calleeExpression = expression.calleeExpression as? KtSimpleNameExpression + val descriptor = resolvedCall.variableCall.resultingDescriptor as? ValueParameterDescriptor + if (calleeExpression != null && descriptor != null) { + checkParameter(calleeExpression, descriptor) + } + } + expression.acceptChildren(this) + } + + private fun checkParameter(expression: KtSimpleNameExpression, descriptor: ValueParameterDescriptor) { + if (descriptor in allParameters && descriptor !in declaredParameters) { + val factory = + when (context.languageVersionSettings.supportsFeature(ProhibitIllegalValueParameterUsageInDefaultArguments)) { + true -> Errors.UNINITIALIZED_PARAMETER + false -> Errors.UNINITIALIZED_PARAMETER_WARNING + } + context.trace.report(factory.on(expression, descriptor)) + } + } + } + + defaultValue.acceptChildren(visitor) + } +} diff --git a/compiler/testData/diagnostics/tests/DefaultValuesTypechecking.kt b/compiler/testData/diagnostics/tests/DefaultValuesTypechecking.kt index bf8107c328a..685ae6d9ba4 100644 --- a/compiler/testData/diagnostics/tests/DefaultValuesTypechecking.kt +++ b/compiler/testData/diagnostics/tests/DefaultValuesTypechecking.kt @@ -15,13 +15,13 @@ val z = 3 fun foo(x: Int = y, y: Int = x, i : Int = z): Int = x + y -fun foo(x: () -> Int = { y }, y: Int = x(), i : Int = z): Int = x() + y +fun foo(x: () -> Int = { y }, y: Int = x(), i : Int = z): Int = x() + y -fun bar(x: () -> Int = { y; 1 }, y: Int) {} +fun bar(x: () -> Int = { y; 1 }, y: Int) {} fun baz( x: () -> Int = { - fun bar(xx: () -> Int = { y; 1 }) = xx + fun bar(xx: () -> Int = { y; 1 }) = xx bar()() }, y: Int @@ -30,7 +30,7 @@ fun baz( fun boo( x: () -> Int = { - fun bar(): Int = y + fun bar(): Int = y bar() }, y: Int diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.fir.kt new file mode 100644 index 00000000000..2f3d6cf04c0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.fir.kt @@ -0,0 +1,72 @@ +// LANGUAGE: +ProhibitIllegalValueParameterUsageInDefaultArguments +// DIAGNOSTICS: -UNUSED_PARAMETER +// WITH_STDLIB +// ISSUE: KT-25694 + +fun test_1( + x: () -> String = { y }, // Error + y: String = "OK" +) {} + +fun test_2( + x: String = "OK", + y: () -> String = { x } // OK +) {} + +fun test_3( + x: () -> Any = { y() to y.invoke() }, // Error + y: () -> String = { "OK" } +) {} + +fun test_4( + x: () -> String = { "OK" }, + y: () -> Any = { x() to x.invoke() } // OK +) {} + +interface Foo { + fun foo() +} + +fun test_5( + x: Foo = object : Foo { + val z1 = y // Error + val z2 = run { y } // Error + + init { + println(y) // Error + } + + override fun foo() { + println(y) // Error + } + }, + y: String = "OK" +) {} + +fun test_6( + x: String = "OK", + y: Foo = object : Foo { + val z1 = x // OK + val z2 = run { x } // OK + + init { + println(x) // OK + } + + override fun foo() { + println(x) // OK + } + } +) {} + +fun getFoo(x: String): Foo = null!! + +fun test_7( + x: Foo = object : Foo by getFoo(y) {}, // Error + y: String = "OK" +) {} + +fun test_8( + x: String = "OK", + y: Foo = object : Foo by getFoo(x) {} // OK +) {} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.kt new file mode 100644 index 00000000000..ba2b447cb84 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.kt @@ -0,0 +1,72 @@ +// LANGUAGE: +ProhibitIllegalValueParameterUsageInDefaultArguments +// DIAGNOSTICS: -UNUSED_PARAMETER +// WITH_STDLIB +// ISSUE: KT-25694 + +fun test_1( + x: () -> String = { y }, // Error + y: String = "OK" +) {} + +fun test_2( + x: String = "OK", + y: () -> String = { x } // OK +) {} + +fun test_3( + x: () -> Any = { y() to y.invoke() }, // Error + y: () -> String = { "OK" } +) {} + +fun test_4( + x: () -> String = { "OK" }, + y: () -> Any = { x() to x.invoke() } // OK +) {} + +interface Foo { + fun foo() +} + +fun test_5( + x: Foo = object : Foo { + val z1 = y // Error + val z2 = run { y } // Error + + init { + println(y) // Error + } + + override fun foo() { + println(y) // Error + } + }, + y: String = "OK" +) {} + +fun test_6( + x: String = "OK", + y: Foo = object : Foo { + val z1 = x // OK + val z2 = run { x } // OK + + init { + println(x) // OK + } + + override fun foo() { + println(x) // OK + } + } +) {} + +fun getFoo(x: String): Foo = null!! + +fun test_7( + x: Foo = object : Foo by getFoo(y) {}, // Error + y: String = "OK" +) {} + +fun test_8( + x: String = "OK", + y: Foo = object : Foo by getFoo(x) {} // OK +) {} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.txt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.txt new file mode 100644 index 00000000000..4d50f1b05f4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.txt @@ -0,0 +1,18 @@ +package + +public fun getFoo(/*0*/ x: kotlin.String): Foo +public fun test_1(/*0*/ x: () -> kotlin.String = ..., /*1*/ y: kotlin.String = ...): kotlin.Unit +public fun test_2(/*0*/ x: kotlin.String = ..., /*1*/ y: () -> kotlin.String = ...): kotlin.Unit +public fun test_3(/*0*/ x: () -> kotlin.Any = ..., /*1*/ y: () -> kotlin.String = ...): kotlin.Unit +public fun test_4(/*0*/ x: () -> kotlin.String = ..., /*1*/ y: () -> kotlin.Any = ...): kotlin.Unit +public fun test_5(/*0*/ x: Foo = ..., /*1*/ y: kotlin.String = ...): kotlin.Unit +public fun test_6(/*0*/ x: kotlin.String = ..., /*1*/ y: Foo = ...): kotlin.Unit +public fun test_7(/*0*/ x: Foo = ..., /*1*/ y: kotlin.String = ...): kotlin.Unit +public fun test_8(/*0*/ x: kotlin.String = ..., /*1*/ y: Foo = ...): kotlin.Unit + +public interface Foo { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.fir.kt new file mode 100644 index 00000000000..74a637204fa --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.fir.kt @@ -0,0 +1,72 @@ +// LANGUAGE: -ProhibitIllegalValueParameterUsageInDefaultArguments +// DIAGNOSTICS: -UNUSED_PARAMETER +// WITH_STDLIB +// ISSUE: KT-25694 + +fun test_1( + x: () -> String = { y }, // Error + y: String = "OK" +) {} + +fun test_2( + x: String = "OK", + y: () -> String = { x } // OK +) {} + +fun test_3( + x: () -> Any = { y() to y.invoke() }, // Error + y: () -> String = { "OK" } +) {} + +fun test_4( + x: () -> String = { "OK" }, + y: () -> Any = { x() to x.invoke() } // OK +) {} + +interface Foo { + fun foo() +} + +fun test_5( + x: Foo = object : Foo { + val z1 = y // Error + val z2 = run { y } // Error + + init { + println(y) // Error + } + + override fun foo() { + println(y) // Error + } + }, + y: String = "OK" +) {} + +fun test_6( + x: String = "OK", + y: Foo = object : Foo { + val z1 = x // OK + val z2 = run { x } // OK + + init { + println(x) // OK + } + + override fun foo() { + println(x) // OK + } + } +) {} + +fun getFoo(x: String): Foo = null!! + +fun test_7( + x: Foo = object : Foo by getFoo(y) {}, // Error + y: String = "OK" +) {} + +fun test_8( + x: String = "OK", + y: Foo = object : Foo by getFoo(x) {} // OK +) {} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.kt new file mode 100644 index 00000000000..9e83758dcf1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.kt @@ -0,0 +1,72 @@ +// LANGUAGE: -ProhibitIllegalValueParameterUsageInDefaultArguments +// DIAGNOSTICS: -UNUSED_PARAMETER +// WITH_STDLIB +// ISSUE: KT-25694 + +fun test_1( + x: () -> String = { y }, // Error + y: String = "OK" +) {} + +fun test_2( + x: String = "OK", + y: () -> String = { x } // OK +) {} + +fun test_3( + x: () -> Any = { y() to y.invoke() }, // Error + y: () -> String = { "OK" } +) {} + +fun test_4( + x: () -> String = { "OK" }, + y: () -> Any = { x() to x.invoke() } // OK +) {} + +interface Foo { + fun foo() +} + +fun test_5( + x: Foo = object : Foo { + val z1 = y // Error + val z2 = run { y } // Error + + init { + println(y) // Error + } + + override fun foo() { + println(y) // Error + } + }, + y: String = "OK" +) {} + +fun test_6( + x: String = "OK", + y: Foo = object : Foo { + val z1 = x // OK + val z2 = run { x } // OK + + init { + println(x) // OK + } + + override fun foo() { + println(x) // OK + } + } +) {} + +fun getFoo(x: String): Foo = null!! + +fun test_7( + x: Foo = object : Foo by getFoo(y) {}, // Error + y: String = "OK" +) {} + +fun test_8( + x: String = "OK", + y: Foo = object : Foo by getFoo(x) {} // OK +) {} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.txt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.txt new file mode 100644 index 00000000000..79ee52401c2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.txt @@ -0,0 +1,19 @@ +package + +public fun getFoo(/*0*/ x: kotlin.String): Foo +public fun test_1(/*0*/ x: () -> kotlin.String = ..., /*1*/ y: kotlin.String = ...): kotlin.Unit +public fun test_2(/*0*/ x: kotlin.String = ..., /*1*/ y: () -> kotlin.String = ...): kotlin.Unit +public fun test_3(/*0*/ x: () -> kotlin.Any = ..., /*1*/ y: () -> kotlin.String = ...): kotlin.Unit +public fun test_4(/*0*/ x: () -> kotlin.String = ..., /*1*/ y: () -> kotlin.Any = ...): kotlin.Unit +public fun test_5(/*0*/ x: Foo = ..., /*1*/ y: kotlin.String = ...): kotlin.Unit +public fun test_6(/*0*/ x: kotlin.String = ..., /*1*/ y: Foo = ...): kotlin.Unit +public fun test_7(/*0*/ x: Foo = ..., /*1*/ y: kotlin.String = ...): kotlin.Unit +public fun test_8(/*0*/ x: kotlin.String = ..., /*1*/ y: Foo = ...): kotlin.Unit + +public interface Foo { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + 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 cd534010db8..d555813a4df 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 @@ -5296,6 +5296,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { @TestMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis") @TestDataPath("$PROJECT_ROOT") public class ControlFlowAnalysis { + @Test + @TestMetadata("accessValueParameterInDefaultValue_after.kt") + public void testAccessValueParameterInDefaultValue_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_after.kt"); + } + + @Test + @TestMetadata("accessValueParameterInDefaultValue_before.kt") + public void testAccessValueParameterInDefaultValue_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessValueParameterInDefaultValue_before.kt"); + } + @Test public void testAllFilesPresentInControlFlowAnalysis() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/controlFlowAnalysis"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index b8de079a003..41581fa8c1a 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -257,6 +257,7 @@ enum class LanguageFeature( // 1.9 DisableCheckingChangedProgressionsResolve(KOTLIN_1_9), // KT-49276 + ProhibitIllegalValueParameterUsageInDefaultArguments(KOTLIN_1_9, kind = BUG_FIX), // KT-25694 // Temporarily disabled, see KT-27084/KT-22379 SoundSmartcastFromLoopConditionForLoopAssignedVariables(sinceVersion = null, kind = BUG_FIX),