comp.lang.ada
 help / color / mirror / Atom feed
* Visibility for operations of formal private extensions
@ 2000-07-28  0:00 Simon Wright
  0 siblings, 0 replies; only message in thread
From: Simon Wright @ 2000-07-28  0:00 UTC (permalink / raw)


The code below gives compilation errors when compiling the view
conversion in P.Q.R.Proc's body, both in GNAT (3.13a1) and Apex
3.2.0b. They say that there's no visible interpretation: GNAT says

/home/simon/tmp/demo.ada:33:09: no candidate interpretations match the actuals:
/home/simon/tmp/demo.ada:33:15: expected type "New_T" defined at /home/simon/tmp/demo.ada:26
/home/simon/tmp/demo.ada:33:15: found private type "Base" defined at /home/simon/tmp/demo.ada:22
/home/simon/tmp/demo.ada:33:15:   ==> in call to "Proc" at /home/simon/tmp/demo.ada:27
/home/simon/tmp/demo.ada:33:15:   ==> in call to "Proc" at /home/simon/tmp/demo.ada:18(inherited)
/home/simon/tmp/demo.ada:33:15:   ==> in call to "Proc" at /home/simon/tmp/demo.ada:5

If I make P.Proc publicly visible, the compilation goes fine.

I believe we are somewhere near 12.5.1(21) here. My belief that it
should have compiled is based on the following:

* we know that P.Q.R.Base is a P.Q.Q_T

* a P.Q.Q_T (privately) inherits P.Proc

* P.Q.R's body has visiblity of the private part of P and therefore
  should be able to see that P.Q.Q_T inherits P.Proc

Note that P.Q.S's body _can_ see P.Proc.

I tried adding a private component to P.Q.Q_T, P.Q.R.Proc can see it
quite happily .. OK, the LRM reference above is about operations not
data, still!

==================================================================
package P is
    type T is tagged private;
private
    type T is tagged null record;
    procedure Proc (The_T : in out T);
end P;

package body P is
    procedure Proc (The_T : in out T) is
    begin
        null;
    end Proc;
end P;

package P.Q is
    type Q_T is new P.T with private;
private
    type Q_T is new T with null record;
end P.Q;

generic
    type Base is new Q_T with private;
package P.Q.R is
    type New_T is new Base with private;
private
    type New_T is new Base with null record;
    procedure Proc (The_T : in out New_T);
end P.Q.R;

package body P.Q.R is
    procedure Proc (The_T : in out New_T) is
    begin
        Proc (Base (The_T));
    end Proc;
end P.Q.R;

package P.Q.S is
    type S_T is new Q_T with private;
private
    type S_T is new Q_T with null record;
    procedure Proc (The_T : in out S_T);
end P.Q.S;

package body P.Q.S is
    procedure Proc (The_T : in out S_T) is
    begin
        Proc (Q_T (The_T));
    end Proc;
end P.Q.S;

with P.Q.R;
with P.Q.S;
package U is
    package U_P is new P.Q.R (Base => P.Q.S.S_T);
end U;




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-07-28  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-28  0:00 Visibility for operations of formal private extensions Simon Wright

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