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,a9a99a861147e2f8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-19 16:11:17 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn14feed!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: <20021119-223832-295143@foorum.com> Subject: Re: access on function returning a class wide type X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Wed, 20 Nov 2002 00:11:17 GMT NNTP-Posting-Host: 12.86.39.88 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1037751077 12.86.39.88 (Wed, 20 Nov 2002 00:11:17 GMT) NNTP-Posting-Date: Wed, 20 Nov 2002 00:11:17 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:31121 Date: 2002-11-20T00:11:17+00:00 List-Id: "alex" wrote in message news:20021119-223832-295143@foorum.com... > > Is there a "workaround/trick" to implement this kind of think. > > package A is > type A_T is abstract tagged null record; > function Fa return A_T is abstract; > type Fa_Ptr is access function return A_T'Class; > end A; > > with A; > package B is > type B_T is new A.A_T with null record ; > function Fa return B_T; > end B; > > package body B is > function Fa return B_T is > begin return (A.A_T with null record); > end Fa; > end B; > > with A,B; > procedure Test is > Ptr : A.Fa_Ptr := B.Fa'access; -- error : LRM:8.6(28) > begin null; > end Test; > > The compiler is expecting a function returning a A_T'Class, ok I understand. > But, B_T is in the A_T'Class! B_T is in the A_T'Class but a function returning B_T does not return a class-wide type. You have defined Fa_Ptr to be an access type to a function returning a class-wide type rooted in type A_T. Another problem you have is that you are trying to return an instance of an abstract type. You cannot create an instance of an abstract type. Jim Rogers