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

Kroppeb

11/05/2019, 11:39 PM
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

streetsofboston

11/05/2019, 11:42 PM
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

Frodrigues

11/05/2019, 11:50 PM
That's only a suggestion. But you really want to make a list with a null?
k

Kroppeb

11/05/2019, 11:54 PM
If
t = T(null)
, then
r1
will return
[null]
but
r2
would return
[10]
w

w_bianrytree

11/06/2019, 2:10 AM
Try add a ? at your capture function?
k

Kroppeb

11/06/2019, 2:15 AM
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

bodiam

11/06/2019, 3:33 AM
In this case it seems maybe better to create Youtrack issue in the IntelliJ project, since this looks like a bug.
a

Alexey Belkov [JB]

11/07/2019, 6:38 AM
Yes, please report to http://kotl.in/issue with sample code to reproduce in text form. Thanks!
k

Kroppeb

11/07/2019, 7:27 PM
3 Views