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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.129.158.144 with SMTP id v138mr21273172ywg.30.1495752789226; Thu, 25 May 2017 15:53:09 -0700 (PDT) X-Received: by 10.157.14.91 with SMTP id n27mr397198otd.8.1495752789175; Thu, 25 May 2017 15:53:09 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!l39no314201qtb.0!news-out.google.com!v18ni2143ita.0!nntp.google.com!67no511499itx.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 25 May 2017 15:53:08 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.201.205; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.201.205 References: <4a47e4cd-829c-4451-abf1-82cf60b67706@googlegroups.com> <9cdf04e6-123e-4bd9-b466-77aad00d61bb@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <62e326e6-dd15-4546-83dc-b1e423327c23@googlegroups.com> Subject: Re: Preventing private procedure visibility being made public through extension From: Jere Injection-Date: Thu, 25 May 2017 22:53:09 +0000 Content-Type: text/plain; charset="UTF-8" Xref: news.eternal-september.org comp.lang.ada:46866 Date: 2017-05-25T15:53:08-07:00 List-Id: On Thursday, May 25, 2017 at 3:40:01 PM UTC-4, Randy Brukardt wrote: > Your probably having trouble with the appropriaate view of My_Type. The full > type of My_Type has both versions of Create (of course), as it inherits from > View_Type. If you try to extend somewhere where that full view is visible, > then that extension too will get both Creates. (That includes in the body > and in any child packages.) > > OTOH, an extension somewhere that only has visibility on the private type, > you should only get one (visible) Create. (But the other one is still > inherited, it just can't be called directly.) > > I could go into more detail if you need that; it would help to have a full > compilable example in that case so I can see where everything is declared. > > Randy. > > This might be a better example. I have 3 tiers: Base/Derived/More_Derived More_Derived publicly inherits off of Base but privately inherits off of Derived. Derived provides a Something procedure and More_Derived provides a Something procedure but uses a different signature and is not overriding (I double checked by putting "overriding" with it and noted the compiler error). More_Derived does not have private view of Derived, but GNAT still says there is a ambiguity. I don't see how More_Derived has a private view of Derived, so I think this is a bug, but I might be missing something. main.adb ******************************************* with Base; with Derived; with More_Derived; procedure Main is p : Base.Derived_Param; subtype My_Type is More_Derived.More_Derived_Type; m : My_Type; begin m.Something(p); -- ERROR: ambiguous call to Something end Main; ******************************************* base.ads ************************************************* package Base is type Base_Param is tagged null record; type Derived_Param is new Base.Base_Param with null record; type Base_Type is tagged null record; end Base; ************************************************* derived.ads ************************************************* with Base; package Derived is type Derived_Type is new Base.Base_Type with null record; procedure Something (Obj : in out Derived_Type; Value : Base.Base_Param'Class) is null; end Derived; ************************************************* more_derived.ads ************************************************* with Base; with Derived; package More_Derived is type More_Derived_Type is new Base.Base_Type with private; procedure Something (Obj : in out More_Derived_Type; Value : Base.Derived_Param'Class) is null; private type More_Derived_Type is new Derived.Derived_Type with null record; end More_Derived; ************************************************* If I don't use the subtype in main.adb, it compiles fine.