Wrong diagnostic when last expression in lambda contains assignment operation

#KT-6769 Fixed
This commit is contained in:
Stanislav Erokhin
2015-02-26 22:50:55 +03:00
parent 09435ad0e3
commit 602689892e
8 changed files with 76 additions and 1 deletions
@@ -0,0 +1,16 @@
fun test(bal: Array<Int>) {
var bar = 4
val a = { bar += 4 }
a : () -> Unit
val b = { bar = 4 }
b : () -> Unit
val c = { bal[2] = 3 }
c : () -> Unit
val d = run { bar += 4 }
d : Unit
}
fun <T> run(f: () -> T): T = f()
@@ -0,0 +1,4 @@
package
internal fun </*0*/ T> run(/*0*/ f: () -> T): T
internal fun test(/*0*/ bal: kotlin.Array<kotlin.Int>): kotlin.Unit
@@ -0,0 +1,16 @@
fun test(bal: Array<Int>) {
var bar = 4
val <!UNUSED_VARIABLE!>a<!>: () -> Unit = { bar += 4 }
val <!UNUSED_VARIABLE!>b<!>: () -> Int = { <!EXPECTED_TYPE_MISMATCH!>bar = 4<!> }
val <!UNUSED_VARIABLE!>c<!>: () -> <!UNRESOLVED_REFERENCE!>UNRESOLVED<!> = { bal[2] = 3 }
val <!UNUSED_VARIABLE!>d<!>: () -> Int = { <!ASSIGNMENT_TYPE_MISMATCH(kotlin.Int)!>bar += 4<!> }
val <!UNUSED_VARIABLE!>e<!>: Unit = run { bar += 4 }
val <!UNUSED_VARIABLE!>f<!>: Int = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>run<!> { bar += 4 }
}
fun <T> run(f: () -> T): T = f()
@@ -0,0 +1,4 @@
package
internal fun </*0*/ T> run(/*0*/ f: () -> T): T
internal fun test(/*0*/ bal: kotlin.Array<kotlin.Int>): kotlin.Unit
@@ -0,0 +1,11 @@
fun main(args : Array<String>) {
var list = listOf(1)
val a: Int? = 2
a?.let { list += it }
}
fun <T : Any, R> T.let(f: (T) -> R): R = f(this)
fun <T> Iterable<T>.plus(<!UNUSED_PARAMETER!>element<!>: T): List<T> = null!!
fun listOf<T>(vararg <!UNUSED_PARAMETER!>values<!>: T): List<T> = null!!
@@ -0,0 +1,6 @@
package
internal fun </*0*/ T> listOf(/*0*/ vararg values: T /*kotlin.Array<out T>*/): kotlin.List<T>
internal fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit
internal fun </*0*/ T : kotlin.Any, /*1*/ R> T.let(/*0*/ f: (T) -> R): R
internal fun </*0*/ T> kotlin.Iterable<T>.plus(/*0*/ element: T): kotlin.List<T>