🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #32525

Re: inherited interfaces question

#32525
From: Jens Geyer
Date: Fri, 22 Nov 2002 09:24
55 lines
2369 bytes
Hello Peter

> It will not fail if the pB instance is implemented by a TInterfacedObject
> descendent.
>
> Type
>   TInterfacedObject = class(TObject, IInterface)
>

I changed the sample code and then with D7 as well with D5 I got an
assertion failure in the line marked with   *******

I can change
   TMyClass = class( TInterfacedObject, IDerived);
to
   TMyClass = class( TInterfacedObject, IDerived, IUnknown);
or to
   TMyClass = class( TInterfacedObject, IDerived, IInterface);
it doesn't matter - in all three cases the assertion comes up.

--- source ----

program Project1;
{$APPTYPE CONSOLE}
uses sysutils;

type
  IBase = interface( IUnknown)
    ['{D95F52B1-F337-4DE2-BF8D-1ACEF13F331A}']
  end;

  IDerived = interface( IBase)
    ['{47114A72-5557-4815-A734-76FE5745E2BA}']
  end;

  TMyClass = class( TInterfacedObject, IDerived);

  procedure TestIt( pB : IBase);
  var  pU : IUnknown;
  begin
     ASSERT( Supports( pB, IUnknown, pU));
     ASSERT( Supports( pU, IBase, pB));  // *******
  end;


var pD,pD2 : IDerived;
    pB,pB2 : IBase;
begin
  pD := TMyClass.Create;
  pB := pD;             // direct assignment works
  ASSERT( pB <> nil);
  ASSERT( Supports( pD, IDerived, pD2));
  TestIt( pD);
  ASSERT( Supports( pB, IBase, pB2));     // will fail
end.
Technical Details
Message-ID: <3dddf51e@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!newsfeed.online.be!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mail
References: <3dda625f$1@newsgroups.borland.com> <VA.00009639.009cb4ab@antispam.compuserve.com> <3ddcaa70$1@newsgroups.borland.com> <VA.0000964e.00747990@antispam.compuserve.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109d30,2f990dd4e4623e73,start
X-Google-Attributes: gid109d30,public
X-Google-ArrivalTime: 2002-11-22 01:17:04 PST
From: "Jens Geyer" <jgx@vsx.net>
Newsgroups: borland.public.delphi.language.objectpascal
References: <3dda625f$1@newsgroups.borland.com> <VA.00009639.009cb4ab@antispam.compuserve.com> <3ddcaa70$1@newsgroups.borland.com> <VA.0000964e.00747990@antispam.compuserve.com>
Subject: Re: inherited interfaces question
Date: Fri, 22 Nov 2002 10:24:08 +0100
Lines: 59
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
NNTP-Posting-Host: 217.80.143.212
Message-ID: <3dddf51e@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1037956382 217.80.143.212 (22 Nov 2002 01:13:02 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!newsfeed.online.be!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mail