Consider this completely innocent piece of code:
var set = mutableSetOf<String>() set += "abd"
I get a compiler error:
Error: Kotlin: Assignment operators ambiguity:
public operator fun Set.plus(element: String): Set defined in kotlin.collections
@InlineOnly public inline operator fun MutableCollection.plusAssign(element: String): Unit defined in kotlin.collections
This seems silly; how can
+= ever be ambiguous? I clearly typed
+=! Also, while using
+ is legal in that position, it’s not an assignment operator!
How do I make sense of this compiler error and/or language feature?