Sometimes, we have a class defined as such in an unit:
TSomeClass = class
protected
procedure SomeProtectedMethod;
end;
TChildClass = class(TSomeClass);
and in another unit, we want to run the SomeProtectedMethod.
What we could do for ever is to create a local "hook" class:
TSomeClassHook = class(TSomeClass);
...
if obj is TSomeClass then
TSomeClassHook(obj).SomeProtectedMethod;
It worked well, because of the forced typecast.
But if obj is of type TChildClass, now FPC trunk complains at runtime.
So I suspect, the trunk compiler add a runtime check to ensure that TSomeClassHook(obj) is actually a TSomeClassHook - which is not the case of course.
In practice, now above code seems to be compiled as:
TSomeClassHook = class(TSomeClass);
...
if obj is TSomeClass then
(obj as TSomeClassHook).SomeProtectedMethod;
which is breaking existing code.
What should I do?