Lift assignment: do not report in cases where argument are of different types #KT-21520 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
fcc6395b14
commit
0cd25353bc
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(b: Boolean, x: Int, y: Int?) {
|
||||
val list = mutableListOf<Int?>()
|
||||
<caret>if (b) {
|
||||
list += x
|
||||
} else {
|
||||
list += y
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(b: Boolean, x: Int, y: Int?) {
|
||||
val list = mutableListOf<Int?>()
|
||||
list += if (b) {
|
||||
x
|
||||
} else {
|
||||
y
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
fun test(b: Boolean, x: Long, y: Int) {
|
||||
var num: Long = 0L
|
||||
<caret>if (b) {
|
||||
num += x
|
||||
} else {
|
||||
num += y
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
// ERROR: Type mismatch: inferred type is Long? but Long was expected
|
||||
fun test(b: Boolean, x: Long, y: Long?) {
|
||||
var num: Long = 0L
|
||||
<caret>if (b) {
|
||||
num += x
|
||||
} else {
|
||||
num += y
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// PROBLEM: none
|
||||
class C {
|
||||
operator fun plusAssign(i: Int) {}
|
||||
operator fun plusAssign(b: Boolean) {}
|
||||
}
|
||||
|
||||
fun f(b: Boolean) {
|
||||
val c = C()
|
||||
<caret>if (b)
|
||||
c += 1
|
||||
else
|
||||
c += true
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun test(b: Boolean) {
|
||||
val list = mutableListOf<Int>()
|
||||
<caret>if (b) {
|
||||
list += 1
|
||||
} else {
|
||||
list += mutableListOf(2)
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// PROBLEM: none
|
||||
// ERROR: Type mismatch: inferred type is List<Any> but MutableList<Int> was expected
|
||||
// ERROR: Val cannot be reassigned
|
||||
// WITH_RUNTIME
|
||||
fun test(b: Boolean) {
|
||||
val list = mutableListOf<Int>()
|
||||
<caret>if (b) {
|
||||
list += mutableListOf(1)
|
||||
} else {
|
||||
list += mutableListOf(2L)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user