As the title says,
class AA { protected void Fun() {} } class BB : AA { override void Fun() {} // should throw compile error for inconsistent accessibility. } AA a = new AA(); BB b = new BB(); AA upcasted = (AA)b; a.Fun(); // compile error. b.Fun(); // ok, instead, should throw compile error. upcasted.Fun(); // the object is of type BB, but casted to AA, compile error.
Also this code causes a crash if you put the last six lines into a non-member function. In the repro code, as you can see I put it in a member function instead, which causes no crash, if I were to remove the class, and just leave the function, the workbench crashes, all I know for now is that this is due to 'protected' modifier in the AA class.