Correct handling of empty super type list while adding an entry #KT-12011 Fixed
This commit is contained in:
@@ -38,6 +38,10 @@ abstract class KtClassOrObject :
|
||||
|
||||
fun addSuperTypeListEntry(superTypeListEntry: KtSuperTypeListEntry): KtSuperTypeListEntry {
|
||||
getSuperTypeList()?.let {
|
||||
val single = it.entries.singleOrNull()
|
||||
if (single != null && single.typeReference?.typeElement == null) {
|
||||
return single.replace(superTypeListEntry) as KtSuperTypeListEntry
|
||||
}
|
||||
return EditCommaSeparatedListHelper.addItem(it, getSuperTypeListEntries(), superTypeListEntry)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Let the anonymous object implement interface 'Runnable'" "true"
|
||||
|
||||
fun foo(r: Runnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object: {})
|
||||
}
|
||||
|
||||
interface Runnable
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Let the anonymous object implement interface 'Runnable'" "true"
|
||||
|
||||
fun foo(r: Runnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo(object: Runnable {})
|
||||
}
|
||||
|
||||
interface Runnable
|
||||
@@ -7654,6 +7654,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("letObjectLiteralImplementInterface.kt")
|
||||
public void testLetObjectLiteralImplementInterface() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/letObjectLiteralImplementInterface.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("letStringImplementInterface.kt")
|
||||
public void testLetStringImplementInterface() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/letStringImplementInterface.kt");
|
||||
|
||||
Reference in New Issue
Block a user