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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,87cefb21a3c43af8,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news3.google.com!news.glorb.com!proxad.net!cleanfeed2-a.proxad.net!nnrp11-1.free.fr!not-for-mail Message-Id: <44b91f16$0$27041$626a54ce@news.free.fr> From: Yves Bailly Subject: Trouble with overriding and class-wide parameters Newsgroups: comp.lang.ada Date: Sat, 15 Jul 2006 19:00:00 +0200 User-Agent: KNode/0.10.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit Organization: Guest of ProXad - France NNTP-Posting-Date: 15 Jul 2006 19:00:07 MEST NNTP-Posting-Host: 81.56.171.53 X-Trace: 1152982807 nnrp11-1.free.fr 27041 81.56.171.53:55657 X-Complaints-To: abuse@proxad.net Xref: g2news2.google.com comp.lang.ada:5706 Date: 2006-07-15T19:00:07+02:00 List-Id: Hello all, Here's a problem I'm encountering, while developping a (rather huge) library using Ada 2005, for now using only the latest GNAT GPL compiler from AdaCore (i.e. GNAT-2006). Given a first package, defining a tagged type: --8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--- package Pkg is type Some_Type is tagged null record; not overriding procedure Setup(st: not null access Some_Type; p : access Some_Type'Class); end Pkg; --8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--- The procedure just Put_Line() a string to identify itself. Then take a second package, with a type derived from the previous: --8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--- with Pkg; use Pkg; package Sub_Pkg is type Sub_Type is new Some_Type with null record; not overriding procedure Setup(st: not null access Sub_Type; p : access Sub_Type'Class); end Sub_Pkg; --8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--- Here again the procedure just print something to identify itself. Now the test program: --8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--- with Pkg; use Pkg; with Sub_Pkg; use Sub_Pkg; procedure Test is st: aliased Sub_Type; begin st.Setup(null); end Test; --8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--- I would expect the call to Setup() to invoke the Sub_Pkg.Setup() procedure, as "st" is of type Sub_Type. However the procedure actually called is Pkg.Setup(), as shown by the output : Pkg.Setup(Some_Type) What am I missing? I suspect the value "null" to be part of this, but I can't find a workaround. Sorry in advance if it's a silly question, I have a huge background of C++ and not yet very skilled with Ada type system. Thanks for any hint ! Best regards, -- (o< | Yves Bailly : http://kafka-fr.net | -o) //\ | Linux Dijon : http://www.coagul.org | //\ \_/ | | \_/`