In my application, there is this line of code causing trouble:
public class DisplayListing<R extends Listing<R, L>, L extends Listing<R, L>.Loader> extends SherlockListFragment { ... }
Working with Eclipse everything behaves fine. But after switching to IntelliJ IDEA errors are popping up:
No enclosing instance of type ‘com.app.Listing’ is in scope.
This error message refers to the part Listing<R, L>.Loader (Loader is a non-static class).
When I go to IntelliJ’s preferences and change the compiler from Javac to Eclipse I’m back to business: the application will successfully compile and run again.
But the red mark indicating an error will stay (and I would like to get rid of that). So I’m wondering if I’m actually doing something wrong and my generic arguments should be fixed or if it is okay to rely on the Eclipse compiler and ignore the error?
This is a legitimate bug, and it can be reproduced without any complex generics:
It appears that the IntelliJ parser (not its compiler, which is either
javacorecj) is mistaking theextends Bar.Bazto be part of the declaration ofFoo, notT. In other words, it’s the same error that you (correctly) get when you do this:This is IDEA Issue #94011. You can upvote that issue to give it greater notice.