comp.lang.ada
 help / color / mirror / Atom feed
From: Jere <jhb.chat@gmail.com>
Subject: Re: Preventing private procedure visibility being made public through extension
Date: Thu, 25 May 2017 15:53:08 -0700 (PDT)
Date: 2017-05-25T15:53:08-07:00	[thread overview]
Message-ID: <62e326e6-dd15-4546-83dc-b1e423327c23@googlegroups.com> (raw)
In-Reply-To: <og7bug$9lq$1@franka.jacob-sparre.dk>

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.

  reply	other threads:[~2017-05-25 22:53 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-20 17:33 Preventing private procedure visibility being made public through extension Jere
2017-05-20 20:13 ` AdaMagica
2017-05-20 21:55   ` Jere
2017-05-20 20:32 ` Dmitry A. Kazakov
2017-05-20 22:51   ` Jere
2017-05-21  0:51     ` Jere
2017-05-21  9:16       ` Chris Moore
2017-05-21 22:55         ` Jere
2017-05-21  8:44     ` Dmitry A. Kazakov
2017-05-21 12:19       ` J-P. Rosen
2017-05-21 12:53         ` Dmitry A. Kazakov
2017-05-21 20:06       ` Jere
2017-05-21 21:07         ` Dmitry A. Kazakov
2017-05-21 22:28           ` Jere
2017-05-22  8:52             ` Dmitry A. Kazakov
2017-05-22 13:33               ` AdaMagica
2017-05-22 13:43           ` AdaMagica
2017-05-22 21:17         ` Randy Brukardt
2017-05-25  4:06           ` Jere
2017-05-25 19:39             ` Randy Brukardt
2017-05-25 22:53               ` Jere [this message]
2017-05-25 22:57                 ` Jere
2017-05-26 20:46                 ` Randy Brukardt
2017-05-26 22:35                   ` Simon Wright
2018-05-20 11:22                     ` Simon Wright
2018-05-20 12:03                       ` Jere
2017-05-26 22:58                   ` Jeffrey R. Carter
2017-05-30 21:15                     ` Randy Brukardt
2017-06-02  1:07                       ` Jere
2017-06-02  7:31                         ` Dmitry A. Kazakov
2017-06-02  8:09                         ` Mark Lorenzen
2017-06-02 11:31                         ` Simon Wright
2017-05-22 21:12   ` Randy Brukardt
2017-05-23  7:38     ` Dmitry A. Kazakov
2017-05-21 18:14 ` Robert Eachus
2017-05-21 20:21   ` Jere
2017-05-21 21:09     ` Jeffrey R. Carter
2017-05-21 22:46       ` Jere
2017-05-22 21:24         ` Jeffrey R. Carter
2017-05-25  3:45           ` Jere
2017-05-21 21:20     ` Dmitry A. Kazakov
2017-05-21 21:45       ` Jere
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox