KT-352 Function variable declaration type isn't checked inside a function body
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
//KT-352 Function variable declaration type isn't checked inside a function body
|
||||
|
||||
namespace kt352
|
||||
|
||||
val f : fun(Any) : Unit = <!TYPE_MISMATCH!>{ () : Unit => }<!> //type mismatch
|
||||
|
||||
fun foo() {
|
||||
val f : fun(Any) : Unit = <!TYPE_MISMATCH!>{ () : Unit => }<!> //!!! no error
|
||||
}
|
||||
|
||||
class A() {
|
||||
val f : fun(Any) : Unit = <!TYPE_MISMATCH!>{ () : Unit => }<!> //type mismatch
|
||||
}
|
||||
|
||||
//more tests
|
||||
val g : fun() : Unit = <!TYPE_MISMATCH!>{ (): Int => 42 }<!>
|
||||
|
||||
val h : fun() : Unit = { doSmth() }
|
||||
|
||||
fun doSmth(): Int = 42
|
||||
fun doSmth(a: String) {}
|
||||
|
||||
val testIt : fun(Any) : Unit = {
|
||||
if (it is String) {
|
||||
doSmth(it)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user