Files
kotlin-fork/compiler/testData/diagnostics/tests/generics/nullability/smartCasts.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

47 lines
1.1 KiB
Kotlin
Vendored

// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_EXPRESSION,-UNUSED_VARIABLE
fun <T : CharSequence?> T.bar1() {}
fun CharSequence?.bar2() {}
fun <T : CharSequence> T.bar3() {}
fun CharSequence.bar4() {}
fun <T : CharSequence?> foo(x: T) {
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
<!DEBUG_INFO_SMARTCAST!>x<!>.length
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
<!DEBUG_INFO_SMARTCAST{NI}!>x<!>.bar1()
x.bar2()
<!DEBUG_INFO_SMARTCAST{NI}!>x<!>.<!TYPE_INFERENCE_UPPER_BOUND_VIOLATED{OI}!>bar3<!>()
<!DEBUG_INFO_SMARTCAST!>x<!>.bar4()
x<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
}
x<!UNSAFE_CALL!>.<!>length
if (x is String) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
<!DEBUG_INFO_SMARTCAST{NI}!>x<!>.bar1()
x.bar2()
<!DEBUG_INFO_SMARTCAST!>x<!>.bar3()
}
if (x is CharSequence) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
<!DEBUG_INFO_SMARTCAST{NI}!>x<!>.bar1()
x.bar2()
<!DEBUG_INFO_SMARTCAST!>x<!>.bar3()
}
}