View Issue Details

IDProjectCategoryView StatusLast Update
0027847PackagesLCLpublic2019-12-30 13:52
ReporterAnthony Walter Assigned ToJuha Manninen  
Status resolvedResolutionfixed 
Product Version1.5 (SVN) 
Summary0027847: CodeTools see generics as an error
DescriptionHere is a video of the problem with CodeTools:

When declaring a class with a generic interface referencing itself e.g. TPen = class(TGraphicsObject<TPen>) anytime code insight is invoke CodeTools displays and error in the and jumps to the class definition.

What should happen is that CodeTools sees a line such as:

Pen.Color := clRed;

As valid syntax, and provide a proper class insight dropdown when a user types:

Pen.[ctrl + space]
Steps To Reproduceprogram test;

{$mode delphi}

  TClone<T> = interface
   function Clone: T;

  TGraphicObject<T> = class(TInterfacedObject, TClone<T>)
    function Clone: T; virtual; abstract;

  TPen = class;

  TPen = class(TGraphicObject<TPen>)
    function Clone: TPen; override;

function TPen.Clone: TPen;
  Result := TPen.{<- press ctrl space here for code tools error}Create;

Tagscodetools, generics
Fixed in Revision
Attached Files


related to 0023903 resolvedMattias Gaertner Lazarus Complete code error 
related to 0030124 resolvedJuha Manninen Lazarus specialize TFPGList<Int64> declaration is not supported by CodeTools 
related to 0030349 new Lazarus [codetools] Codetools doesn't recognize generic procedure inside a normal class, thus normal codetools functions will fail. 
related to 0031944 closedMattias Gaertner Lazarus Codetools: a semicolon (;) is inserted after "specialize" when using Codecompletion on generics 


Anthony Walter

2015-04-14 00:43

reporter   ~0082893

I am prepping to release version 2 of Bare Game, and in doing so am producing a "lets make a game" video series where I show a cross platform game running on Windows, Linux, Macintosh, and the Ouya console (a basic android system).

I am hoping the video tutorial series which takes someone from a non programming background, introduces them to Free Pascal and Lazarus, and teaches basic of game development skills using Bare Game in a series of 14 videos.

The problem is there are a few issues with CodeTools which I think may hamper new users.

One problem in particular deals with code insight, which helps Lazarus users find methods on objects. Users can normally press ctrl+space after the dot of an object and get a drop down list of properties, methods, and other information related to a class or record.

In Bare.Game library though I make use of clonable objects (cloning a sprite, cloning a pen, cloning a vector graphics path for example) and their definitions typically look like this:

TGraphicObject = class(TPersistObject, ICloneable<T>)
TPen = class(TGraphicObject<TPen>)

If I could get some help understanding CodeTools I could fix these errors and possibly a few others, but I honestly hesitate to put out this tutorial when I know new users are going to struggle if CodeTools constantly jumps to source code units telling theme there is an error, when in fact there are no errors.


2015-05-17 00:26

reporter   ~0083672

The same happens when you use objfpc syntax, i.e.

generic TGraphicObject<T> = class(TInterfacedObject, specialize TClone<T>)

The error is 'Identifier not found: specialize'.

Juha Manninen

2019-12-30 13:52

developer   ~0120149

This is fixed at some point. Please test.

Issue History

Date Modified Username Field Change
2015-04-14 00:20 Anthony Walter New Issue
2015-04-14 00:21 Anthony Walter Tag Attached: codetools
2015-04-14 00:21 Anthony Walter Tag Attached: generics
2015-04-14 00:43 Anthony Walter Note Added: 0082893
2015-04-14 02:02 Mattias Gaertner Assigned To => Mattias Gaertner
2015-04-14 02:02 Mattias Gaertner Status new => assigned
2015-05-17 00:26 Martok Note Added: 0083672
2015-12-10 15:14 Mattias Gaertner Relationship added related to 0023903
2016-05-19 00:09 Juha Manninen Relationship added related to 0030124
2016-10-08 11:34 Juha Manninen Relationship added related to 0030349
2017-06-01 18:10 Juha Manninen Relationship added related to 0031944
2019-12-30 13:51 Juha Manninen Assigned To Mattias Gaertner => Juha Manninen
2019-12-30 13:52 Juha Manninen Status assigned => resolved
2019-12-30 13:52 Juha Manninen Resolution open => fixed
2019-12-30 13:52 Juha Manninen LazTarget => -
2019-12-30 13:52 Juha Manninen Note Added: 0120149