Files
kotlin-fork/compiler/testData/diagnostics/tests/implicitIntersection.fir.kt
T
Denis.Zharkov 2ecba6ac39 Remove WITH_NEW_INFERENCE directive from all tests
This directive anyway does not make test run twice with OI, and with NI
It only once run the test with specific settings (// LANGUAGE)
and ignores irrelevant (OI or NI tags)
2021-05-25 13:28:26 +03:00

30 lines
687 B
Kotlin
Vendored

// NI_EXPECTED_FILE
// See KT-10244: no intersection types in signatures
open class B
interface A
interface C
// Error!
fun foo(b: B) = if (b is A && b is C) b else null
// Ok: given explicitly
fun gav(b: B): A? = if (b is A && b is C) b else null
class My(b: B) {
// Error!
val x = if (b is A && b is C) b else null
// Ok: given explicitly
val y: C? = if (b is A && b is C) b else null
// Error!
fun foo(b: B) = if (b is A && b is C) b else null
}
fun bar(b: B): String {
// Ok: local variable
val tmp = if (b is A && b is C) b else null
// Error: local function
fun foo(b: B) = if (b is A && b is C) b else null
return tmp.toString()
}