I've encountered an odd bug where Apex code was assigning a value to a static property without a setter defined.
Below is a simplified version of the code:
@isTest
public class PropertySettingTest {
public static boolean testBooleanProp {
get {
return false;
}
}
static testMethod void setPropertyUnitTest() {
System.assert(!testBooleanProp);
testBooleanProp = true;
System.assert(!testBooleanProp);
System.debug(testBooleanProp);
}
}
When assigning the property I'd expect to get an error when saving/compiling like:
Save error: Variable is not visible: testBooleanProp
However, is saves and runs. The property assignment has no affect.
I did another test, and if the property isn't static the code fails to save/compile as expected.
Am I missing something or is this a bug? I'd like some confirmation before raising a support case.