From a9c1091140e8c4fd1ed60b7081b17dbe83dfd43a Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 22 Mar 2023 16:04:38 +0200 Subject: [PATCH] [Test] Add test for KT-57456 --- ...CompilerTestFE10TestdataTestGenerated.java | 12 ++ ...sticCompilerFE10TestDataTestGenerated.java | 12 ++ ...eeOldFrontendDiagnosticsTestGenerated.java | 12 ++ ...siOldFrontendDiagnosticsTestGenerated.java | 12 ++ ...anionInBaseEnumInitSection_function.fir.kt | 144 ++++++++++++++++++ ...CompanionInBaseEnumInitSection_function.kt | 144 ++++++++++++++++++ ...anionInBaseEnumInitSection_property.fir.kt | 144 ++++++++++++++++++ ...CompanionInBaseEnumInitSection_property.kt | 144 ++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 12 ++ 9 files changed, 636 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.fir.kt create mode 100644 compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.kt create mode 100644 compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.fir.kt create mode 100644 compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index df4ac117c0a..02883b549ca 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -5715,6 +5715,18 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia @TestMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis") @TestDataPath("$PROJECT_ROOT") public class ControlFlowAnalysis { + @Test + @TestMetadata("accessToCompanionInBaseEnumInitSection_function.kt") + public void testAccessToCompanionInBaseEnumInitSection_function() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.kt"); + } + + @Test + @TestMetadata("accessToCompanionInBaseEnumInitSection_property.kt") + public void testAccessToCompanionInBaseEnumInitSection_property() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.kt"); + } + @Test @TestMetadata("accessValueParameterInDefaultValue_after.kt") public void testAccessValueParameterInDefaultValue_after() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index e8e5cd15f19..13573d61689 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -5715,6 +5715,18 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated @TestMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis") @TestDataPath("$PROJECT_ROOT") public class ControlFlowAnalysis { + @Test + @TestMetadata("accessToCompanionInBaseEnumInitSection_function.kt") + public void testAccessToCompanionInBaseEnumInitSection_function() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.kt"); + } + + @Test + @TestMetadata("accessToCompanionInBaseEnumInitSection_property.kt") + public void testAccessToCompanionInBaseEnumInitSection_property() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.kt"); + } + @Test @TestMetadata("accessValueParameterInDefaultValue_after.kt") public void testAccessValueParameterInDefaultValue_after() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index e097620af2e..7b4d32bce4a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -5715,6 +5715,18 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir @TestMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis") @TestDataPath("$PROJECT_ROOT") public class ControlFlowAnalysis { + @Test + @TestMetadata("accessToCompanionInBaseEnumInitSection_function.kt") + public void testAccessToCompanionInBaseEnumInitSection_function() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.kt"); + } + + @Test + @TestMetadata("accessToCompanionInBaseEnumInitSection_property.kt") + public void testAccessToCompanionInBaseEnumInitSection_property() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.kt"); + } + @Test @TestMetadata("accessValueParameterInDefaultValue_after.kt") public void testAccessValueParameterInDefaultValue_after() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 54b222a6f7f..efd328b8d24 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -5721,6 +5721,18 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia @TestMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis") @TestDataPath("$PROJECT_ROOT") public class ControlFlowAnalysis { + @Test + @TestMetadata("accessToCompanionInBaseEnumInitSection_function.kt") + public void testAccessToCompanionInBaseEnumInitSection_function() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.kt"); + } + + @Test + @TestMetadata("accessToCompanionInBaseEnumInitSection_property.kt") + public void testAccessToCompanionInBaseEnumInitSection_property() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.kt"); + } + @Test @TestMetadata("accessValueParameterInDefaultValue_after.kt") public void testAccessValueParameterInDefaultValue_after() throws Exception { diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.fir.kt new file mode 100644 index 00000000000..50f67742efe --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.fir.kt @@ -0,0 +1,144 @@ +// DIAGNOSTICS: -UNUSED_VARIABLE +// WITH_STDLIB +// ISSUE: KT-57456, KT-57608 +@file:OptIn(ExperimentalContracts::class) + +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.contract +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty + +enum class Enum { + A { + val aInside = foo() + val bInside = inPlaceRun { foo() } + val cInside = nonInPlaceRun { foo() } + + val dInside by foo() + val eInside by inPlaceDelegate { foo() } + val fInside by nonInPlaceDelegate { foo() } + }, + B { + init { + val aInit = foo() + val bInit = inPlaceRun { foo() } + val cInit = nonInPlaceRun { foo() } + + val dInit by foo() + val eInit by inPlaceDelegate { foo() } + val fInit by nonInPlaceDelegate { foo() } + } + }, + C { + init { + class Local { + val aInside = foo() + val bInside = inPlaceRun { foo() } + val cInside = nonInPlaceRun { foo() } + + val dInside by foo() + val eInside by inPlaceDelegate { foo() } + val fInside by nonInPlaceDelegate { foo() } + + init { + val aInit = foo() + val bInit = inPlaceRun { foo() } + val cInit = nonInPlaceRun { foo() } + + val dInit by foo() + val eInit by inPlaceDelegate { foo() } + val fInit by nonInPlaceDelegate { foo() } + } + + fun localFun() { + val a = foo() + val b = inPlaceRun { foo() } + val c = nonInPlaceRun { foo() } + + val d by foo() + val e by inPlaceDelegate { foo() } + val f by nonInPlaceDelegate { foo() } + } + } + } + }, + D { + init { + val someObj = object { + val aInside = foo() + val bInside = inPlaceRun { foo() } + val cInside = nonInPlaceRun { foo() } + + val dInside by foo() + val eInside by inPlaceDelegate { foo() } + val fInside by nonInPlaceDelegate { foo() } + + init { + val aInit = foo() + val bInit = inPlaceRun { foo() } + val cInit = nonInPlaceRun { foo() } + + val dInit by foo() + val eInit by inPlaceDelegate { foo() } + val fInit by nonInPlaceDelegate { foo() } + } + + fun localFun() { + val a = foo() + val b = inPlaceRun { foo() } + val c = nonInPlaceRun { foo() } + + val d by foo() + val e by inPlaceDelegate { foo() } + val f by nonInPlaceDelegate { foo() } + } + } + } + } + ; + + val a = foo() + val b = inPlaceRun { foo() } + val c = nonInPlaceRun { foo() } + + val d by foo() + val e by inPlaceDelegate { foo() } + val f by nonInPlaceDelegate { foo() } + + companion object { + fun foo(): String = "foo()" + } +} + +enum class EnumWithConstructor(val a: String, val b: String, val c: String) { + A( + a = foo(), + b = inPlaceRun { foo() }, + c = nonInPlaceRun { foo() } + ); + + companion object { + fun foo(): String = "foo()" + } +} + +operator fun T.provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty = ReadOnlyProperty { _, _ -> this } + +inline fun inPlaceRun(block: () -> T): T { + contract { callsInPlace(block) } + return block() +} + +fun nonInPlaceRun(block: () -> T): T { + return block() +} + +inline fun inPlaceDelegate(block: () -> T): ReadOnlyProperty { + contract { callsInPlace(block) } + val value = block() + return ReadOnlyProperty { _, _ -> value } +} + +fun nonInPlaceDelegate(block: () -> T): ReadOnlyProperty { + return ReadOnlyProperty { _, _ -> block() } +} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.kt new file mode 100644 index 00000000000..7f81d075a14 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.kt @@ -0,0 +1,144 @@ +// DIAGNOSTICS: -UNUSED_VARIABLE +// WITH_STDLIB +// ISSUE: KT-57456, KT-57608 +@file:OptIn(ExperimentalContracts::class) + +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.contract +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty + +enum class Enum { + A { + val aInside = foo() + val bInside = inPlaceRun { foo() } + val cInside = nonInPlaceRun { foo() } + + val dInside by foo() + val eInside by inPlaceDelegate { foo() } + val fInside by nonInPlaceDelegate { foo() } + }, + B { + init { + val aInit = foo() + val bInit = inPlaceRun { foo() } + val cInit = nonInPlaceRun { foo() } + + val dInit by foo() + val eInit by inPlaceDelegate { foo() } + val fInit by nonInPlaceDelegate { foo() } + } + }, + C { + init { + class Local { + val aInside = foo() + val bInside = inPlaceRun { foo() } + val cInside = nonInPlaceRun { foo() } + + val dInside by foo() + val eInside by inPlaceDelegate { foo() } + val fInside by nonInPlaceDelegate { foo() } + + init { + val aInit = foo() + val bInit = inPlaceRun { foo() } + val cInit = nonInPlaceRun { foo() } + + val dInit by foo() + val eInit by inPlaceDelegate { foo() } + val fInit by nonInPlaceDelegate { foo() } + } + + fun localFun() { + val a = foo() + val b = inPlaceRun { foo() } + val c = nonInPlaceRun { foo() } + + val d by foo() + val e by inPlaceDelegate { foo() } + val f by nonInPlaceDelegate { foo() } + } + } + } + }, + D { + init { + val someObj = object { + val aInside = foo() + val bInside = inPlaceRun { foo() } + val cInside = nonInPlaceRun { foo() } + + val dInside by foo() + val eInside by inPlaceDelegate { foo() } + val fInside by nonInPlaceDelegate { foo() } + + init { + val aInit = foo() + val bInit = inPlaceRun { foo() } + val cInit = nonInPlaceRun { foo() } + + val dInit by foo() + val eInit by inPlaceDelegate { foo() } + val fInit by nonInPlaceDelegate { foo() } + } + + fun localFun() { + val a = foo() + val b = inPlaceRun { foo() } + val c = nonInPlaceRun { foo() } + + val d by foo() + val e by inPlaceDelegate { foo() } + val f by nonInPlaceDelegate { foo() } + } + } + } + } + ; + + val a = foo() + val b = inPlaceRun { foo() } + val c = nonInPlaceRun { foo() } + + val d by foo() + val e by inPlaceDelegate { foo() } + val f by nonInPlaceDelegate { foo() } + + companion object { + fun foo(): String = "foo()" + } +} + +enum class EnumWithConstructor(val a: String, val b: String, val c: String) { + A( + a = foo(), + b = inPlaceRun { foo() }, + c = nonInPlaceRun { foo() } + ); + + companion object { + fun foo(): String = "foo()" + } +} + +operator fun T.provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty = ReadOnlyProperty { _, _ -> this } + +inline fun inPlaceRun(block: () -> T): T { + contract { callsInPlace(block) } + return block() +} + +fun nonInPlaceRun(block: () -> T): T { + return block() +} + +inline fun inPlaceDelegate(block: () -> T): ReadOnlyProperty { + contract { callsInPlace(block) } + val value = block() + return ReadOnlyProperty { _, _ -> value } +} + +fun nonInPlaceDelegate(block: () -> T): ReadOnlyProperty { + return ReadOnlyProperty { _, _ -> block() } +} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.fir.kt new file mode 100644 index 00000000000..42e4f84fc31 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.fir.kt @@ -0,0 +1,144 @@ +// DIAGNOSTICS: -UNUSED_VARIABLE +// WITH_STDLIB +// ISSUE: KT-57456, KT-57608 +@file:OptIn(ExperimentalContracts::class) + +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.contract +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty + +enum class Enum { + A { + val aInside = value + val bInside = inPlaceRun { value } + val cInside = nonInPlaceRun { value } + + val dInside by value + val eInside by inPlaceDelegate { value } + val fInside by nonInPlaceDelegate { value } + }, + B { + init { + val aInit = value + val bInit = inPlaceRun { value } + val cInit = nonInPlaceRun { value } + + val dInit by value + val eInit by inPlaceDelegate { value } + val fInit by nonInPlaceDelegate { value } + } + }, + C { + init { + class Local { + val aInside = value + val bInside = inPlaceRun { value } + val cInside = nonInPlaceRun { value } + + val dInside by value + val eInside by inPlaceDelegate { value } + val fInside by nonInPlaceDelegate { value } + + init { + val aInit = value + val bInit = inPlaceRun { value } + val cInit = nonInPlaceRun { value } + + val dInit by value + val eInit by inPlaceDelegate { value } + val fInit by nonInPlaceDelegate { value } + } + + fun localFun() { + val a = value + val b = inPlaceRun { value } + val c = nonInPlaceRun { value } + + val d by value + val e by inPlaceDelegate { value } + val f by nonInPlaceDelegate { value } + } + } + } + }, + D { + init { + val someObj = object { + val aInside = value + val bInside = inPlaceRun { value } + val cInside = nonInPlaceRun { value } + + val dInside by value + val eInside by inPlaceDelegate { value } + val fInside by nonInPlaceDelegate { value } + + init { + val aInit = value + val bInit = inPlaceRun { value } + val cInit = nonInPlaceRun { value } + + val dInit by value + val eInit by inPlaceDelegate { value } + val fInit by nonInPlaceDelegate { value } + } + + fun localFun() { + val a = value + val b = inPlaceRun { value } + val c = nonInPlaceRun { value } + + val d by value + val e by inPlaceDelegate { value } + val f by nonInPlaceDelegate { value } + } + } + } + } + ; + + val a = value + val b = inPlaceRun { value } + val c = nonInPlaceRun { value } + + val d by value + val e by inPlaceDelegate { value } + val f by nonInPlaceDelegate { value } + + companion object { + val value = "value" + } +} + +enum class EnumWithConstructor(val a: String, val b: String, val c: String) { + A( + a = value, + b = inPlaceRun { value }, + c = nonInPlaceRun { value } + ); + + companion object { + val value = "value" + } +} + +operator fun T.provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty = ReadOnlyProperty { _, _ -> this } + +inline fun inPlaceRun(block: () -> T): T { + contract { callsInPlace(block) } + return block() +} + +fun nonInPlaceRun(block: () -> T): T { + return block() +} + +inline fun inPlaceDelegate(block: () -> T): ReadOnlyProperty { + contract { callsInPlace(block) } + val value = block() + return ReadOnlyProperty { _, _ -> value } +} + +fun nonInPlaceDelegate(block: () -> T): ReadOnlyProperty { + return ReadOnlyProperty { _, _ -> block() } +} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.kt new file mode 100644 index 00000000000..f3c72045de2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.kt @@ -0,0 +1,144 @@ +// DIAGNOSTICS: -UNUSED_VARIABLE +// WITH_STDLIB +// ISSUE: KT-57456, KT-57608 +@file:OptIn(ExperimentalContracts::class) + +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.contract +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty + +enum class Enum { + A { + val aInside = value + val bInside = inPlaceRun { value } + val cInside = nonInPlaceRun { value } + + val dInside by value + val eInside by inPlaceDelegate { value } + val fInside by nonInPlaceDelegate { value } + }, + B { + init { + val aInit = value + val bInit = inPlaceRun { value } + val cInit = nonInPlaceRun { value } + + val dInit by value + val eInit by inPlaceDelegate { value } + val fInit by nonInPlaceDelegate { value } + } + }, + C { + init { + class Local { + val aInside = value + val bInside = inPlaceRun { value } + val cInside = nonInPlaceRun { value } + + val dInside by value + val eInside by inPlaceDelegate { value } + val fInside by nonInPlaceDelegate { value } + + init { + val aInit = value + val bInit = inPlaceRun { value } + val cInit = nonInPlaceRun { value } + + val dInit by value + val eInit by inPlaceDelegate { value } + val fInit by nonInPlaceDelegate { value } + } + + fun localFun() { + val a = value + val b = inPlaceRun { value } + val c = nonInPlaceRun { value } + + val d by value + val e by inPlaceDelegate { value } + val f by nonInPlaceDelegate { value } + } + } + } + }, + D { + init { + val someObj = object { + val aInside = value + val bInside = inPlaceRun { value } + val cInside = nonInPlaceRun { value } + + val dInside by value + val eInside by inPlaceDelegate { value } + val fInside by nonInPlaceDelegate { value } + + init { + val aInit = value + val bInit = inPlaceRun { value } + val cInit = nonInPlaceRun { value } + + val dInit by value + val eInit by inPlaceDelegate { value } + val fInit by nonInPlaceDelegate { value } + } + + fun localFun() { + val a = value + val b = inPlaceRun { value } + val c = nonInPlaceRun { value } + + val d by value + val e by inPlaceDelegate { value } + val f by nonInPlaceDelegate { value } + } + } + } + } + ; + + val a = value + val b = inPlaceRun { value } + val c = nonInPlaceRun { value } + + val d by value + val e by inPlaceDelegate { value } + val f by nonInPlaceDelegate { value } + + companion object { + val value = "value" + } +} + +enum class EnumWithConstructor(val a: String, val b: String, val c: String) { + A( + a = value, + b = inPlaceRun { value }, + c = nonInPlaceRun { value } + ); + + companion object { + val value = "value" + } +} + +operator fun T.provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty = ReadOnlyProperty { _, _ -> this } + +inline fun inPlaceRun(block: () -> T): T { + contract { callsInPlace(block) } + return block() +} + +fun nonInPlaceRun(block: () -> T): T { + return block() +} + +inline fun inPlaceDelegate(block: () -> T): ReadOnlyProperty { + contract { callsInPlace(block) } + val value = block() + return ReadOnlyProperty { _, _ -> value } +} + +fun nonInPlaceDelegate(block: () -> T): ReadOnlyProperty { + return ReadOnlyProperty { _, _ -> block() } +} 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 5f6f7433c6b..d554da2c321 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 @@ -5721,6 +5721,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { @TestMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis") @TestDataPath("$PROJECT_ROOT") public class ControlFlowAnalysis { + @Test + @TestMetadata("accessToCompanionInBaseEnumInitSection_function.kt") + public void testAccessToCompanionInBaseEnumInitSection_function() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_function.kt"); + } + + @Test + @TestMetadata("accessToCompanionInBaseEnumInitSection_property.kt") + public void testAccessToCompanionInBaseEnumInitSection_property() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/accessToCompanionInBaseEnumInitSection_property.kt"); + } + @Test @TestMetadata("accessValueParameterInDefaultValue_after.kt") public void testAccessValueParameterInDefaultValue_after() throws Exception {