Unused symbol: fix false positives on inline class constructors
#KT-27434 Fixed
This commit is contained in:
@@ -327,11 +327,10 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
private fun KtCallableDeclaration.canBeHandledByLightMethods(descriptor: DeclarationDescriptor?): Boolean {
|
||||
return when {
|
||||
hasModifier(KtTokens.INTERNAL_KEYWORD) -> false
|
||||
this !is KtNamedFunction -> true
|
||||
descriptor !is FunctionDescriptor -> true
|
||||
descriptor is ConstructorDescriptor -> !descriptor.constructedClass.isInline
|
||||
else -> !descriptor.hasInlineClassParameters()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun FunctionDescriptor.hasInlineClassParameters(): Boolean {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
|
||||
inline class InlineClass(val x: Int) {
|
||||
<caret>constructor() : this(42)
|
||||
}
|
||||
|
||||
val call = InlineClass()
|
||||
+5
@@ -6613,6 +6613,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
runTest("idea/testData/inspectionsLocal/unusedSymbol/inAnonymousRunWrapped.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassConstructor.kt")
|
||||
public void testInlineClassConstructor() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/unusedSymbol/inlineClassConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassMemberFunction.kt")
|
||||
public void testInlineClassMemberFunction() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/unusedSymbol/inlineClassMemberFunction.kt");
|
||||
|
||||
Reference in New Issue
Block a user