diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/ifWithCR.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/ifWithCR.kt index 1eacfbff8c8..6c6be29bea8 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/ifWithCR.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/ifWithCR.kt @@ -1,5 +1,5 @@ -private var Int.readOnlyWrapper: CharSequence? get() = null -private var Int.mutableWrapper: CharSequence? get() = null +private var Int.readOnlyWrapper: CharSequence? get() = null +private var Int.mutableWrapper: CharSequence? get() = null fun main(x: Int) { val x = if (x > 1) x::readOnlyWrapper else x::mutableWrapper diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt index 6523fa6a080..08b375c74c9 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt @@ -130,7 +130,7 @@ internal fun checkPropertyInitializer( !isExternal && !property.hasExplicitBackingField ) { - if (property.receiverParameter != null && !property.hasAnyAccessorImplementation) { + if (property.receiverParameter != null && !property.hasAllAccessorImplementation) { reporter.reportOn(propertySource, FirErrors.EXTENSION_PROPERTY_MUST_HAVE_ACCESSORS_OR_BE_ABSTRACT, context) } else if (reachable) { reportMustBeInitialized(property, isDefinitelyAssignedInConstructor, containingClass, propertySource, reporter, context) @@ -209,6 +209,9 @@ private val FirProperty.hasSetterAccessorImplementation: Boolean private val FirProperty.hasAnyAccessorImplementation: Boolean get() = getter.hasImplementation || setter.hasImplementation +private val FirProperty.hasAllAccessorImplementation: Boolean + get() = getter.hasImplementation && (isVal || setter.hasImplementation) + private fun FirProperty.getEffectiveModality(containingClass: FirClass?, languageVersionSettings: LanguageVersionSettings): Modality? = when (languageVersionSettings.supportsFeature(LanguageFeature.TakeIntoAccountEffectivelyFinalInMustBeInitializedCheck) && status.modality == Modality.OPEN && containingClass?.status?.modality == Modality.FINAL) { diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstCustomBinariesTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstCustomBinariesTest.kt index 9d46fe661c2..db57994f89d 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstCustomBinariesTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileKotlinAgainstCustomBinariesTest.kt @@ -663,8 +663,7 @@ abstract class AbstractCompileKotlinAgainstCustomBinariesTest : AbstractKotlinCo compileKotlin("main.kt", tmpdir, listOf(library), additionalOptions = features) } - // Fixed in the LV2.0 branch. - fun testUnreachableExtensionVarPropertyDeclaration() = muteForK2 { + fun testUnreachableExtensionVarPropertyDeclaration() { val (output, exitCode) = compileKotlin("source.kt", tmpdir, expectedFileName = null) assertEquals("Output:\n$output", ExitCode.COMPILATION_ERROR, exitCode) }