From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3ac1d8bc704e79f7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-06 07:33:46 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail Reply-To: "James S. Rogers" From: "James S. Rogers" Newsgroups: comp.lang.ada References: Subject: Re: Dispatching problem. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: Date: Thu, 06 Feb 2003 15:33:45 GMT NNTP-Posting-Host: 12.86.38.254 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1044545625 12.86.38.254 (Thu, 06 Feb 2003 15:33:45 GMT) NNTP-Posting-Date: Thu, 06 Feb 2003 15:33:45 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:33837 Date: 2003-02-06T15:33:45+00:00 List-Id: "Petter Fryklund" wrote in message news:f74cb448.0302060604.e808c22@posting.google.com... > We have the following: > > package A is > type Msg; > type Msg_Ptr is access all Msg'Class; > type Msg is abstract tagged null record; > ... other declarations > > type M1 is new Msg with .... > type M1_Ptr is access all M1; > type M2 is new Msg with .... > type M2_Ptr is access all M2; > ... other declarations > > function X (Param : Integer) return Msg_Ptr; > end A; > > with A; > package B is > type Msg is abstract new A.Msg with null record; > type Msg_Ptr is access all Msg; > type B1 is new A.M1 with null record; > type B1_Ptr is access all B1; > type B2 is new A.M1 with null record; > type B2_Ptr is access all B2; > > procedure Y (MP : access B1); > procedure Y (MP : access B2); > end B; > > with A; > with B; > procedure Main is > > X : A.Msg_Ptr; > Y : A.Msg_Ptr; > begin > X := A.X (1); -- Building a A.M1 > Y := A.X (2); -- Building a A.M2 > B.Y (B.Msg_Ptr (X)); -- causes Constraint_Error Tag Check Failed to be raised. > end Main; > > How can we dispatch in package B? You seem to have your inheritence concepts inverted here. Every B.B1 is a member of the class rooted at A.Msg. Not every A.Msg is a member of B.B1. For instance, A.M1 is not a B.B1. Jim Rogers