"Convert to anonymous object" quickfix: false negative when interface has concrete members

#KT-37908 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-04-01 12:49:46 +09:00
committed by Yan Zhulanow
parent 5b927d798c
commit 111b2945e1
7 changed files with 87 additions and 2 deletions
@@ -0,0 +1,11 @@
// "Convert to anonymous object" "true"
interface I {
fun a()
fun b() {}
}
fun foo(i: I) {}
fun test() {
foo(<caret>I {})
}
@@ -0,0 +1,15 @@
// "Convert to anonymous object" "true"
interface I {
fun a()
fun b() {}
}
fun foo(i: I) {}
fun test() {
foo(object : I {
override fun a() {
}
})
}
@@ -0,0 +1,12 @@
// "Convert to anonymous object" "true"
interface I {
fun a()
val b: Int
get() = 1
}
fun foo(i: I) {}
fun test() {
foo(<caret>I {})
}
@@ -0,0 +1,16 @@
// "Convert to anonymous object" "true"
interface I {
fun a()
val b: Int
get() = 1
}
fun foo(i: I) {}
fun test() {
foo(object : I {
override fun a() {
}
})
}
@@ -0,0 +1,11 @@
// "Convert to anonymous object" "false"
// ERROR: Interface I does not have constructors
// ACTION: Introduce import alias
// ACTION: Split property declaration
interface I {
fun <T> foo(): String
}
fun test() {
val i = <caret>I { "" }
}