comp.lang.ada
 help / color / mirror / Atom feed
* Accessibility check failed
@ 2014-08-11  2:12 hreba
  2014-08-11  5:32 ` Jeffrey Carter
  2014-08-11 19:56 ` sbelmont700
  0 siblings, 2 replies; 20+ messages in thread
From: hreba @ 2014-08-11  2:12 UTC (permalink / raw)


One more beginner's question.

I wrote a linear list of abstract items.
There is an abstract type Iterator with an abstract method Proc which 
can be called with a class wide item type. Procedure Iterate calls Proc 
with each item of the list.

For a test I declared a concrete extension extension of Gen.Lists.ItemD.
I also declare a concrete extension of Iterator called Writer and a 
concrete method Proc.

Everything compiles, but at runtime the line

          i:= Item(itm);

in Proc generates a "accessibility check failed" error.

I checked with a debugger that itm is not null and that its actual 
(dynamic) type is that of the concrete extension.

So what is wrong?

A more complete extract of my program follows.

---------------------

package Gen.Lists is

    type ItemD is abstract tagged private;
    type List is limited private;

    type Iterator is abstract tagged null record;
    procedure Proc (iter: in out Iterator; itm: access ItemD'Class) is 
abstract;
    procedure Iterate (ic: in out Iterator'Class; l: List);

end Gen.Lists;

--------------------

with Gen.Lists;

package test_lists_aux is

    type ItemD is new Gen.Lists.ItemD with
       record
          ch:	Character;
       end record;
    type Item is access all ItemD;

    type Writer is new Gen.Lists.Iterator with null record;
    procedure Proc (w: in out Writer; itm: access Gen.Lists.ItemD'Class);

end test_lists_aux;

-----------------

with Ada.Text_IO;	use Ada.Text_IO;

package body test_lists_aux is

    procedure Proc (w: in out Writer; itm: access Gen.Lists.ItemD'Class) is
       i: Item;
    begin
       if itm.all in ItemD then
          i:= Item(itm);
       end if;
       Put (i.ch);
       --Put (Item(itm).ch);
    end Proc;

end test_lists_aux;


-- 
Frank Hrebabetzky		+55 / 48 / 3235 1106
Florianopolis, Brazil


^ permalink raw reply	[flat|nested] 20+ messages in thread
* accessibility check failed
@ 2015-11-29 18:03 Serge Robyns
  2015-11-29 18:37 ` Jeffrey R. Carter
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Serge Robyns @ 2015-11-29 18:03 UTC (permalink / raw)


I'm facing a "mysterious" accessibility check failed error.

I'm having the following function:

   overriding function Get_Client
     (Self        : not null access T_Data_Store;
      Client_Name : in              T_Client_Name)
      return T_Client'Class
   is
      Cursor : Client_Map.Cursor;
   begin
      Cursor := Self.Clients.Find (Client_Name);
      if Cursor = Client_Map.No_Element then
         return T_Client_DAO'(No_Client
                                  with Store => Self);
      end if;
      return T_Client_DAO'(T_Client (Client_Map.Element (Cursor))
                               with Store => Self);
   end Get_Client;

The definition of T_Client_DAO is:
   type T_Client_DAO is new T_Client with record
      Store : access T_Abstract_Data_Store'Class;
   end record;

T_Client is the object with is methods.  T_Abstract_Data_Store is the assembly of Factory interfaces (see below for an example).

The idea is to return a copy of the client record and store with it a reference to the data store class from which the object came from.  This will allow to use my_object.change_XYZ to update the object and it's representation into the store through that reference.

Researching the web for the accessibility check failed all refers to returning a reference to a local variable which is indeed disappearing on the execution of the return statement.  But in my case, I'm just storing the reference I did receive from the parent.

I did find a suggestion to replace anonymous access types to named ones but that does not compile for the interface class for which the above function is an implementation.
 
   type Factory is limited interface;
   type Factory_Access is access Factory;

   function Get_Client
     (Self        : Factory_Access;
      Client_Name : in T_Instrument_Name)
      return T_Client'Class
     is abstract;

with:
warning: abstract subprogram is not dispatching or overriding

However when using not null access T_Factory instead it does compile.

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-12-01 20:17 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-11  2:12 Accessibility check failed hreba
2014-08-11  5:32 ` Jeffrey Carter
2014-08-11 16:45   ` hreba
2014-08-11 16:55     ` Jeffrey Carter
2014-08-12 11:57       ` hreba
2014-08-11 19:56 ` sbelmont700
2014-08-11 20:17   ` Jeffrey Carter
2014-08-11 20:28     ` sbelmont700
2014-08-11 21:14       ` Jeffrey Carter
  -- strict thread matches above, loose matches on Subject: below --
2015-11-29 18:03 accessibility " Serge Robyns
2015-11-29 18:37 ` Jeffrey R. Carter
2015-11-29 19:00   ` Serge Robyns
2015-11-29 22:32     ` Jeffrey R. Carter
2015-11-29 22:53       ` Serge Robyns
2015-11-30  2:04         ` Jeffrey R. Carter
2015-11-30 23:22         ` Randy Brukardt
2015-12-01  9:38           ` Serge Robyns
2015-11-29 19:15 ` Dmitry A. Kazakov
2015-11-29 22:40 ` Serge Robyns
2015-12-01 20:17 ` sbelmont700

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox