Implement members: don't add 'actual' modifier for fake overrides
#KT-25044 Fixed
This commit is contained in:
+7
-2
@@ -122,8 +122,13 @@ fun OverrideMemberChooserObject.generateMember(targetClass: KtClassOrObject, cop
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (targetClass.hasActualModifier()) {
|
if (targetClass.hasActualModifier()) {
|
||||||
val expectClassDescriptors = targetClass.resolveToDescriptorIfAny()?.expectedDescriptors() ?: emptyList()
|
val expectClassDescriptors =
|
||||||
if (expectClassDescriptors.any { (it as? ClassDescriptor)?.findCallableMemberBySignature(immediateSuper)?.isExpect == true }) {
|
targetClass.resolveToDescriptorIfAny()?.expectedDescriptors()?.filterIsInstance<ClassDescriptor>().orEmpty()
|
||||||
|
if (expectClassDescriptors.any { expectClassDescriptor ->
|
||||||
|
val expectMemberDescriptor = expectClassDescriptor.findCallableMemberBySignature(immediateSuper)
|
||||||
|
expectMemberDescriptor?.isExpect == true && expectMemberDescriptor.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE
|
||||||
|
}
|
||||||
|
) {
|
||||||
newMember.addModifier(KtTokens.ACTUAL_KEYWORD)
|
newMember.addModifier(KtTokens.ACTUAL_KEYWORD)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
expect interface ExpInterface {
|
||||||
|
fun first()
|
||||||
|
}
|
||||||
|
|
||||||
|
expect class ExpImpl : ExpInterface { }
|
||||||
idea/testData/multiModuleQuickFix/implementMembersInActualClassNoExpectMember/common/common.kt.after
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
expect interface ExpInterface {
|
||||||
|
fun first()
|
||||||
|
}
|
||||||
|
|
||||||
|
expect class ExpImpl : ExpInterface { }
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// "Implement members" "true"
|
||||||
|
// ERROR: Class 'ExpImpl' is not abstract and does not implement abstract member public abstract actual fun first(): Unit defined in ExpInterface
|
||||||
|
|
||||||
|
actual interface ExpInterface {
|
||||||
|
actual fun first()
|
||||||
|
}
|
||||||
|
|
||||||
|
actual class ExpImpl<caret> : ExpInterface
|
||||||
Vendored
+12
@@ -0,0 +1,12 @@
|
|||||||
|
// "Implement members" "true"
|
||||||
|
// ERROR: Class 'ExpImpl' is not abstract and does not implement abstract member public abstract actual fun first(): Unit defined in ExpInterface
|
||||||
|
|
||||||
|
actual interface ExpInterface {
|
||||||
|
actual fun first()
|
||||||
|
}
|
||||||
|
|
||||||
|
actual class ExpImpl : ExpInterface {
|
||||||
|
override fun first() {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -229,6 +229,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
|
|||||||
runTest("idea/testData/multiModuleQuickFix/implementAbstractExpectMemberInheritedFromInterface/");
|
runTest("idea/testData/multiModuleQuickFix/implementAbstractExpectMemberInheritedFromInterface/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("implementMembersInActualClassNoExpectMember")
|
||||||
|
public void testImplementMembersInActualClassNoExpectMember() throws Exception {
|
||||||
|
runTest("idea/testData/multiModuleQuickFix/implementMembersInActualClassNoExpectMember/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("implementMembersInImplClassNonImplInheritor")
|
@TestMetadata("implementMembersInImplClassNonImplInheritor")
|
||||||
public void testImplementMembersInImplClassNonImplInheritor() throws Exception {
|
public void testImplementMembersInImplClassNonImplInheritor() throws Exception {
|
||||||
runTest("idea/testData/multiModuleQuickFix/implementMembersInImplClassNonImplInheritor/");
|
runTest("idea/testData/multiModuleQuickFix/implementMembersInImplClassNonImplInheritor/");
|
||||||
|
|||||||
Reference in New Issue
Block a user