Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-07

Verify Method Calls

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hello,

I would like to use "Verify Method Calls" (-CR), but when I choose it in the Lazarus project options under debugging, I get compiler errors such as:

Incompatible type for arg no.2: Got "Class Of IZCollection", expected "TClass".

With Verify Method Calls off, the same code compiles fine.

The offending line is from ZEOS lib, ZCollections.pas:

HashMap.FKeys := IZCollection(FKeys.Clone);

I wonder why it says "arg no.2".

Any ideas? Is it possible to turn "Verify Method Calls" off via a {$xxx } switch in the source code?

Cheers,
Tobias

Reply by email

Jonas Maebe
to Unknown author
Show quoted text 12 lines
I would like to use "Verify Method Calls" (-CR), but when I choose it in the Lazarus project options under debugging, I get compiler errors such as: Incompatible type for arg no.2: Got "Class Of IZCollection", expected "TClass". With Verify Method Calls off, the same code compiles fine. The offending line is from ZEOS lib, ZCollections.pas: HashMap.FKeys := IZCollection(FKeys.Clone); I wonder why it says "arg no.2".

Try compiling with -vh, it may show more info. -CR basically turns all object/class typecasts into "as"-like expressions, but in a way that you can still pass them to var/out-parameters.

Is it possible to turn "Verify Method Calls" off via a {$xxx } switch in the source code?

No.

Jonas

Reply by email

Unknown author
to Jonas Maebe

Hello,
many thanks for your reply! -vh didn't show more info, but I was able to reduce the source to a small program, maybe you can try it? Compiling it with -CR fails, but without it compiles fine without warnings. Unfortunately there are many typecasts like these and I don't know how to solve it.
Best wishes,
Tobias Giesen

-----------------
program AnInterfaceTest;
uses Classes;
type
  {** Replacement for generic interface type. }
  IZInterface = IUnknown;
  {** Represents an interface for all abstract object. }
  IZObject = interface(IZInterface)
    ['{EF46E5F7-00CF-4DDA-BED0-057D6686AEE0}']
    function Clone: IZInterface;
  end;
  {** Represents an interface to clone objects. }
  IZClonnable = interface(IZObject)
    ['{ECB7F3A4-7B2E-4130-BA66-54A2D43C0149}']
  end;
  {** Represents a collection of object interfaces. }
  IZCollection = interface(IZClonnable)
    ['{51417C87-F992-4CAD-BC53-CF3925DD6E4C}']
  end;
  {** Represents a hash map interface. }
  IZHashMap = interface(IZClonnable)
    ['{782C64F4-AD09-4F56-AF2B-E4193A05BBCE}']
  end;
  {** Implements an abstract interfaced object. }
  { TZAbstractObject }
  TZAbstractObject = class(TInterfacedObject, IZObject)
  public
    function Clone: IZInterface; virtual;
  end;
  { TZHashMap }
  TZHashMap = class(TZAbstractObject, IZHashMap, IZClonnable)
  private
    FKeys: IZCollection;
  public
    constructor Create;
    destructor Destroy; override;
    function Clone: IZInterface; override;
  end;

{ TZAbstractObject }

function TZAbstractObject.Clone: IZInterface;
begin
  result := nil; // needs to be overriden
  end;

{ TZHashMap }

constructor TZHashMap.Create;
begin
end;
destructor TZHashMap.Destroy;
begin
 inherited Destroy;
end;
function TZHashMap.Clone: IZInterface;
var
  HashMap: TZHashMap;
begin
  HashMap := TZHashMap.Create;
  HashMap.FKeys := IZCollection(FKeys.Clone);
  Result := HashMap;
end;
begin
end.

-----------------

Kind Regards,

Tobias Giesen

----

Show quoted text 26 lines
On 04/07/16 19:38, wrote: > I would like to use "Verify Method Calls" (-CR), but when I choose it in the Lazarus > project options under debugging, I get compiler errors such as: > > Incompatible type for arg no.2: Got "Class Of IZCollection", expected "TClass". > > With Verify Method Calls off, the same code compiles fine. > > The offending line is from ZEOS lib, ZCollections.pas: > > HashMap.FKeys := IZCollection(FKeys.Clone); > > I wonder why it says "arg no.2". Try compiling with -vh, it may show more info. -CR basically turns all object/class typecasts into "as"-like expressions, but in a way that you can still pass them to var/out-parameters. > Is it possible to turn "Verify Method Calls" off via a {$xxx } switch in the > source code? No. Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Kind Regards,
Tobias Giesen

Super Flexible Software Ltd. & Co. KG
Buddenstr. 29-31
48143 Münster, Germany
www.superflexible.com
www.tgtools.com

----------------------------------------------------------- Registered at register court Münster as HRA 9716
Liability / general partner: TGTools Ltd.
Company No. 05513299
Registered in England and Wales
Directors: Tobias Giesen and Claudia Giesen

Reply by email

Jonas Maebe
to Unknown author
many thanks for your reply! -vh didn't show more info, but I was able to reduce the source to a small program, maybe you can try it? Compiling it with -CR fails, but without it compiles fine without warnings.

Indeed. Please file a bug report.

Jonas

Reply by email