View Issue Details

IDProjectCategoryView StatusLast Update
0036477FPCCompilerpublic2019-12-24 17:34
ReporterFrederic Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformX64OSLinux 
Product Version3.0.4 
Summary0036477: Generic Specialization Name Collision
DescriptionWhen using using multiple generic classes and specialzing them in function type definitons it results in a name collision. This does not occur when specializing in the class header

The example given shows this behaviour. Controlled via the macro Broken, the type is specialized either in the function definition (which results in the error) or in the class definition (which works fine)

Tested on Arch and Debian with fpc 3.0.4
Tagsgenerics
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Relationships

related to 0035992 assignedSven Barth Problems with Generic speciaization 

Activities

Frederic

2019-12-24 17:15

reporter  

test.pas (753 bytes)   
unit Test;

{$mode ObjFPC}{$H+}
{$Interfaces CORBA}
{$Define Broken}

interface

uses
  Classes, SysUtils, fgl;

type
  generic IFoo<T> = interface
    function get: specialize IFoo<T>;
  end;

  { TBar }

  generic TBar<T> = class(TObject, specialize IFoo<T>)
    function get: specialize IFoo<T>;
  end;

  { TFooBar }

  generic TFooBar<T> = class
    type IFoo_T = specialize IFoo<T>;
    {$IfnDef Broken}
    type TBar_T = specialize TBar<T>;
    {$endif}
  private
    FFoo: IFoo_T;
  public
    constructor Create;
  end;

implementation

{ TFooBar }

constructor TFooBar.Create;
{$ifdef Broken}
type
  TBar_T = specialize TBar<T>;
{$endif}
begin
  FFoo := TBar_T.Create;
end;

{ TBar }

function TBar.get: specialize IFoo<T>;
begin

end;

end.

test.pas (753 bytes)   

Issue History

Date Modified Username Field Change
2019-12-24 17:15 Frederic New Issue
2019-12-24 17:15 Frederic File Added: test.pas
2019-12-24 17:33 Sven Barth Tag Attached: generics
2019-12-24 17:34 Sven Barth Relationship added related to 0035992