KT-2883 Type inference fails due to non-Unit value returned
#KT-2883 fixed
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
//KT-2883 Type inference fails due to non-Unit value returned
|
||||
package a
|
||||
|
||||
public fun doAction(<!UNUSED_PARAMETER!>action<!> : () -> Unit){
|
||||
}
|
||||
|
||||
class Y<TItem>(val itemToString: (TItem) -> String){
|
||||
}
|
||||
|
||||
fun <TItem> bar(<!UNUSED_PARAMETER!>context<!> : Y<TItem>) : TItem{
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun foo(){
|
||||
val stringToString : (String) -> String = { it }
|
||||
doAction({bar(Y<String>(stringToString))})
|
||||
}
|
||||
|
||||
fun <T> bar(t: T): T = t
|
||||
|
||||
fun test() {
|
||||
|
||||
doAction { bar(12) }
|
||||
|
||||
val <!UNUSED_VARIABLE!>u<!>: Unit = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>bar<!>(11)
|
||||
}
|
||||
|
||||
fun testWithoutInference(col: MutableCollection<Int>) {
|
||||
|
||||
doAction { col.add(2) }
|
||||
|
||||
val <!UNUSED_VARIABLE!>u<!>: Unit = <!TYPE_MISMATCH!>col.add(2)<!>
|
||||
}
|
||||
Reference in New Issue
Block a user