In conversions of prefixed calls involving interfaces, the expression in the conversion may have a limited view of a type obtained transitively through several contexts. Use the non-limited view if available, to enable subsequent interface membership tests.
The following must compile quietly: gcc -c rich_graph.adb --- with Edge; with Vertex; with Graph; package Rich_Graph is type Object is new Graph.Object with private; type Class_Ref is access all Object'Class; overriding function Other_End (G : in Object; E : in Edge.Class_Ref; V : in Vertex.Class_Ref) return Vertex.Class_Ref; private type Object is new Graph.Object with null record; end Rich_Graph; --- with Rich_Edge; with Rich_Vertex; package body Rich_Graph is overriding function Other_End (G : in Object; E : in Edge.Class_Ref; V : in Vertex.Class_Ref) return Vertex.Class_Ref is Rich_E : Rich_Edge.Class_Ref; Rich_V : Rich_Vertex.Class_Ref; begin Rich_E := Rich_Edge.Class_Ref (E); Rich_V := Rich_Vertex.Class_Ref (V); return Vertex.Class_Ref (Rich_E.Other_End (Rich_V)); end Other_End; end Rich_Graph; --- package Edge is type Object is limited interface; type Class_Ref is access all Object'Class; end Edge; --- package Vertex is type Object is limited interface; type Class_Ref is access all Object'Class; end Vertex; --- with Vertex; with Edge; package Graph is type Object is limited interface; type Class_Ref is access all Object'Class; function Other_End (Graph : in Object; E : in Edge.Class_Ref; V : in Vertex.Class_Ref) return Vertex.Class_Ref is abstract; end Graph; --- with Edge; limited with Rich_Vertex; package Rich_Edge is type Object is limited interface and Edge.Object; type Class_Ref is access all Object'Class; function Other_End (E : in Object; V : access Rich_Vertex.Object'Class) return Rich_Vertex.Class_Ref is abstract; end Rich_Edge; --- with Vertex; package Rich_Vertex is type Object is limited interface and Vertex.Object; type Class_Ref is access all Object'Class; end Rich_Vertex; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-07-29 Ed Schonberg <schonb...@adacore.com> * sem_res.adb (Resolve_Type_Conversion): If the type of the expression is a limited view, use the non-limited view when available.
Index: sem_res.adb =================================================================== --- sem_res.adb (revision 213154) +++ sem_res.adb (working copy) @@ -10193,6 +10193,17 @@ Target : Entity_Id := Target_Typ; begin + -- If the type of the operand is a limited view, use the non- + -- limited view when available. + + if From_Limited_With (Opnd) + and then Ekind (Opnd) in Incomplete_Kind + and then Present (Non_Limited_View (Opnd)) + then + Opnd := Non_Limited_View (Opnd); + Set_Etype (Expression (N), Opnd); + end if; + if Is_Access_Type (Opnd) then Opnd := Designated_Type (Opnd); end if;