Can be private: correct detection of calls inside inline function

So #KT-22180 Fixed
So #KT-22094 Fixed
This commit is contained in:
Mikhail Glukhikh
2018-06-06 15:50:08 +03:00
parent a8737a1278
commit 38632c2937
2 changed files with 20 additions and 1 deletions
@@ -131,7 +131,7 @@ class MemberVisibilityCanBePrivateInspection : AbstractKotlinInspection() {
return@Processor false
}
}
val function = usage.getParentOfType<KtCallableDeclaration>(false)
val function = usage.getParentOfType<KtNamedFunction>(true)
val insideInlineFun = function?.modifierList?.let { it.hasModifier(KtTokens.INLINE_KEYWORD) && !function.isPrivate() } ?: false
if (insideInlineFun) {
otherUsageFound = true
@@ -0,0 +1,19 @@
open class AA {
protected inline fun foo() {
val result = bar()
}
protected fun bar() {
}
}
fun <T> run(f: () -> T): T = f()
object TT {
inline fun foo(f: () -> String) {
run {
bar(f())
}
}
fun bar(s: String) = s
}