Skip to content

Commit

Permalink
Set 'protected' modifier as allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
VitalyVPinchuk committed Apr 28, 2022
1 parent b8700b6 commit b86ae6f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.psi.KtObjectDeclaration
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
import org.jetbrains.kotlin.psi.psiUtil.getTopmostParentOfType
import org.jetbrains.kotlin.psi.psiUtil.isProtected
import org.jetbrains.kotlin.psi.psiUtil.isPublic

/**
Expand Down Expand Up @@ -66,12 +67,12 @@ class KDocReferencesNonPublicProperty(config: Config = Config.empty) : Rule(conf
}

private fun KtProperty.isNonPublicInherited(): Boolean {
if (!isPublic) {
if (!isPublic && !isProtected()) {
return true
}
var classOrObject = containingClassOrObject
while (classOrObject != null && classOrObject is KtObjectDeclaration) {
if (!classOrObject.isPublic) {
if (!classOrObject.isPublic && !isProtected()) {
return true
}
classOrObject = classOrObject.containingClassOrObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class KDocReferencesNonPublicPropertySpec {
* [A.B.prop2] - public property
* [C.prop3] - public property
*/
class Test {
val prop1 = 0
open class Test {
protected val prop1 = 0
object A {
object B {
val prop2 = 0
Expand Down

0 comments on commit b86ae6f

Please sign in to comment.