* fix for Mantis : also handle "generic" keyword inside helper types

+ added test

git-svn-id: trunk@42328 -
This commit is contained in:
svenbarth 2019-07-05 14:12:13 +00:00
parent a2ce2cea94
commit d0eddbcbb9
3 changed files with 38 additions and 1 deletions

1
.gitattributes vendored
View File

@ -16668,6 +16668,7 @@ tests/webtbs/tw3564.pp svneol=native#text/plain
tests/webtbs/tw3567.pp svneol=native#text/plain
tests/webtbs/tw3572.pp svneol=native#text/plain
tests/webtbs/tw3573.pp svneol=native#text/plain
tests/webtbs/tw35735.pp svneol=native#text/pascal
tests/webtbs/tw3576.pp svneol=native#text/plain
tests/webtbs/tw3577.pp svneol=native#text/plain
tests/webtbs/tw3578.pp svneol=native#text/plain

View File

@ -1268,7 +1268,10 @@ implementation
begin
if (idtoken=_GENERIC) and
not (m_delphi in current_settings.modeswitches) and
not fields_allowed then
(
not fields_allowed or
is_objectpascal_helper(current_structdef)
) then
begin
if hadgeneric then
Message(parser_e_procedure_or_function_expected);

33
tests/webtbs/tw35735.pp Normal file
View File

@ -0,0 +1,33 @@
{ %NORUN }
program tw35735;
{$Mode objfpc}
uses
Classes, SysUtils;
type
{ TObjectHelper }
TObjectHelper = class helper for TObject
public
generic function Test<T>(): String;
end;
{ TComponentHelper }
generic function TObjectHelper.Test<T>: String;
begin
Result := T.ClassName
end;
var
O: TObject;
begin
O := TObject.Create;
WriteLn(O.specialize Test<TPersistent>);
O.Free;
end.