"Make open": Fix false positive for data class inheritance #KT-27354 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
6d73aa29e0
commit
5e7d974767
@@ -156,7 +156,7 @@ open class AddModifierFix(
|
|||||||
val classDescriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return null
|
val classDescriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return null
|
||||||
val declaration = DescriptorToSourceUtils.descriptorToDeclaration(classDescriptor) as? KtClass ?: return null
|
val declaration = DescriptorToSourceUtils.descriptorToDeclaration(classDescriptor) as? KtClass ?: return null
|
||||||
if (!declaration.canRefactor()) return null
|
if (!declaration.canRefactor()) return null
|
||||||
if (declaration.isEnum()) return null
|
if (declaration.isEnum() || declaration.isData()) return null
|
||||||
return AddModifierFix(declaration, KtTokens.OPEN_KEYWORD)
|
return AddModifierFix(declaration, KtTokens.OPEN_KEYWORD)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// "Make 'A' open" "false"
|
||||||
|
// ERROR: This type is final, so it cannot be inherited from
|
||||||
|
// ACTION: Add names to call arguments
|
||||||
|
// ACTION: Do not show hints for current method
|
||||||
|
data class A(val x: Int)
|
||||||
|
class B: A<caret>(42)
|
||||||
@@ -7960,6 +7960,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/modifiers/addOpenToClassDeclaration"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/modifiers/addOpenToClassDeclaration"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("dataSuperType.kt")
|
||||||
|
public void testDataSuperType() throws Exception {
|
||||||
|
runTest("idea/testData/quickfix/modifiers/addOpenToClassDeclaration/dataSuperType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("enumSupertype.kt")
|
@TestMetadata("enumSupertype.kt")
|
||||||
public void testEnumSupertype() throws Exception {
|
public void testEnumSupertype() throws Exception {
|
||||||
runTest("idea/testData/quickfix/modifiers/addOpenToClassDeclaration/enumSupertype.kt");
|
runTest("idea/testData/quickfix/modifiers/addOpenToClassDeclaration/enumSupertype.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user