Inspection - List<String>{} is not recognized as List<APEX_OBJECT>
It seems to have just appeared in the latest version (2.0.5.1) ... or at least I've not noticed it until today.
This code flags an inspection error of Expected argument of type List<APEX_OBJECT>; found List<String> (see attachment)
String caseSubject = String.format(OpportunityHeaderByStageControllerExt.ISSUE_POLICY_TASK, new List<String>{
String.valueOf(opp.Final_Term_Length__c),
String.valueOf(opp.Final_Coverage_Amount__c)
});
But this is (properly) not flagged.
List<String> ret = new List<String>();
Comments (15)
-
repo owner -
It is happening to me also, but using List<Object> instead, both apex code and anonymous apex (I'm using version v2.0.5.2), see image:
-
repo owner Good to know....I'd rather see a pattern than a one-off. This is on my list of bugs to investigate (and ideally address) for the next build. I'll let you both know if I have trouble reproducing it and/or need additional info from you.
-
repo owner Okay, I do get an IC inspection error, but mine reads:
Expected argument of type List<String>; found List<Object>
If I try to send that code to the server, I get the following compilation error:
Compile failure on line 1, column 21: Method does not exist or incorrect signature: void format(String, List<Object>) from the type String
So I think that Gustavo's example isn't valid, is it? However, Tony's does use a list of strings and yields the same message. As I mentioned previously, though, there shouldn't be any remaining
APEX_OBJECT
references after OST generation. Can one or both of you guys show me howString.format()
is rendered into the OST? Here's mine:global static String format(String format, List<String> arguments) { }
-
documentation says that arguments are of List<Object> type (maybe I'm not understanding)
there's another example in an apex class:
// ... String description = String.format( 'foo {0} bar {1} baz {2}', new List<Object>{ contract.Name, Date.today().format(), 'http://www.google.com/' } );
-
repo owner Aha! That's an API v45.0/Spring '19 change and is not GA yet. Are you working against a pre-release org?
Here are the signatures for 44.0 and 45.0 respectively:
// 44.0 public static String format(String stringToFormat, List<String> formattingArguments) // 45.0 public static String format(String stringToFormat, List<Object> formattingArguments)
IC's integrated API docs are based on the most recent release, so they reflect 44.0/Summer '18. I will update those when I update the plugin for 45.0/Spring '19 once it's been released in all orgs. In the interim, if you're working against a Spring '19 pre-release org, it should be accepted as valid from a compilation standpoint, and it's possible that regenerating your OST will update the method signature for 45.0 as well...it depends on whether Salesforce has updated for that change pervasively or not.
The
List<APEX_OBJECT>
false negative that both of you are seeing is likely unrelated to that difference, though, so I'll continue to investigate it. -
reporter ahhh - looks like that's the issue.
i'm on cs20 ... which looks to be Spring '19 Patch 6.1 (v45.0)
Thanks for the investigation ... I probably should have considered that before I filed the ticket (though now you have something to verify for an upcoming release).
Scott - Big fan of IC ... keep up the great work!
thx,
-ttt
-
repo owner Ah, okay. As you said, still something to address, but perhaps something that only a few folks will encounter right now. I have some Spring '19 orgs that I use for dev on the LWC stuff. I'll check this out against them and see what's going on. I'll keep you posted here!
And definitely glad to hear that you're enjoying IC! Much appreciated!
-
I also tried with List<String> without success unfortunately
-
Hi Scott,
just wanted to add that this issue also occurs when generating the complete OST with a v44 connection against a Spring '19 org (CS85):
global static String format(String format, List<APEX_OBJECT> arguments) { }
Hope this helps, until then, just like Tony stated: Keep up the great work. ;)
Cheers, Sven
-
repo owner Thanks for the confirmation, Sven. I'll take a look today/tonight and, assuming it's reproducible (I see no reason it wouldn't be), I'll incorporate a fix for the next build.
-
repo owner Easily reproduced. Fix submitted for inclusion in the next build.
-
repo owner Delivered in 2.0.5.3.
-
repo owner - changed status to resolved
-
repo owner Fix back-ported to IC1 in 1.8.4.7.
- Log in to comment
That's really strange.
APEX_OBJECT
should not show up anywhere...it's purposefully replaced withObject
during OST generation. Let me tinker and see if I can reproduce this. I might need more information from you if I can't. Thanks for reporting!