Add function supertype: make abstract function in sealed class
#KT-30769 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
f2c7b6b8c4
commit
bf5b559923
@@ -196,7 +196,11 @@ class AddFunctionToSupertypeFix private constructor(
|
||||
): FunctionDescriptor {
|
||||
// TODO: support for generics.
|
||||
|
||||
val modality = if (typeDescriptor.kind == ClassKind.INTERFACE) Modality.ABSTRACT else typeDescriptor.modality
|
||||
val modality = if (typeDescriptor.kind == ClassKind.INTERFACE || typeDescriptor.modality == Modality.SEALED) {
|
||||
Modality.ABSTRACT
|
||||
} else {
|
||||
typeDescriptor.modality
|
||||
}
|
||||
|
||||
return functionDescriptor.copy(
|
||||
typeDescriptor,
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// "Add 'abstract fun f()' to 'A'" "true"
|
||||
sealed class A {
|
||||
}
|
||||
class B : A() {
|
||||
<caret>override fun f() {}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// "Add 'abstract fun f()' to 'A'" "true"
|
||||
sealed class A {
|
||||
abstract fun f()
|
||||
}
|
||||
class B : A() {
|
||||
<caret>override fun f() {}
|
||||
}
|
||||
@@ -9286,6 +9286,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
runTest("idea/testData/quickfix/override/nothingToOverride/addFunctionNonUnitReturnType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addFunctionSealedClass.kt")
|
||||
public void testAddFunctionSealedClass() throws Exception {
|
||||
runTest("idea/testData/quickfix/override/nothingToOverride/addFunctionSealedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addFunctionTrait.kt")
|
||||
public void testAddFunctionTrait() throws Exception {
|
||||
runTest("idea/testData/quickfix/override/nothingToOverride/addFunctionTrait.kt");
|
||||
|
||||
Reference in New Issue
Block a user