From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Cannot call primitive op for generic formal derived type: why not?
Date: 1999/09/02
Date: 1999-09-02T00:00:00+00:00 [thread overview]
Message-ID: <37cf2237@news1.us.ibm.net> (raw)
I have a type hierarchy, rooted at P.T, with a private, primitive operation,
here called Private_Op.
The root package P has a generic child, P.C, with a generic formal type that
derives from T, here called NT. P.C has a public operation, Op, that takes
NT as an access parameter.
The body of P.C.Op tries to call the primitive operation Private_Op. This
seems like it should be legal, because NT derives from T, and T has
Private_Op as a primitive operation (so NT should have inherited it).
Yet my compiler is telling me that the call to Private_Op is illegal:
p-c.adb:5:19: expected type access to "T" defined at p.ads:9
p-c.adb:5:19: found type access to "Nt" defined at p-c.ads:5
It seems as if the compiler doesn't acknowledge that Private_Op is primitive
for NT.
What's up with that? Is this a compiler bug, or is this program not legal
Ada?
I thought the whole point of importing a derived type is precisely to be
able to call the primitive operations for types in that class. Is this
expectation incorrect?
Thanks in advance,
Matt
--STX
package P is
type T is abstract tagged limited private;
private
type T is abstract tagged limited null record;
procedure Private_Op (O : access T);
end P;
package body P is
procedure Private_Op (O : access T) is
begin
null;
end;
end P;
generic
type NT is new T with private;
package P.C is
procedure Op (O : access NT);
end P.C;
package body P.C is
procedure Op (O : access NT) is
begin
Private_Op (O);
end Op;
end P.C;
next reply other threads:[~1999-09-02 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-09-02 0:00 Matthew Heaney [this message]
1999-09-03 0:00 ` Cannot call primitive op for generic formal derived type: why not? David C. Hoos, Sr.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox