with this code ```val webRootDirectory = Paths.get...
# intellij
c
with this code
Copy code
val webRootDirectory = Paths.get("src", "main", "resources", "web").toAbsolutePath()
idea complains “declaration has type inferred from a platform call which can lead to unchecked nullability issue” when i add a
!!
, it instead complains “unnecessary non null assertion (!!) on a non null receiver of type path”
s
I usually specify the type on the variable to get rid of the platform type
c
that fixes it but its more verbose. also the behavior is probably a bug
m
Both of Idea's complaints are warnings to indicate there is something you should pay attention to. If you're happy with it, then you can either Suppress the warning to clearly indicate to others that you've thought about it, and are ok with it, ignore it, or as suggested, explicitly put the type. Yes, it's more verbose, BUT it's also very clear to others, and the compiler, what you expect to happen. Less code isn't always a good thing, and I'm slowly changing my perspective on 'put type as little as possible'. If you ALWAYS use IDEA to read your code, and have type hints on, then they're unnecessary. But if you're reviewing code in a text editor, or on GitHub/GitLab/Bitbucket etc, then you're left guessing at the types.
a
Thank you, created https://youtrack.jetbrains.com/issue/KT-38513. A workaround for this particular case is to specify the type of the variable explicitly.
c
thank you. thats what i did.