T := It.Typ;
end if;
- -- Locate the component. For a private prefix the selector can denote
- -- a discriminant.
+ -- Find the selected component. For a private prefix, the selector
+ -- can denote a discriminant.
if Is_Record_Type (T) or else Is_Private_Type (T) then
- -- If the prefix is a class-wide type, the visible components are
- -- those of the base type.
+ -- If the prefix has a class-wide type, the visible components are
+ -- those of the root type.
if Is_Class_Wide_Type (T) then
- T := Etype (T);
+ T := Root_Type (T);
end if;
Comp := First_Entity (T);
T := It.Typ;
end if;
- -- Locate selected component. For a private prefix the selector
+ -- Find the selected component. For a private prefix, the selector
-- can denote a discriminant.
if Is_Record_Type (T) or else Is_Private_Type (T) then
- -- The visible components of a class-wide type are those of
- -- the root type.
+ -- If the prefix has a class-wide type, the visible components
+ -- are those of the root type.
if Is_Class_Wide_Type (T) then
- T := Etype (T);
+ T := Root_Type (T);
end if;
Comp := First_Entity (T);
--- /dev/null
+-- { dg-do compile }
+
+with Ada.Containers.Indefinite_Vectors;
+
+generic
+package Class_Wide1 is
+
+ type R is tagged record
+ X : Integer;
+ end record;
+
+ package V is new Ada.Containers.Indefinite_Vectors (Positive, R);
+ package V_CW is new Ada.Containers.Indefinite_Vectors (Positive, R'Class);
+
+ function F1 (VV : V.Vector) return Integer is (VV (1).X);
+ function F2 (VV : V_CW.Vector) return Integer is (VV (1).Element.X);
+ function F3 (VV : V_CW.Vector) return Integer is (VV (1).X);
+
+end Class_Wide1;