Fix crash evaluating class-wide preconditions with missing completion
This commit fixes a crash when evaluating class-wide preconditions for non-primitive subprograms with missing type completion in Ada.
This commit prevents a crash that occurred when the compiler tried to evaluate a class-wide precondition of a non-primitive subprogram when the dispatching type was abstract and lacked completion. Instead of crashing, the compiler will now issue an appropriate error message.
In Details
The fix modifies sem_prag.adb in the Check_References function. It avoids calling Class_Wide_Type if the subprogram is a non-primitive procedure and the dispatching type might be empty due to being abstract with a missing completion. This prevents attempting to access the class-wide type when it's not available.
For Context
In Ada, a 'precondition' is a condition that must be true before a subprogram (function or procedure) is executed. A 'class-wide precondition' applies to all types in a class hierarchy. 'Type completion' refers to the point where the full definition of a type is known. This commit fixes a compiler crash that happened when a precondition check tried to access incomplete type information. Now, the compiler will report an error instead of crashing, providing a better user experience.