In some cases involving a generic with two formal parameters, a formal package
and a formal derived type that is derived from an interface type declared in
the formal package, a legal instantiation of that generic is rejected with a
message incorrectly stating that the second actual parameter does not implement
the required interface.
gcc/ada/ChangeLog:
* sem_ch12.adb (Validate_Derived_Type_Instance): Cope with the case
where the ancestor type for a formal derived type is declared in
an earlier formal package but Get_Instance_Of does not return the
corresponding type from the corresponding actual package.
elsif
Scope (Scope (Base_Type (Etype (A_Gen_T)))) = Scope (A_Gen_T)
then
- Ancestor :=
- Get_Instance_Of (Base_Type (Etype (A_Gen_T)));
+ declare
+ Formal_Ancestor : constant Entity_Id :=
+ Base_Type (Etype (A_Gen_T));
+ begin
+ Ancestor := Get_Instance_Of (Formal_Ancestor);
+
+ -- Handle (rare) case where Get_Instance_Of found nothing in
+ -- the map.
+
+ if Ancestor = Formal_Ancestor then
+ Ancestor :=
+ Get_Instance_Of
+ (Base_Type (Etype (Get_Instance_Of (A_Gen_T))));
+ end if;
+ end;
-- The type may be a local derivation, or a type extension of a
-- previous formal, or of a formal of a parent package.