From: "Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org>
Subject: Ambiguous reference - What is wrong with this?
Date: Tue, 14 Aug 2001 11:14:30 -0400
Date: 2001-08-14T15:14:31+00:00 [thread overview]
Message-ID: <9lbf8n$brf$1@nh.pace.co.uk> (raw)
O.K. I've got a compilation problem that is most likely due to my
misunderstanding of some language rule. Below is some code that shows a
simplified version of the problem. I'm using Gnat 3.13p on a WinNT PC.
I'm pretty sure that the problem has something to do with the 'Class
parameters creating some kind of ambiguity - but given that I've fully
qualified the names, it seems like the compiler ought to know which
procedure I meant to call. The quest6ion is twofold: Am I doing something
illegal (if so, what?) and if it *is* illegal, then is there an alternate
way of doing essentially the same thing? (One parameter being of a specific
descendent and the other being a class-wide parameter. The class wide
parameter wants to be an increasingly restrictive subset as you move down
the chain of child packages)
package Root is
type Base is tagged private ;
procedure Some_Proc (
Object : in out Base;
Object2 : in out Base'Class) ;
private
type Base is tagged record
Data_Item_1 : Natural := 0 ;
end record ;
end Root ;
package body Root is
procedure Some_Proc (
Object : in out Base;
Object2 : in out Base'Class) is
begin
null ;
end Some_Proc ;
end Root ;
package Root.Child1 is
type Derive1 is new Base with private ;
procedure Some_Proc (
Object : in out Derive1;
Object2 : in out Derive1'Class) ;
private
type Derive1 is new Base with record
Data_Item_2 : Natural := 0 ;
end record ;
end Root.Child1 ;
package body Root.Child1 is
procedure Some_Proc (
Object : in out Derive1;
Object2 : in out Derive1'Class) is
begin
Root.Some_Proc (
Object => Root.Base (Object),
Object2 => Object2) ;
end Some_Proc ;
end Root.Child1 ;
package Root.Child1.Child2 is
type Derive2 is new Derive1 with private ;
procedure Some_Proc (
Object : in out Derive2;
Object2 : in out Derive2'Class) ;
private
type Derive2 is new Derive1 with record
Data_Item_3 : Natural := 0 ;
end record ;
end Root.Child1.Child2 ;
package body Root.Child1.Child2 is
procedure Some_Proc (
Object : in out Derive2;
Object2 : in out Derive2'Class) is
begin
--
-- Dies here with the following error message:
--
-- root-child1-child2.adb:15:20: ambiguous expression (cannot
resolve "Some_Proc")
-- root-child1-child2.adb:15:20: possible interpretation at
root-child1.ads:4
-- root-child1-child2.adb:15:20: possible interpretation at
root-child1.ads:3
-- gnatmake: "root-child1-child2.adb" compilation error
--
Root.Child1.Some_Proc (
Object => Root.Child1.Derive1 (Object),
Object2 => Object2) ;
end Some_Proc ;
end Root.Child1.Child2 ;
Thanks for any help you can offer.
MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas www.pacemicro.com
Enabling the digital revolution
e-Mail: marin.condic@pacemicro.com
Web: http://www.mcondic.com/
next reply other threads:[~2001-08-14 15:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-14 15:14 Marin David Condic [this message]
2001-08-14 16:56 ` Ambiguous reference - What is wrong with this? Warren W. Gay VE3WWG
2001-08-14 17:45 ` Warren W. Gay VE3WWG
2001-08-14 17:54 ` Marin David Condic
2001-08-14 19:24 ` Warren W. Gay VE3WWG
2001-08-14 17:44 ` Sergey Koshcheyev
2001-08-14 20:10 ` Marin David Condic
2001-08-15 7:38 ` Sergey Koshcheyev
2001-08-15 13:49 ` Marin David Condic
2001-08-14 20:02 ` tmoran
2001-08-15 6:17 ` Simon Wright
2001-08-17 16:34 ` Marin David Condic
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox