Skip to content

Commit

Permalink
Do not use an access type discriminant for a mutable type
Browse files Browse the repository at this point in the history
... This is not allowed.

To circumvent, define a local class wide access type.

For https://gitlab.adacore-it.com/eng/toolchain/gnat/-/issues/993
  • Loading branch information
setton committed Aug 2, 2024
1 parent f366015 commit 11aa92a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions liblsp_base/source/lsp-json_streams.ads
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ with VSS.Text_Streams;
package LSP.JSON_Streams is
-- pragma Elaborate_Body;

type JSON_Reader is access all VSS.JSON.Pull_Readers.JSON_Pull_Reader'Class;

type JSON_Stream
(Is_Server_Side : Boolean := False;
R : access VSS.JSON.Pull_Readers.JSON_Pull_Reader'Class := null)
R : JSON_Reader := null)
is limited new Ada.Streams.Root_Stream_Type with private;
-- Stream implemented over JSON document
--
Expand Down Expand Up @@ -106,7 +108,7 @@ private

type JSON_Stream
(Is_Server_Side : Boolean := False;
R : access VSS.JSON.Pull_Readers.JSON_Pull_Reader'Class := null)
R : JSON_Reader := null)
is limited new Ada.Streams.Root_Stream_Type with
record
W : Write_Stream;
Expand Down
2 changes: 1 addition & 1 deletion source/client/lsp-clients.adb
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ package body LSP.Clients is
use all type VSS.JSON.Streams.JSON_Stream_Element_Kind;

R : aliased VSS.JSON.Pull_Readers.Simple.JSON_Simple_Pull_Reader;
JS : aliased LSP.JSON_Streams.JSON_Stream (False, R'Access);
JS : aliased LSP.JSON_Streams.JSON_Stream (False, R'Unchecked_Access);

begin
R.Set_Stream (Memory'Unchecked_Access);
Expand Down

0 comments on commit 11aa92a

Please sign in to comment.