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

31 lines
912 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
// NI_EXPECTED_FILE
// See KT-10244: no intersection types in signatures
open class B
interface A
interface C
// Error!
fun <!IMPLICIT_INTERSECTION_TYPE{OI}!>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) <!DEBUG_INFO_SMARTCAST!>b<!> else null
class My(b: B) {
// Error!
val <!IMPLICIT_INTERSECTION_TYPE{OI}!>x<!> = if (b is A && b is C) b else null
// Ok: given explicitly
val y: C? = if (b is A && b is C) <!DEBUG_INFO_SMARTCAST!>b<!> else null
// Error!
fun <!IMPLICIT_INTERSECTION_TYPE{OI}!>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 <!IMPLICIT_INTERSECTION_TYPE{OI}!>foo<!>(b: B) = if (b is A && b is C) b else null
return tmp.toString()
}