Files
kotlin/compiler/testData/codegen/java8/box/removeIf.kt
Denis Zharkov 5bc5722051 Load additional JDK functions into built-ins member scope
#KT-5990 Fixed
 #KT-7127 Fixed
 #KT-10370 Fixed
2016-04-25 17:41:08 +03:00

34 lines
839 B
Kotlin
Vendored

// FULL_JDK
// WITH_RUNTIME
import java.util.*
import java.util.function.Predicate
class MyList : AbstractCollection<String>(), MutableCollection<String> {
override fun iterator(): MutableIterator<String> {
throw UnsupportedOperationException()
}
override val size: Int
get() = throw UnsupportedOperationException()
override fun removeIf(predicate: Predicate<in String>) =
predicate.test("abc")
}
fun box(): String {
val ml = mutableListOf("xyz", "abc")
if (!ml.removeIf { x -> x == "abc" }) return "fail 1"
if (ml.removeIf { x -> x == "abc" }) return "fail 2"
if (ml != listOf("xyz")) return "fail 3"
val myList = MyList()
if (!myList.removeIf { x -> x == "abc" }) return "fail 4"
if (myList.removeIf { x -> x == "xyz" }) return "fail 5"
return "OK"
}