I have the following packages:
-------------------
-- File: father.ads
-------------------
package Father with SPARK_Mode => On is
pragma Elaborate_Body;
type Father_T is abstract tagged private;
function Get_Field_1 (Self : Father_T) return Positive;
procedure Proc_1 (Self : in out Father_T; Another : Father_T) is abstract;
function Func_1 (Self : Father_T) return Boolean is abstract;
private
pragma SPARK_Mode (Off);
type Father_T is abstract tagged record
Field_1 : Positive := 1;
end record;
end Father;
--------------------------
-- File: father-middle.ads
--------------------------
package Father.Middle with SPARK_Mode => On is
pragma Elaborate_Body;
type Middle_T is abstract new Father_T with null record; -- [L1]
overriding procedure Proc_1 (Self : in out Middle_T; Another : Middle_T);
private
pragma SPARK_Mode (Off);
function Func_2 (Self : Middle_T) return Boolean;
end Father.Middle; -- [L3]
--------------------------
-- File: father-middle.adb
--------------------------
package body Father.Middle is
------------
-- Proc_1 --
------------
overriding procedure Proc_1 (Self : in out Middle_T; Another : Middle_T) is -- [L2]
begin
Self.Field_1 := Self.Field_1 + Another.Field_1;
end Proc_1;
------------
-- Func_2 --
------------
function Func_2 (Self : Middle_T) return Boolean is
begin
return False;
end Func_2;
end Father.Middle;
-------------------------------
-- File: father-middle-lead.ads
-------------------------------
package Father.Middle.Leaf with SPARK_Mode => On is
pragma Elaborate_Body;
type Leaf_T is new Middle_T with null record;
function Create return Leaf_T;
overriding function Func_1 (Self : Leaf_T) return Boolean;
end Father.Middle.Leaf;
The compiler gives the following error:
father-middle.ads:7:04: first freezing point of type "Middle_T" must appear within early call region of primitive body "Proc_1" (SPARK RM 7.7(8)) [L1]
father-middle.ads:7:04: region starts at father-middle.adb:7 [L2]
father-middle.ads:7:04: region ends at father-middle.adb:7 [L2]
father-middle.ads:7:04: first freezing point at line 17 [L3]
If I override Proc_1 in Father.Middle.Leaf instead of Father.Middle the error is gone.
I have read https://docs.adacore.com/spark2014-docs/html/lrm/packages.html#elaboration-issues but I am new to SPARK.
Is there a way to override Proc_1 in Father.Middle?
I am using GNAT Studio Community 2020 in Windows 10.