Can be private: don't report if it's used in inline property
#KT-29085 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
2a7eb2fb0e
commit
7cba11ff28
+3
-1
@@ -133,7 +133,7 @@ class MemberVisibilityCanBePrivateInspection : AbstractKotlinInspection() {
|
||||
val function = usage.getParentOfTypesAndPredicate<KtDeclarationWithBody>(
|
||||
true, KtNamedFunction::class.java, KtPropertyAccessor::class.java
|
||||
) { true }
|
||||
val insideInlineFun = function?.let { it.hasModifier(KtTokens.INLINE_KEYWORD) && !function.isPrivate() } ?: false
|
||||
val insideInlineFun = function.insideInline() || (function as? KtPropertyAccessor)?.property.insideInline()
|
||||
if (insideInlineFun) {
|
||||
otherUsageFound = true
|
||||
false
|
||||
@@ -145,6 +145,8 @@ class MemberVisibilityCanBePrivateInspection : AbstractKotlinInspection() {
|
||||
return inClassUsageFound && !otherUsageFound
|
||||
}
|
||||
|
||||
private fun KtModifierListOwner?.insideInline() = this?.let { it.hasModifier(KtTokens.INLINE_KEYWORD) && !it.isPrivate() } ?: false
|
||||
|
||||
private fun registerProblem(holder: ProblemsHolder, declaration: KtDeclaration) {
|
||||
val modifierListOwner = declaration.getParentOfType<KtModifierListOwner>(false) ?: return
|
||||
val member = when (declaration) {
|
||||
|
||||
@@ -18,7 +18,12 @@ object TT {
|
||||
val x: String
|
||||
inline get() = baz
|
||||
|
||||
inline val y: String
|
||||
get() = qux
|
||||
|
||||
fun bar(s: String) = s
|
||||
|
||||
val baz = ""
|
||||
|
||||
val qux = ""
|
||||
}
|
||||
Reference in New Issue
Block a user