Spurious illegal assignment error for ApexPages.Message constructor

Issue #1059 resolved
Phil W created an issue

The ApexPages.Message constructors are documented as taking an ApexPages.Severity value. However, the following code generates an illegal assignment of ApexPages.Severity to Integer:

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'blah'));

Now, I believe this is actually because of the issue I previously raised where we happen to have a nested class called Message that has a constructor that takes two parameters that are of type Integer and String:

    public class Message {
        public Integer messageType;
        public String contents;

        public Message(Integer messageType, String contents) {
            this.contents = contents;
            this.messageType = messageType;
        }
    }

This appears in the same class containing the methods that are using the ApexPages.Message class. Using ctrl+click or ctrl+B on the "Message" class name in the line containing ApexPages.Message incorrectly takes me to the nested Message class.

This is happening in:

IntelliJ IDEA 2018.2 (Ultimate Edition) Build #IU-182.3684.101, built on July 24, 2018 JRE: 1.8.0_152-release-1248-b8 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0

With IC2 2.0.3.0.

Comments (3)

  1. Scott Wells repo owner

    Phil, this is obviously quite old. Is it still happening? My guess(/hope) is that it's long-since fixed, but I wanted to ask before resolving the issue.

  2. Scott Wells repo owner

    Thanks for confirming. I'm trying to knock down some of these type inference corner cases right now which is why some of these older ones are coming back into play.

  3. Log in to comment