[Test] Operator ambiguity check with 'set'

When using `x[y] += z` the spec mandates attempting all possible combinations.

^KT-62138 Fixed
This commit is contained in:
Alejandro Serrano Mena
2023-10-02 11:24:42 +02:00
committed by Space Team
parent 5b7b159d64
commit c2dfe415f3
7 changed files with 82 additions and 0 deletions
@@ -0,0 +1,22 @@
// FIR_IDENTICAL
// ISSUE: KT-62138
class HashMap<K, V>(
private val defaultValue: V
) {
operator fun get(key: K): V = defaultValue
operator fun set(key: K, value: V) { }
}
private class X
private operator fun X?.plus(p: Int) = X()
private operator fun X?.plusAssign(p: Int) { }
class C {
private val map = HashMap<String, X>(defaultValue = X())
fun f(): Any? {
map[""] <!ASSIGN_OPERATOR_AMBIGUITY!>+=<!> 1
return map[""]
}
}