diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ProtectedInSuperClassCompanionCallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ProtectedInSuperClassCompanionCallChecker.kt index bbe3359d61a..33bd2bf9a06 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ProtectedInSuperClassCompanionCallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ProtectedInSuperClassCompanionCallChecker.kt @@ -17,7 +17,9 @@ package org.jetbrains.kotlin.resolve.jvm.checkers import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.annotations.hasJvmStaticAnnotation @@ -29,7 +31,14 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm class ProtectedInSuperClassCompanionCallChecker : CallChecker { override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) { - val targetDescriptor = resolvedCall.resultingDescriptor.original + check(resolvedCall.resultingDescriptor.original, reportOn, context) + } + + override fun checkPropertyCall(descriptor: PropertyAccessorDescriptor, reportOn: PsiElement, context: CallCheckerContext) { + check(descriptor, reportOn, context) + } + + private fun check(targetDescriptor: CallableDescriptor, reportOn: PsiElement, context: CallCheckerContext) { // Protected non-JVM static if (targetDescriptor.visibility != Visibilities.PROTECTED) return if (targetDescriptor.hasJvmStaticAnnotation()) return diff --git a/compiler/testData/diagnostics/testsWithStdLib/CallCompanionProtectedNonStatic.kt b/compiler/testData/diagnostics/testsWithStdLib/CallCompanionProtectedNonStatic.kt index ac714408aac..e9512072dbe 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/CallCompanionProtectedNonStatic.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/CallCompanionProtectedNonStatic.kt @@ -27,6 +27,9 @@ open class Base { } companion object : VeryBase() { + var prop = 42 + protected set + protected fun bar() {} @JvmStatic protected fun gav() {} @@ -46,6 +49,7 @@ class Derived : Base() { gav() // Ok bar() baz() + prop = 0 } inner class DerivedInner { @@ -54,6 +58,7 @@ class Derived : Base() { gav() // Ok bar() baz() + prop = 0 } } @@ -62,6 +67,7 @@ class Derived : Base() { gav() // Ok bar() baz() + prop = 0 } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/CallCompanionProtectedNonStatic.txt b/compiler/testData/diagnostics/testsWithStdLib/CallCompanionProtectedNonStatic.txt index 6e98801e08c..81df8b4eedf 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/CallCompanionProtectedNonStatic.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/CallCompanionProtectedNonStatic.txt @@ -11,6 +11,7 @@ public open class Base { public companion object Companion : VeryBase { private constructor Companion() + public final var prop: kotlin.Int protected final fun bar(): kotlin.Unit protected final override /*1*/ /*fake_override*/ fun baz(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean