IntelliJ suggests to convert `r1` to `r2`, but the...
# announcements
k
IntelliJ suggests to convert
r1
to
r2
, but these are not equivalent. (The inferred type isn't even the same) Seems to be an issue if an extension function on a nullable type gives a generic type with the input type as one of the type parameters and as input a nullable type with a nullable parameter
s
The inferred types are different because of the nullability of
T.p
, correct?
Maybe it suggests the conversion because a
List<Int>
is a sub-type of `List<Int?>`… just guessing here 🙂
f
That's only a suggestion. But you really want to make a list with a null?
k
If
t = T(null)
, then
r1
will return
[null]
but
r2
would return
[10]
w
Try add a ? at your capture function?
k
If you mean making the type argument non nullable, no. That’s not the problem. The problem is IntelliJ giving a suggestion that doesn’t work.
b
In this case it seems maybe better to create Youtrack issue in the IntelliJ project, since this looks like a bug.
a
Yes, please report to http://kotl.in/issue with sample code to reproduce in text form. Thanks!
k