Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/varnotnull/boundInitializerWrong.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
900 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
// KT-15792 and related
fun foo() {
var x: String? = ""
val y = x
x = null
if (y != null) {
<!DEBUG_INFO_CONSTANT{OI}!>x<!><!UNSAFE_CALL!>.<!>hashCode()
}
}
fun foo2() {
var x: String? = ""
val y = x
if (y != null) {
x<!UNSAFE_CALL!>.<!>hashCode()
}
}
fun bar(s: String?) {
var ss = s
val hashCode = ss?.hashCode()
ss = null
if (hashCode != null) {
<!DEBUG_INFO_CONSTANT{OI}!>ss<!><!UNSAFE_CALL!>.<!>hashCode()
}
}
fun bar2(s: String?) {
var ss = s
val hashCode = ss?.hashCode()
if (hashCode != null) {
ss<!UNSAFE_CALL!>.<!>hashCode()
}
}
class Some(var s: String?)
fun baz(arg: Some?) {
val ss = arg?.s
if (ss != null) {
<!DEBUG_INFO_SMARTCAST!>arg<!>.hashCode()
<!SMARTCAST_IMPOSSIBLE!><!DEBUG_INFO_SMARTCAST!>arg<!>.s<!>.hashCode()
}
}