Cannot resolve symbol - 2.0.3.5 (inner class issue)

Issue #1091 resolved
Eric Kintzer created an issue

You must have made a change recently to the analyzer but the following creates Red "Cannot resolve symbol" whereas it didn't use to.

public class Foo {
  public FooInner bars;

 public class FooInner {
    String s = Bars.SomeStatic;  // cannot resolve symbol SomeStatic
 }
}

public class Bars {
  public static String SomeStatic;
}

1) This is valid Apex compiler syntax as Apex knows that Bars.SomeStatic refers to class Bars, not outer class variable

bars

which , BTW, isn't referenceable in an inner class anyway.

2) Now, you might say, what idiot would name an instance variable the same as a class name (bars vs Bars)?

This arises from Json deserialization code where variable bars appears in the Json (defined by a third party integration) and Bars happens to be the fflib domain class used to deal with Sobject Bar__c and hence follows the fflib naming conventions

Comments (5)

  1. Scott Wells repo owner

    Easily reproduced. As you've ascertained, the issue is that IC's internal resolver is finding the field named bars instead of the class named Bars and therefore isn't able to resolve the field Bars.SomeStatic. This one will require some careful updates to the internal resolver to ensure that existing resolution logic isn't negatively affected. It won't be the first time some level of forward lookahead is required, but it's always a bit tricky to implement. I'll take a look at it for one of the upcoming builds.

  2. Scott Wells repo owner

    I do have a candidate fix for this one. I want to do quite a bit of testing to ensure there are no regressions, but assuming that all goes well it might very well be in the next build after all.

  3. Scott Wells repo owner

    There were a few small issues with the candidate fix...nothing big, but I want to address them before including it in an official release. This won't be in the next build (tomorrow morning's), but it should be in the one after that if everything smooths out the way I expect.

  4. Log in to comment