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!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Preventing private procedure visibility being made public through extension Date: Fri, 26 May 2017 15:46:42 -0500 Organization: JSA Research & Innovation Message-ID: References: <4a47e4cd-829c-4451-abf1-82cf60b67706@googlegroups.com> <9cdf04e6-123e-4bd9-b466-77aad00d61bb@googlegroups.com> <62e326e6-dd15-4546-83dc-b1e423327c23@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: franka.jacob-sparre.dk 1495831602 14331 24.196.82.226 (26 May 2017 20:46:42 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 26 May 2017 20:46:42 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:46868 Date: 2017-05-26T15:46:42-05:00 List-Id: Ah, a subtype. GNAT has (or had?)a bug having to do with making things visible because of a subtype declaration (I recall someone else running across that and having verified it myself). That's just plain wrong, a subtype has no effect on what's visible in a prefixed call (or anywhere else for that matter, in particular with "use all type"). You ought to have an ambiguity if you tried to call Something in the body of More_Derived, but it should be OK in the main subprogram. I'd skip the subtype and just use the real name of the type. And possibly make a bug report to AdaCore. You could also use a traditional call (More_Derived.Something (M, P);) which would avoid the buggy part of GNAT. Randy. "Jere" wrote in message news:62e326e6-dd15-4546-83dc-b1e423327c23@googlegroups.com... > 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.