Details
Description
I have the following code which doesn't work:
import static Constants.* class Constants { static final String NAME = "name" } def map = [:] if(!map[NAME]) { // <------ this succeeds... map[NAME] = "erik" // <------ this fails! } println map
However, the following does work:
import static Constants.* class Constants { public static final String NAME = "name" // <---- mind the public! } def map = [:] if(!map[NAME]) { // <------ this succeeds... map[NAME] = "erik" // <------ and this also succeeds... }
This can also be solved by prefixing the NAME constant with the class (Constants.NAME)
Appears this was fixed in 1.8, the first code sample runs successfully in 1.8.9 (and current versions) and prints the expected output.