--  An extension aggregate of a type whose discriminants are not its ancestor's: the aggregate
--  gives the type's own (`Length`), and the ancestor part must have the ancestor's
--  discriminants they and the type's constraint give (`Width = Length`, `Height = 1`).
with Ada.Text_IO;
procedure Main is
   package Shapes is
      subtype Count is Natural range 0 .. 20;
      type Shape (Width, Height : Count) is tagged record
         Name : Character := 'S';
      end record;
      type Strip (Length, Depth : Count) is new Shape (Width => Length, Height => 1) with record
         Extra : Integer := 7;
      end record;
      type Band (Size : Count) is new Strip (Length => Size, Depth => 2) with null record;
   end Shapes;
   use Shapes;
   function Make (W, H : Count) return Shape is (Width => W, Height => H, Name => 'X');
   S : constant Strip := (Make (2, 1) with Length => 2, Depth => 3, Extra => 4);
   T : constant Strip := (Shape with Length => 5, Depth => 1, Extra => 0);
   S2 : constant Strip := (Make (2, 1) with Length => 2, Depth => 2, Extra => 9);
   B : constant Band := (S2 with Size => 2);
begin
   Ada.Text_IO.Put_Line (S.Length'Image & S.Depth'Image & S.Extra'Image & " " & S.Name);
   Ada.Text_IO.Put_Line (T.Length'Image & Shape (T).Width'Image & Shape (T).Height'Image & " " & T.Name);
   Ada.Text_IO.Put_Line (B.Size'Image & Strip (B).Depth'Image & B.Extra'Image);
end Main;
