[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:
committed by
Space Team
parent
5b7b159d64
commit
c2dfe415f3
Vendored
+22
@@ -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[""]
|
||||
}
|
||||
}
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
private operator fun X?.plus(/*0*/ p: kotlin.Int): X
|
||||
private operator fun X?.plusAssign(/*0*/ p: kotlin.Int): kotlin.Unit
|
||||
|
||||
public final class C {
|
||||
public constructor C()
|
||||
private final val map: HashMap<kotlin.String, X>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun f(): kotlin.Any?
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class HashMap</*0*/ K, /*1*/ V> {
|
||||
public constructor HashMap</*0*/ K, /*1*/ V>(/*0*/ defaultValue: V)
|
||||
private final val defaultValue: V
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final operator fun get(/*0*/ key: K): V
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final operator fun set(/*0*/ key: K, /*1*/ value: V): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
private final class X {
|
||||
public constructor X()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user