Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.kt
T
Dmitriy Novozhilov e6b5cb5216 [TD] Update diagnostics test data due to new test runners
Update includes:
- Changing syntax of `OI/`NI` tags from `<!NI;TAG!>` to `<!TAG{NI}!>`
- Fix some incorrect directives
- Change order of diagnostics in some places
- Remove ignored diagnostics from FIR test data (previously `DIAGNOSTICS` didn't work)
- Update FIR dumps in some places and add `FIR_IDENTICAL` if needed
- Replace all JAVAC_SKIP with SKIP_JAVAC directive
2020-12-16 19:52:25 +03:00

35 lines
868 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
var longWords = 0
val smallWords = hashSetOf<String>()
fun test1(word: String) =
run {
if (word.length > 4) {
<!IMPLICIT_CAST_TO_ANY{OI}!>longWords++<!>
}
else {
<!IMPLICIT_CAST_TO_ANY{OI}!>smallWords.add(word)<!>
}
}
fun test2(word: String) =
run {
if (word.length > 4) {
<!INVALID_IF_AS_EXPRESSION!>if<!> (word.startsWith("a")) <!IMPLICIT_CAST_TO_ANY{OI}!>longWords++<!>
}
else {
<!IMPLICIT_CAST_TO_ANY{OI}!>smallWords.add(word)<!>
}
}
fun test3(word: String) =
run {
if (word.length > 4) {
longWords++
}
else {
System.out?.println(word) // Unit?
}
}