The code below reproduces a problem I have, of a generic function which is present in a package, but is not seen regardless. The package itself is seen, and instantiated, but not the function inside.
It’s the smallest complete exemple I could make. I’m certainly overlooking something painfully obvious… But I can’t see it.
So please tell.
Thank you
pragma Ada_2022; pragma Extensions_Allowed (all);
with Ada.Text_IO, Ada.Characters.Handling;
use Ada.Text_IO, Ada.Characters.Handling;
procedure Test is
generic
type Item_Type (<>) is limited private;
type Item_Access is access Item_Type;
package Limited_Lists is
type List_Type is limited private;
type List_Iterator is private;
generic
with function Make return Item_type is <>;
procedure Insert (Iterator : List_Iterator);
function Last (List : aliased List_Type) return List_Iterator;
private
type Item_Record;
type Item_Record_Access is access Item_Record;
type List_Access is access List_Type;
type Item_Record is
record
Item : Item_Access;
Next, Pred : Item_Record_Access;
end record;
type List_Type is limited
record
First, Last : Item_Record_Access;
Count : Natural := 0;
end record;
type List_Iterator is
record
List : List_Access;
Current : Item_Record_Access;
end record;
end Limited_Lists;
package body Limited_Lists is
function Last (List : aliased List_Type) return List_Iterator is
(List => List'Unrestricted_Access, Current => null);
procedure Insert (Iterator : in List_Iterator) is
New_Item : Item_Record_Access;
begin
New_Item := new Item_Record'(Pred => <>, Next => Iterator.Current, Item => new Item_type '(Make));
Iterator.List.Last := New_Item;
end Insert;
end Limited_Lists;
package Spreadsheets is
type Spreadsheet_Type is tagged limited private;
type Spreadsheet_Access is not null access all Spreadsheet_Type'Class;
type Cell_Type (Sheet : Spreadsheet_Access) is tagged null record;
procedure Insert (Sheet : in out Spreadsheet_Type;
Constructor: not null access function return Cell_type'Class);
type Cell_Access is access all Cell_Type'Class;
private
package Cell_lists is new Limited_lists (Cell_Type'Class,Cell_Access);
use cell_lists;
type Spreadsheet_Type is tagged limited record
Cells : aliased List_Type;
end record;
end Spreadsheets;
package body Spreadsheets is
procedure Insert (Sheet : in out Spreadsheet_Type; Constructor: not null access function return Cell_type'Class) is
function Insert_2 is new cell_lists.Insert (Constructor.all); -- COMPLAINS HERE
begin
Insert_2 (Last(Sheet.Cells));
end Insert;
end Spreadsheets;
begin
null;
end test;