bogus typechecker error only in IntelliJ
Opened this issue · 6 comments
I have a class which implements android.service.media.MediaBrowserService.onLoadChildren()
:
shared actual void onLoadChildren(String parentMediaId,
MediaBrowserService.Result<List<MediaBrowser.MediaItem>> result) { ... }
This results in the nonsense error:
type of parameter 'result' of 'onLoadChildren' declared by 'MusicService' is different to type of corresponding parameter 'result' of refined member 'onLoadChildren' of 'MediaBrowserService': 'MediaBrowserService.Result<List<MediaBrowser.MediaItem>>' is not exactly 'Result<List<MediaBrowser.MediaItem>>?'
But the error only occurs inside Android Studio. It doesn't happen from the Gradle build.
You can see the error in this project: https://github.com/gavinking/UniversalMusicPlayer
Simpler test case:
public abstract class MediaBrowserService {
public class Result<T> {}
abstract void fun(Result<String> list);
}
import java.lang { String }
class Cl() extends MediaBrowserService() {
shared actual void fun(Result<String>? list) {}
}
type of parameter 'list' of 'fun' declared by 'Cl' is different to type of corresponding parameter 'list' of refined member 'fun' of 'MediaBrowserService': 'MediaBrowserService.Result<String>?' is not exactly 'Result<String>?'
// TODO
qualifyingType => null; //enclosing;
🙄
ops!
@bjansen I was trying to figure this one out and perhaps the answer is to use psi.accept(PsiTypeVisitor)
to get the qualifying type? WDYT?
I was also looking for a solution the other day, but didn't notice that visitor. Are you talking about this one? It doesn't look like it does anything useful in our case...
Yeah that one. Oh I thought maybe it visits the constituent types of a type expression.