To avoid duplication of generated code, the compiler builders of Embarcadero have done a nice job. They introduced new instrinsics like IsManagedType, GetTypeKind and IsConstantType (see
this Stackoverflow answer), so they could make a function like the following generate a call to the exact function directly, so the code below "runs" completely inside the compiler (even the code in InternalAddMRef