why do I sometimes get a runtime exception due to ...
# announcements
d
why do I sometimes get a runtime exception due to a non optional value being null? at least when interacting with Android platform APIs. does this mean the platform API is not correctly annotated for consumption in Kotlin?
g
probably you passed null from Java or have some reflections that create nullable values. Anyway hard to say something particular without details
d
Copy code
c.getString(c.getColumnIndex(StructuredPostal.STREET))
apparently that returned
null
.. i just wish i would get a compile error instead of a runtime error
g
this is Java API, there is no nullability information
d
so shouldn't it be a compile error to assign that to a non optional value?
g
at least until those functions annotated with Nullable/NonNull
no, it’s a very long story whym, but it’s called platform types
so if Java API is not annotated, it concidered as platform type and maybe used as nullable and non-nullable
d
got it
i wonder if there is a linter option that could turn these into compile errors
g
there is no such option
d
ok
o
for what it's worth there's an inspection for
Function or property has a platform type
which you could set to error (seems to default to weak warning)
g
It wouldn't be reported for David's usecase, because platform type passed as argument to another platform type, so there is no warning. You see this warning only when expose it in Kotlin API
👍 1