===================================================================
@@ -6061,12 +6061,16 @@
end;
else
- -- If the function returns the limited view of type, the call must
- -- appear in a context in which the non-limited view is available.
- -- As is done in Try_Object_Operation, use the available view to
- -- prevent back-end confusion.
+ -- If the called function is not declared in the main unit and it
+ -- returns the limited view of type then use the available view (as
+ -- is done in Try_Object_Operation) to prevent back-end confusion;
+ -- the call must appear in a context where the nonlimited view is
+ -- available. If the called function is in the extended main unit
+ -- then no action is needed, because the back end handles this case.
- if From_Limited_With (Etype (Nam)) then
+ if not In_Extended_Main_Code_Unit (Nam)
+ and then From_Limited_With (Etype (Nam))
+ then
Set_Etype (Nam, Available_View (Etype (Nam)));
end if;