Method name "of" results in error despite being valid
I have some static lookup methods called of
, and IC complains with the following:
'.', <, <name identifier> or '[' expected, got 'of'
. This also breaks auto code formatting.
This code is valid and deploys without problems.
If you rename the method to ofX
or anything but of
, all is well within the editor, but that should not be necessary.
Example:
public class TestClass {
public static Account of(String email) {
return null;
}
}
Comments (4)
-
repo owner -
reporter Ah this is good to know! Thanks for the reference. Indeed it'd be great if you could ease the restriction since it works as of now. Perhaps the most ideal would be if it could be a warning for the future reserved words. Not sure if you can do different rules by API version or if you'd ever want to, but the neatest implementation would know what keywords would be valid depending on the class' API version.
-
repo owner Fix submitted for the next build.
-
repo owner - changed status to resolved
Delivered in 2.0.1.2 and 1.8.2.1.
- Log in to comment
This is because
of
is a keyword reserved for future use by Salesforce:http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_reserved_words.htm
so IC's parser doesn't currently allow it as an identifier name. I have a simple mechanism to ease this restriction, though, and will do so for the next build.