mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-12 14:49:33 +02:00
* fix for Mantis #35735: also handle "generic" keyword inside helper types
+ added test git-svn-id: trunk@42328 -
This commit is contained in:
parent
a2ce2cea94
commit
d0eddbcbb9
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||
|
@ -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
33
tests/webtbs/tw35735.pp
Normal 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.
|
||||
|
Loading…
Reference in New Issue
Block a user