A type guard can be required in two cases, as follows.
When assigning to an object reference where the declared class of the expression on the right of the assignment is a superclass of the declared class on the left-hand side; for example:
countAllClasses(): Integer updating; constants Max_Classes = 16000; vars objArray : ObjectArray; cls : Class; obj : Object; total : Integer; begin create objArray transient; Class.allInstances(objArray, Max_Classes, true); foreach obj in objArray do cls := obj.Class; // Object is a superclass of Class if not cls.isSystemObject and cls.superschemaType = null then total := total + 1; endif; endforeach; return total; end;
When accessing a method or a property of an object where the declared class of the reference to the object is a superclass of the class in which the feature was defined; for example:
foreach form in formDictionary do if form.isKindOf(SpecialForm) then form.SpecialForm.cutEnabled := true; endif; endforeach;
In the above example, a reference is obtained to a form from a generic form dictionary, where the membership type is
The use of the