Do not report "can be private" on properties of private class

So #KT-18822 Fixed
This commit is contained in:
Toshiaki Kameyama
2017-07-12 06:28:52 +03:00
committed by Mikhail Glukhikh
parent f4d63158cc
commit 848f7423ee
2 changed files with 17 additions and 2 deletions
@@ -52,8 +52,9 @@ class MemberVisibilityCanPrivateInspection : AbstractKotlinInspection() {
override fun visitParameter(parameter: KtParameter) {
super.visitParameter(parameter)
if (parameter.isConstructorDeclaredProperty() && canBePrivate(parameter)) {
registerProblem(holder, parameter)
if (parameter.isConstructorDeclaredProperty()) {
if ((parameter.ownerFunction?.parent as? KtClass)?.isPrivate() == true) return
if (canBePrivate(parameter)) registerProblem(holder, parameter)
}
}
}
@@ -134,4 +134,18 @@ class F(val bar: Int) {
class G(val bar: Int) {
private inline fun baz() = bar
}
private class H(val a: String = "",
var b: String = "",
internal val c: String = "",
protected val d: String = "",
private val e: String = "") {
fun foo() {
println(a)
println(b)
println(c)
println(d)
println(e)
}
}