Introduce plusElement and minusElement to disambiguate situations like List<List<T>> + List<T>
#KT-9992 Fixed
This commit is contained in:
@@ -247,6 +247,18 @@ class CollectionTest {
|
||||
assertEquals(listOf("foo", "bar", "cheese", "wine"), list)
|
||||
}
|
||||
|
||||
@test fun plusCollectionInference() {
|
||||
val listOfLists = listOf(listOf("s"))
|
||||
val elementList = listOf("a")
|
||||
val result: List<List<String>> = listOfLists.plusElement(elementList)
|
||||
assertEquals(listOf(listOf("s"), listOf("a")), result, "should be list + element")
|
||||
|
||||
val listOfAny = listOf<Any>("a") + listOf<Any>("b")
|
||||
assertEquals(listOf("a", "b"), listOfAny, "should be list + list")
|
||||
|
||||
val listOfAnyAndList = listOf<Any>("a") + listOf<Any>("b") as Any
|
||||
assertEquals(listOf("a", listOf("b")), listOfAnyAndList, "should be list + Any")
|
||||
}
|
||||
|
||||
@test fun plusAssign() {
|
||||
// lets use a mutable variable of readonly list
|
||||
|
||||
Reference in New Issue
Block a user