This is boggling my mind.
Either my brain has died, or something has changed with the inheritance. Because the way I find it behaving now kindof defeats the whole purpose of having Inheritance in the first place.. anyhoo. examples:
These scenarios are the same with and without either Strict or SuperStrict.
It seems that casting objects back and forth does not work as it should. Does this mean I have to recreate all the Create() functions in every single subclass of A that I write? this has its own disadvantages. Lots of double code which should be solved by the inheritance. And as it stands, I can not treat an instance of B as an instance of A, not even after casting it with A(myinstance), as this threows the Null Reference Error.
Either my brain has died, or something has changed with the inheritance. Because the way I find it behaving now kindof defeats the whole purpose of having Inheritance in the first place.. anyhoo. examples:
SuperStrict Type A Function Create:A() Local _a:A = New A; Return _a; End Function End Type Type B Extends A Method Foo() Print("blah"); End Method End Type '// Scenario 1 Local myB:B = A.Create(); '// Compile Error - Cannot convert from A To B '// Scenario 2 Local myB:B = B.Create(); '// Compile Error - Cannot convert from A To B '// Scenario 3 Local myB:B = B(A.Create()); '// Compiles, but... myB.Foo(); '// Unhandled Exception:Attempt To access Field Or Method of Null Object '// Scenario 4 Local myB:B = B(B.Create()); '// Compiles, but... myB.Foo(); '// Unhandled Exception:Attempt To access Field Or Method of Null Object
These scenarios are the same with and without either Strict or SuperStrict.
It seems that casting objects back and forth does not work as it should. Does this mean I have to recreate all the Create() functions in every single subclass of A that I write? this has its own disadvantages. Lots of double code which should be solved by the inheritance. And as it stands, I can not treat an instance of B as an instance of A, not even after casting it with A(myinstance), as this threows the Null Reference Error.