I have to override a Java method that uses an `@No...
# announcements
t
I have to override a Java method that uses an
@NonNull
annotation on a parameter even though documentation (and common sense) says that it can be null. If I make the same parameter nullable in my overriding Kotlin method, the compiler complains to me that I'm not overriding. But if I don't, then the function will crash at the hidden parameter assertion that is generated automatically. How do I tell the compiler "shut up, I know what to do"? Can I disable null-assertions for just this method?
k
You have to override as non null. It seems though that your Java method should be
@Nullable
, so if have access to it you can fix that.
t
I don't have access, that's the problem
But the compiler generates null checks for that argument, so if it's null it will crash
k
So override as non null? Do you have to pass null to the API?
Is that some Android API btw?
t
It's the Timber logging library
I'm not passing null to the library. It is passing null to me. So if I override with a non-nullable parameter, it will crash
k
Timber should be in Kotlin now…
t
Last release was 2018...
k
yeah, it’s in Kotlin now
t
Not released though. But apparently they changed it so the argument is actually never null. Just the docs are outdated
Annoyingly there was a PR 2 years ago to fix this but never got merged due to bikeshedding 😑
k
4.7.1
is the latest released version, it has Timber written in Kotlin.
What’s the specific API?
t
Timber.Tree.log(int priority, @Nullable String tag, @NotNull String message, @Nullable Throwable t)
My dependency in the build.gradle file is 4.7.1 and that file is still Java when I go to it
🤔 1
When I browse the repo at 4.7.1 tag it's still Java too. The release is just too old to include the Kotlin port it seems
k
Ugh, you are right, it’s not released yet 😕
t
The owner of timber is in this channel.. probably he could find time to help. @jw
t
If only the docs are outdated then there's no need to update it right now.