Unused symbol inspection: properties declared in primary constructor are now checked on 'Used' annotations #KT-11120 Fixed
This commit is contained in:
@@ -74,10 +74,11 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
val lightElement: PsiElement? = when (declaration) {
|
||||
is KtClassOrObject -> declaration.toLightClass()
|
||||
is KtNamedFunction, is KtSecondaryConstructor -> LightClassUtil.getLightClassMethod(declaration as KtFunction)
|
||||
is KtProperty -> {
|
||||
is KtProperty, is KtParameter -> {
|
||||
if (declaration is KtParameter && !declaration.hasValOrVar()) return false
|
||||
// can't rely on light element, check annotation ourselves
|
||||
val descriptor = declaration.descriptor ?: return false
|
||||
val entryPointsManager = EntryPointsManager.getInstance(declaration.getProject()) as EntryPointsManagerBase
|
||||
val entryPointsManager = EntryPointsManager.getInstance(declaration.project) as EntryPointsManagerBase
|
||||
return checkAnnotatedUsingPatterns(
|
||||
descriptor,
|
||||
entryPointsManager.additionalAnnotations + entryPointsManager.ADDITIONAL_ANNOTATIONS
|
||||
|
||||
@@ -25,4 +25,13 @@
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unused Symbol</problem_class>
|
||||
<description>Property 'unused' is never used</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>unusedButEntryPointAnnotated.kt</file>
|
||||
<line>4</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/unusedButEntryPointAnnotated.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unused symbol</problem_class>
|
||||
<description>Class 'Owner' is never used</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
+5
-1
@@ -1,2 +1,6 @@
|
||||
@test.anno.EntryPoint
|
||||
val entryPoint = ""
|
||||
val entryPoint = ""
|
||||
|
||||
class Owner(@test.anno.EntryPoint val xx: Int) {
|
||||
@test.anno.EntryPoint val yy = 42
|
||||
}
|
||||
Reference in New Issue
Block a user