Merge branch 'KT-18797' of https://github.com/nd/kotlin
This commit is contained in:
+13
-6
@@ -30,10 +30,7 @@ import org.jetbrains.kotlin.idea.quickfix.AddModifierFix
|
||||
import org.jetbrains.kotlin.idea.refactoring.isConstructorDeclaredProperty
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isInheritable
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isOverridable
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
|
||||
class MemberVisibilityCanPrivateInspection : AbstractKotlinInspection() {
|
||||
|
||||
@@ -91,8 +88,18 @@ class MemberVisibilityCanPrivateInspection : AbstractKotlinInspection() {
|
||||
false
|
||||
}
|
||||
else {
|
||||
inClassUsageFound = true
|
||||
true
|
||||
val function = usage.getParentOfType<KtCallableDeclaration>(false)
|
||||
val insideInlineFun = function?.modifierList?.let {
|
||||
it.hasModifier(KtTokens.INLINE_KEYWORD) && !function.isPrivate()
|
||||
} ?: false
|
||||
if (insideInlineFun) {
|
||||
otherUsageFound = true
|
||||
false
|
||||
}
|
||||
else {
|
||||
inClassUsageFound = true
|
||||
true
|
||||
}
|
||||
}
|
||||
})
|
||||
return inClassUsageFound && !otherUsageFound
|
||||
|
||||
+9
@@ -107,4 +107,13 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Function 'f2' can be private</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>135</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Property 'bar' can be private</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
@@ -126,4 +126,12 @@ val x = object {
|
||||
f3()
|
||||
f4()
|
||||
}
|
||||
}
|
||||
|
||||
class F(val bar: Int) {
|
||||
inline fun baz() = bar
|
||||
}
|
||||
|
||||
class G(val bar: Int) {
|
||||
private inline fun baz() = bar
|
||||
}
|
||||
Reference in New Issue
Block a user