-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SimpleDecoder constructor is incompatible with Kotlin (nullness) #8232
Comments
[I'm not a Kotlin expert, you may get better help asking this question in a more Kotlin-focussed context like Stack Overflow] This error looks like it's related to Kotlin's handling of covariance and contravariance:
I don't have an easily available setup to test Kotlin, so I don't know if this will work, but can you try explicitly listing the type parameter in your call to
I don't think this question is strictly related to ExoPlayer, I'll leave it open for a while in case anyone else has suggestions. |
Thanks for the reply.
Still get the same error. I also tried to ask the same question in StackOverflow before open a question here, but there was not even a comment. |
I don't know if this is correct, but it does at least compile:
|
Thanks for the suggestion. |
Ah I have another theory.
We have We use (Sorry for the wrong diagnosis above, I didn't spot the crucial The reason your bridge Java class works (I think) is that it's presumably not in a package with the same |
Thanks a lot for the info. It is OK for me to use casting. But the more important thing is to get to know the root cause. Appreciate it. |
I am using Exoplayer in my Kotlin app. When I try to make my own decoder which extends the SimpleDecoder class (coming from the ExoPlayer core library), I got build error.
The dependencies of ExoPlayer I am using:
The constructor of SimpleDecoder is as following:
And in my TestDecoder.kt I was trying to passing array of nulls to the super class:
And the error is:
However, if I create a bridge class in Java inside my project, like following SimpleDecoderBridge.java:
Then make my TestDecoder extends from this bridge class, there is no build error.
Could anyone here point out what is going on here? Why does the error happen and why does it not happen later? Am I doing it correctly(passing arrayOfNulls(size) to super) in Kotlin? If not, what is the correct way to do so? Thanks a lot.
The text was updated successfully, but these errors were encountered: