comp.lang.ada
 help / color / mirror / Atom feed
* Derivation + Access Discriminant = Headaches
@ 1999-03-19  0:00 Matthew Heaney
  1999-03-19  0:00 ` Richard D Riehle
  1999-03-20  0:00 ` Nick Roberts
  0 siblings, 2 replies; 6+ messages in thread
From: Matthew Heaney @ 1999-03-19  0:00 UTC (permalink / raw)


Below is a tagged type hierarchy.

The root is T.  Type T has no discriminant.

Type NT derives from T, and adds a discriminant that designates T'Class.

Type NNT derives from NT, and wants to replace the inherited
discriminant with a discriminant that designates NT'Class.

My expectation is that this should be legal, because NT is in T'Class,
and should therefore be allowed to replace the discriminant that
designates T'Class.

But when I try to compile NNT, my compiler is telling me the subtype of
the discriminant is wrong:

q.ads:5:14: subtype must be compatible with parent discriminant


Is this a compiler bug?  If not, what's the rationale for the
restriction?

Thanks,
Matt


--STX
package P is

   type T is abstract tagged limited private;

   type NT (O : access T'Class) is
     abstract new T with private;

private

   type T is abstract tagged limited null record;

   type NT (O : access T'Class) is new T with null record;

end P;


with P; use P;
package Q is

   type NNT (O : access NT'Class) is
     new NT with private;

private

   type NNT (O : access NT'Class) is
     new NT (O) with null record;

end Q;







^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-03-20  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-19  0:00 Derivation + Access Discriminant = Headaches Matthew Heaney
1999-03-19  0:00 ` Richard D Riehle
1999-03-19  0:00   ` Matthew Heaney
1999-03-19  0:00     ` Stephen Leake
1999-03-20  0:00     ` Richard D Riehle
1999-03-20  0:00 ` Nick Roberts

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