My brain is fried, I don't understand this, anyone...
# announcements
v
My brain is fried, I don't understand this, anyone a quick helping hand?
Unnecessary safe call on a non-null receiver of type Int?
Why is
Int?
non-null? Why is it wrong to use
?.
on it?
n
Are you able to show/isolate the code responsible? Off the cuff, it seems strange.
v
This is the line where it is shown:
Copy code
val buildId = buildId.get()?.let { "=$it" } ?: ""
Where the
get()
returns an
Int?
Hm, and if I remove the
?
it says the opposite,
Unsafe use of a nullable receiver of type Int?
Wtf. I think I'm just going to blame a drunk IntelliJ
n
is this an error from actually compiling or just the IDE?
probably not related but maybe try changing the varialbe name?
j
You have buildId on both the left and right hand side and declaring it as a val. Where's the original definition?
n
maybe the shadowing isconfusing the IDE
v
I know that I have it on left and right side, one is property of the class, the other a local variable 😉
And changing the variable name is not changing anything as expected
The error is in the IDE btw. didn't try to compile yet as I wondered about the message
n
seems like an IDE bug. might be nice to report to the jetbrains team if you can reasonably reproduce without dragging in tons of code. If you have a small repro in your IDE, I'd be cruiosu to paste it into mine and seein'g if i see the same message
v
Hm, maybe IJ is just too intelligent this time. Actually
get()
will never return
null
but throw an exception instead, so even though the type is
Int?
there will never be
null
returned
Anyway, no time to build a repro right now, maybe later
n
interesting