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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1d9d69d55b9d5ba7 X-Google-Attributes: gid103376,public From: Tucker Taft Subject: Re: generic formal derived type that inherits private op Date: 1999/11/12 Message-ID: <382C85D9.E411A4CB@averstar.com>#1/1 X-Deja-AN: 547899634 Content-Transfer-Encoding: 7bit Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.burl.averstar.com References: <382b8c0b_1@news1.prserv.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: AverStar (formerly Intermetrics) Burlington, MA USA Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-12T00:00:00+00:00 List-Id: Matthew Heaney wrote: > > There's some code below that I think should work, but doesn't: > > 1) A generic child package imports a generic formal type that derives > from a (tagged) type declared in the parent package. > > 2) The parent type declares a primitive operation privately; that is, in > the private region of the parent package. > > 3) The generic child package tries to call the (private) primitive > operation of the derived type, but the compiler doesn't think the > derived type comes with that operation. This appears to be incorrect. > > Here's the output of my compiler (GNAT v3.12p): > > p-c.adb:5:19: expected type access to "T" defined at p.ads:9 > p-c.adb:5:19: found type access to "Nt" defined at p-c.ads:5 > > What's the scoop? Is this correct or not? Your code is correct. The compiler seems to have a bug (and the ACVC suite seems to have a hole in this area). > > (Tucker: I submitted this same code to CLA a few months ago. Remember > we talked about it at the ARG meeting a few weeks ago?) Yes, and we had pretty much the same problem in our compiler, which we have since fixed. So now My Favorite Ada95 Front End likes your code. ;-) > > Thanks, > Matt > > --STX > package P is > > type T is abstract tagged limited private; > > private > > type T is abstract tagged limited null record; > > procedure Private_Op (O : access T); > > end P; > > package body P is > > procedure Private_Op (O : access T) is > begin > null; > end; > > end P; > > generic > type NT is new T with private; > package P.C is > > procedure Op (O : access NT); > > end P.C; > > package body P.C is > > procedure Op (O : access NT) is > begin > Private_Op (O); > end Op; > > end P.C; -- -Tucker Taft stt@averstar.com http://www.averstar.com/~stt/ Technical Director, Distributed IT Solutions (www.averstar.com/tools) AverStar (formerly Intermetrics, Inc.) Burlington, MA USA