Conflicting extension is recognized as redundant for setter with expression body
This commit is contained in:
+7
-3
@@ -129,9 +129,13 @@ public class ConflictingExtensionPropertyInspection : AbstractKotlinInspection()
|
||||
|
||||
private fun checkSetterBodyIsSetMethodCall(setter: JetPropertyAccessor, setMethod: FunctionDescriptor): Boolean {
|
||||
val valueParameterName = setter.valueParameters.singleOrNull()?.nameAsName ?: return false
|
||||
if (!setter.hasBlockBody()) return false
|
||||
val statement = (setter.bodyExpression as? JetBlockExpression)?.statements?.singleOrNull() ?: return false
|
||||
return statement.isSetMethodCall(setMethod, valueParameterName)
|
||||
if (setter.hasBlockBody()) {
|
||||
val statement = (setter.bodyExpression as? JetBlockExpression)?.statements?.singleOrNull() ?: return false
|
||||
return statement.isSetMethodCall(setMethod, valueParameterName)
|
||||
}
|
||||
else {
|
||||
return setter.bodyExpression.isSetMethodCall(setMethod, valueParameterName)
|
||||
}
|
||||
}
|
||||
|
||||
private fun JetExpression?.isGetMethodCall(getMethod: FunctionDescriptor): Boolean {
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// "Delete redundant extension property" "true"
|
||||
|
||||
var Thread.<caret>priority: Int
|
||||
get() = getPriority()
|
||||
set(value) = setPriority(value)
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// "Delete redundant extension property" "true"
|
||||
|
||||
@@ -3955,6 +3955,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("setterWithExpressionBody.kt")
|
||||
public void testSetterWithExpressionBody() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/conflictingExtension/setterWithExpressionBody.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/conflictingExtension/simple.kt");
|
||||
|
||||
Reference in New Issue
Block a user