Files
kotlin-fork/compiler/testData/diagnostics/tests/operatorsOverloading/AssignOperatorAmbiguityExtension.kt
T
Alejandro Serrano Mena c2dfe415f3 [Test] Operator ambiguity check with 'set'
When using `x[y] += z` the spec mandates attempting all possible combinations.

^KT-62138 Fixed
2023-10-03 08:23:29 +00:00

22 lines
469 B
Kotlin
Vendored

// 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[""]
}
}