Code inspection returns false positive "Cannot resolve symbol InnerClass"

Issue #1759 resolved
Former user created an issue

Hi Scott,

I’m encountering a Cannot resolve symbol inspection error when using inner classes.

When typing code in the middle of the file, you usually invalidate the code below (as you are halfway a statement and the syntax is incorrect from that point on). If the inner class is placed at the bottom of the class, this gets invalidated too and the class is not compilable, and thus not recognised in the code inspector. (This used to be the same in IC1 - I switched to IC2 last week.) However, once finishing the line and ending up again with correct syntax, the inner class is still not recognised. This was not the case in IC1.

To have it working properly I’d have to reload the project after each line change. The workaround for now is to put inner classes at the top of the file.

FYI: This is a project created in IC1 and imported into IC2, Intellij IDEA 2020.2.3.

Comments (14)

  1. Scott Wells repo owner

    Easily reproduced. Working on a fix for the next build. Thanks for bringing this to my attention!

  2. Scott Wells repo owner

    The attached build includes the fix for this issue which I believe may be causing more problems than just the one indicated here. Basically when IC is unable to find a type for a given simple name, it was caching a null value and not expiring that value when it should have. I'd like for both the reporter of this issue and another using having what I believe is likely the same issue to install this build and help verify whether it helps.

    To install it, download the attached archive, then use Settings/Preferences>Plugins>Install plugin from disk (under the gear drop-down menu).

  3. Attila Hajdrik

    I had the same problem and this new build fixed the unresolved classes where the classes were having syntax errors inside.

  4. Tom Fuda Account Deactivated

    Is it also possible this could have been causing problems with the “Find usages” feature for finding usages of methods and/or classes? I’ve been working with the latest IC2 on IntelliJ Community Edition for the past couple of days and been experiencing a lot of problems with the IDE reporting no usages of methods that are clearly being used. I installed this version in hopes it will fix the problems I’ve been having.

  5. Scott Wells repo owner

    Hi, Tom. Yes, it's very possible. I'll be releasing a new build tomorrow morning with this fix plus a number of others. Let's get that installed and see what problems remain for you, then I'll handle those separately if still present.

  6. Tom Fuda Account Deactivated

    Scott, the pre-release build you attached to this issue does seemed to have helped with the “find usages” problems I was having. Thanks!

  7. Scott Wells repo owner

    Glad to hear, Tom. Stay on that build until the next official one (targeting tomorrow morning) which will include the same fix as well as a number of other (mostly small) fixes.

  8. Scott Wells repo owner

    Glad to hear. As mentioned previously, that is a pre-release build to verify the fix and an official build will be available (most likely) tomorrow morning.

  9. Log in to comment