Cannot resolve symbol

Issue #1033 resolved
Eric Kintzer created an issue

IC2.0.2.5

This comes from the Andrew Fawcett/Trailhead fflib pattern

Given test class Foo contains line:

Application.Selector.setMock(someObject);

and class Application is defined as follows:

public class Application {
  public static final fflib_Application.SelectorFactory Selector = new fflib_Application.SelectorFactory (
  new map<SobjectType,Type> {
    Account.SobjectType => AccountsSelector.class, 
   ...
});

and class fflibApplication.SelectorFactory is an inner class in fflib_Application defined as:

public class SelectorFactory {
   ...
   @TestVisible
   private void setMock(fflib_ISobjectSelector selectorinstance) {..}
}

Then the line in the test class

Application.Selector.setMock(someObject);

will display setMock in red - "Cannot resolve symbol setMock" yet the expression compiles just fine.

Comments (8)

  1. Eric Kintzer reporter

    one other bit -- the red seems transient - once you start editing the file; it seems to go away but when one comes back to the tab for that file, it reappears. Issue is minor

  2. Scott Wells repo owner

    Eric, I've tried to reproduce this issue but have been unable to do so when things are set up properly so that Salesforce also accepts the source for compilation. I didn't install fflib, but I did mock up the respective pieces as follows:

    Application

    public with sharing class Application
    {
        public class SelectorFactory
        {
            @TestVisible
            private void setMock(Comparable comparable)
            {
    
            }
        }
    
        public static final SelectorFactory Selector = new SelectorFactory();
    }
    

    Test class/method that sets the mock

    @IsTest
    public with sharing class IllegalAssignmentTest
    {
        public static void testIssue1033()
        {
            Application.Selector.setMock(null);
        }
    }
    

    This code shows no errors. If I remove the @IsTest annotation from the test class, it does show as red in IC and also fails to deploy to Salesforce.

    Is there perhaps something I'm doing differently from you? If not, can you ensure that you're on the very latest build and see if the problem still occurs? It's possible that I fixed this issue as a side-effect of some of the other fixes in the intervening builds.

  3. Eric Kintzer reporter

    Hmm - in 2.0.2.6 I'm no longer seeing this behavior (whereas in 2.0.2.5 I did). I'll let you know if it recurs

  4. Scott Wells repo owner

    Okay, thanks for confirming. FWIW, I released 2.0.3.0 this morning, so at 2.0.2.6 you're several rounds of fixes behind. I would recommend updating to the latest-and-greatest for the best results...and if you find something broken as a result of doing so, definitely reprimand me and I'll take care of it ASAP! Moving up should be a purely positive experience...

  5. Eric Kintzer

    2.0.3.5

    reopening (variant or perhaps clue of original issue)

    the code auto-complete doesn't seem to work for this sample. using the code above, if I type:

    Application.Se
    

    then the popup code complete menu does present Selector as a choice

    so, press enter, yielding

    Application.Selector
    

    then continue typing

    Application.Selector.setM
    

    and nothing pops up to code complete the method setMock

    N.B. setMock is a private method annotated @TestVisible

  6. Scott Wells repo owner

    Eric, I'm still unable to reproduce this behavior. Here's what I see when I try what you've described:

    Issue1033.gif

    Note that there is a bug in 2.0.3.5 that I have fixed locally but could be contributing to this behavior. Let's hold this open until I release 2.0.3.6 and see if this behavior continues. If so I'll likely need to gather some additional debug logs from you to see why it's happening.

  7. Log in to comment