Report resolution ambiguity on '+=' by taking into account full resolution result including post type checking for '+'

^KT-45503 Fixed
This commit is contained in:
Victor Petukhov
2021-03-26 20:25:01 +03:00
parent 1da35029a6
commit 5d78b0a962
42 changed files with 279 additions and 354 deletions
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// WITH_RUNTIME
// SKIP_TXT
class A<T>
class B<T>(val x: MutableList<T>) : MutableList<T> by x
class C {
operator fun <T> get(k: A<T>): T = TODO()
operator fun <T> set(k: A<T>, v: T): Unit = TODO()
}
fun foo() {
C()[A<B<Int>>()] += 2
}
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// WITH_RUNTIME
// SKIP_TXT
class A<T>
class B<T>(val x: MutableList<T>) : MutableList<T> by x
class C {
operator fun <T> get(k: A<T>): T = TODO()
operator fun <T> set(k: A<T>, v: T): Unit = TODO()
}
fun foo() {
C()[A<B<Int>>()] += 2
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
// SKIP_TXT
class A<T>(var x: T)
interface I
class C {
operator fun <T> get(k: A<T>): T = k.x
operator fun <T : I> set(k: A<T>, v: T) { k.x = v }
}
fun foo() {
C()[A(mutableListOf(1))] += 2
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
// SKIP_TXT
class A<T>(var x: T)
interface I
class C {
operator fun <T> get(k: A<T>): T = k.x
operator fun <T : I> set(k: A<T>, v: T) { k.x = v }
}
fun foo() {
C()[A(mutableListOf(1))] += 2
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// WITH_RUNTIME
// SKIP_TXT
class A<T>
class C
interface I
class E {
operator fun <T> get(k: A<T>): T = TODO()
operator fun <T : I> set(k: A<T>, v: T) { TODO() }
operator fun set(k: A<C>, v: C) { TODO() }
}
fun foo() {
E()[A<MutableList<Int>>()] += 1
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// WITH_RUNTIME
// SKIP_TXT
class A<T>
class C
interface I
class E {
operator fun <T> get(k: A<T>): T = TODO()
operator fun <T : I> set(k: A<T>, v: T) { TODO() }
operator fun set(k: A<C>, v: C) { TODO() }
}
fun foo() {
E()[A<MutableList<Int>>()] += 1
}
@@ -0,0 +1,31 @@
// WITH_RUNTIME
fun test1() {
var list = ArrayList<Int>()
<!ASSIGN_OPERATOR_AMBIGUITY!>list -= 2<!>
}
fun test2() {
var set = HashMap<Int, Int>()
<!ASSIGN_OPERATOR_AMBIGUITY!>set += 2 to 2<!>
}
fun test3() {
var set = HashSet<Int>()
<!ASSIGN_OPERATOR_AMBIGUITY!>set -= 2<!>
}
fun test4() {
var list = mutableListOf(1)
<!ASSIGN_OPERATOR_AMBIGUITY!>list += 2<!>
}
fun test5() {
var map = mutableMapOf(1 to 1)
<!ASSIGN_OPERATOR_AMBIGUITY!>map += 2 to 2<!>
}
fun test6() {
var set = mutableSetOf(1)
<!ASSIGN_OPERATOR_AMBIGUITY!>set += 2<!>
}
@@ -0,0 +1,31 @@
// WITH_RUNTIME
fun test1() {
var list = ArrayList<Int>()
list -= 2
}
fun test2() {
var set = HashMap<Int, Int>()
set += 2 to 2
}
fun test3() {
var set = HashSet<Int>()
set -= 2
}
fun test4() {
var list = mutableListOf(1)
list += 2
}
fun test5() {
var map = mutableMapOf(1 to 1)
map += 2 to 2
}
fun test6() {
var set = mutableSetOf(1)
set += 2
}
@@ -0,0 +1,9 @@
package
public fun test1(): kotlin.Unit
public fun test2(): kotlin.Unit
public fun test3(): kotlin.Unit
public fun test4(): kotlin.Unit
public fun test5(): kotlin.Unit
public fun test6(): kotlin.Unit