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

xenoterracide

09/25/2019, 5:45 PM
is there any way for me to work around that?
k

Kroppeb

09/25/2019, 5:52 PM
Are you sure? I feel like it should be
Any!
which would allow a
null
I think. Adding a
@Nullable
should solve the problem.
x

xenoterracide

09/25/2019, 5:54 PM
sadly it’s not my method, so I can’t modify it
s

streetsofboston

09/25/2019, 5:55 PM
You should be able to pass a
null
value to a platform type like
Any!
, without a
@Nullable
annotation
x

xenoterracide

09/25/2019, 5:56 PM
Screen Shot 2019-09-25 at 12.55.45 PM.png
s

streetsofboston

09/25/2019, 5:57 PM
It says the type is
Any
, not
Any!
. Are you sure this is a platform type, and you’re not hooking up to some kotlin extension …
k

Kroppeb

09/25/2019, 5:57 PM
Huh, what does the doc says if you bring it up in the ide?
x

xenoterracide

09/25/2019, 5:59 PM
Copy code
> Task :compileTestKotlin FAILED
e: /Users/calebcushing/IdeaProjects/phs/src/test/kotlin/com/potreromed/monitor/PatientLookupTest.kt: (79, 58): Null can not be a value of a non-null type Any
Screen Shot 2019-09-25 at 12.59.43 PM.png
s

streetsofboston

09/25/2019, 6:06 PM
Does the Spring framework declare this method with a Nullable-annotation? If so, that would explain things
☝️ 1
x

xenoterracide

09/25/2019, 6:06 PM
not according to the attached sources it doesn’t
m

Mike

09/25/2019, 7:00 PM
Spring has NotNull set as default at package/module level IIRC so they only have to identify those places where something is nullable. I think that explains yours scenario.
x

xenoterracide

09/25/2019, 8:47 PM
ah
maybe I should file a bug?
m

Mike

09/26/2019, 12:57 PM
I don't think it's a bug. Is there a function to check if the body is null instead? That's the way I'd code it. Use Equal when you have/expect a body, and check null/empty explicitly in the other case.
3 Views