mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-12 08:31:28 +00:00
- update diagnostic to (supposedly) more useful - also report IMPLICIT_CAST_TO_ANY if expected type is DONT_CARE (effectively "no expected type" for lambda expression).
22 lines
610 B
Kotlin
Vendored
22 lines
610 B
Kotlin
Vendored
var longWords = 0
|
|
val smallWords = hashSetOf<String>()
|
|
|
|
fun test1(word: String) =
|
|
run {
|
|
if (word.length > 4) {
|
|
<!IMPLICIT_CAST_TO_ANY!>longWords++<!>
|
|
}
|
|
else {
|
|
<!IMPLICIT_CAST_TO_ANY!>smallWords.add(word)<!>
|
|
}
|
|
}
|
|
|
|
fun test2(word: String) =
|
|
run {
|
|
if (word.length > 4) {
|
|
<!INVALID_IF_AS_EXPRESSION, IMPLICIT_CAST_TO_ANY!>if (word.startsWith("a")) longWords++<!>
|
|
}
|
|
else {
|
|
<!IMPLICIT_CAST_TO_ANY!>smallWords.add(word)<!>
|
|
}
|
|
} |