From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: hreba Newsgroups: comp.lang.ada Subject: Accessibility check failed Date: Sun, 10 Aug 2014 23:12:37 -0300 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 0jd0u1TqMNkh/qRlSdEXdA1WuMbKFL8WmfKfJPGoJj5my/hSHk Cancel-Lock: sha1:jCRdnDWFmqDeX6BNlVWAYNrUPQE= User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.0 Xref: news.eternal-september.org comp.lang.ada:21650 Date: 2014-08-10T23:12:37-03:00 List-Id: 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