991d8c18aa
Also remove incorrect subtype check checkers Test unsafeVarianceInAliasedFunctionalType.kt started to fail because of KT-54894. This bug existed before, changes from this commit just unhided it (previously it was hidden because incorrect subtype check in `isSubtypeForTypeMismatch` which is used by FirFunctionReturnTypeMismatchChecker
29 lines
660 B
Kotlin
Vendored
29 lines
660 B
Kotlin
Vendored
//KT-352 Function variable declaration type isn't checked inside a function body
|
|
|
|
package kt352
|
|
|
|
val f : (Any) -> Unit = <!INITIALIZER_TYPE_MISMATCH!>{ -> }<!> //type mismatch
|
|
|
|
fun foo() {
|
|
val f : (Any) -> Unit = <!INITIALIZER_TYPE_MISMATCH!>{ -> }<!> //!!! no error
|
|
}
|
|
|
|
class A() {
|
|
val f : (Any) -> Unit = <!INITIALIZER_TYPE_MISMATCH!>{ -> }<!> //type mismatch
|
|
}
|
|
|
|
//more tests
|
|
val g : () -> Unit = { 42 }
|
|
val gFunction : () -> Unit = <!INITIALIZER_TYPE_MISMATCH!>fun(): Int = 1<!>
|
|
|
|
val h : () -> Unit = { doSmth() }
|
|
|
|
fun doSmth(): Int = 42
|
|
fun doSmth(a: String) {}
|
|
|
|
val testIt : (Any) -> Unit = {
|
|
if (it is String) {
|
|
doSmth(it)
|
|
}
|
|
}
|