https://kotlinlang.org logo
#announcements
Title
# announcements
t

tipsy

09/13/2019, 9:53 PM
i have a line:
if (header?.startsWith("Basic ") != true) throw Exception
. intellij is suggesting i replace this with
require(header?.startsWith("Basic ") == true)
, but if i do that,
header
is no longer smart cast
w

wasyl

09/13/2019, 9:59 PM
🤔 For me in the first case
header
is not smart cast to
String
either. Is that what you meant by smart cast?
image.png
Hm, nevermind. It is smartcast, but the hint is wrong. When I write e.g.
header[0]
it works. Anyway, it seems like it should be possible to infer nullability in this case. The quick fix shouldn’t change the semantics, though
k

karelpeeters

09/14/2019, 7:33 AM
Either it's a compiler bug or a quickfix bug, report an youtrack and let them sort it out simple smile
2 Views