Can anyone explain what this type hint in intellij...
# intellij
k
Can anyone explain what this type hint in intellij means?
m
I'm guessing that
phoneNumber
is a nullable range of strings. That would not be what I would expect the type of a phoneNumber variable to be.
k
Also this is interoping with java code that should just be a string
m
String
implements
Comparable
so you can have a
ClosedRange<String>
. But I just created a range of strings and I don't get that in the type hint. So I'm at a lost on what it would mean
k
This is the declaration of
phone_number
.
I wonder if this is an IDE bug?
m
It cold be indicating that it is nullable or not nulable, but I would have thought that would be
String!
. Seems like a bug
k
yeah I agree. If it can’t figure out nullability, it should be a platform type
k
This seems to be a change made in 2021.3. For example, I have a statement like this (using slf4j):
Copy code
val logger = LoggerFactory.getLogger(...)
The older release, 2021.2.x, shows the type hint as
Logger!
whereas the new release shows it as
(Logger..Logger?)
.
k
Very strange way to denote platform types. It’s extra confusing because this conflates the syntax for ranges with nullability.
k
I suppose it's meant to be a clever way of saying "the type of this variable ranges from X to nullable X". But it's not easy to parse visually/mentally. I prefer the old way. Also, it's inconsistent with other ways of getting hints, e.g. ctrl+Enter still shows "X!".
a