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.idea.refactoring.isConstructorDeclaredProperty
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isInheritable
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isOverridable
|
|
||||||
|
|
||||||
class MemberVisibilityCanPrivateInspection : AbstractKotlinInspection() {
|
class MemberVisibilityCanPrivateInspection : AbstractKotlinInspection() {
|
||||||
|
|
||||||
@@ -91,8 +88,18 @@ class MemberVisibilityCanPrivateInspection : AbstractKotlinInspection() {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
inClassUsageFound = true
|
val function = usage.getParentOfType<KtCallableDeclaration>(false)
|
||||||
true
|
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
|
return inClassUsageFound && !otherUsageFound
|
||||||
|
|||||||
+9
@@ -107,4 +107,13 @@
|
|||||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||||
<description>Function 'f2' can be private</description>
|
<description>Function 'f2' can be private</description>
|
||||||
</problem>
|
</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>
|
</problems>
|
||||||
|
|||||||
@@ -127,3 +127,11 @@ val x = object {
|
|||||||
f4()
|
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