Files
kotlin/compiler/testData/diagnostics/tests/implicitIntersection.kt
Dmitry Savvinov 33f9576dd1 [NI] Turn off KnownTypeParameterSubstitutor for NI
The main consequence of it is that TYPE_MISMATCH range for control
structures became wider.

Also, for extra safety, don't change behaviour of OI.
2017-12-07 14:05:42 +03:00

30 lines
913 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 <!OI;IMPLICIT_INTERSECTION_TYPE!>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) <!OI;DEBUG_INFO_SMARTCAST!>b<!> else null
class My(b: B) {
// Error!
val <!OI;IMPLICIT_INTERSECTION_TYPE!>x<!> = if (b is A && b is C) b else null
// Ok: given explicitly
val y: C? = if (b is A && b is C) <!OI;DEBUG_INFO_SMARTCAST!>b<!> else null
// Error!
fun <!OI;IMPLICIT_INTERSECTION_TYPE!>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 <!OI;IMPLICIT_INTERSECTION_TYPE!>foo<!>(b: B) = if (b is A && b is C) b else null
return tmp.toString()
}