View Issue Details

IDProjectCategoryView StatusLast Update
0035709FPCCompilerpublic2019-06-14 07:51
ReporterImants GulbisAssigned ToSven Barth 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Product Version3.2.0Product Build 
Target VersionFixed in Version 
Summary0035709: Single generic method in class
DescriptionIt is not possible to compile project in objfpc mode who specialize single generic method defined inside class. It is possible to compile project in delphi mode.

I attached bought examples in objfpc mode and delphi mode
Tagsgenerics
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Imants Gulbis

2019-06-12 14:27

reporter  

notworking.7z (60,271 bytes)
working.7z (60,275 bytes)

Sven Barth

2019-06-13 23:18

manager   ~0116717

Your specialization is wrong:

=== code begin ===

R := specialize C.Get<TWinControl>();

=== code end ===

This needs to be the following:

=== code begin ===

R := C.specialize Get<TWinControl>();

=== code end ===

The "specialize" keyword is part of the generic symbol that needs to be specialized, not a prefix of the whole expression. This becomes more apparant when you have multiple specializations:

=== code begin ===

// assume Get<> is a class function of a generic TGComponent<>
R := specialize TGComponent<TSomeType>.specialize Get<TWinControl>();

=== code end ===

Also next time please provide examples that don't depend on Lazarus.

Imants Gulbis

2019-06-14 07:51

reporter   ~0116719

-

Issue History

Date Modified Username Field Change
2019-06-12 14:27 Imants Gulbis New Issue
2019-06-12 14:27 Imants Gulbis File Added: notworking.7z
2019-06-12 14:27 Imants Gulbis File Added: working.7z
2019-06-13 23:14 Sven Barth Tag Attached: generics
2019-06-13 23:18 Sven Barth Assigned To => Sven Barth
2019-06-13 23:18 Sven Barth Status new => resolved
2019-06-13 23:18 Sven Barth Resolution open => no change required
2019-06-13 23:18 Sven Barth FPCTarget => -
2019-06-13 23:18 Sven Barth Note Added: 0116717
2019-06-14 07:51 Imants Gulbis Status resolved => closed
2019-06-14 07:51 Imants Gulbis Note Added: 0116719