* Generic templates can be separated by semicolon (used in fgl unit)

git-svn-id: trunk@40942 -
This commit is contained in:
michael 2019-01-20 17:10:16 +00:00
parent 75a89d2115
commit 2bcc195677
2 changed files with 24 additions and 1 deletions

View File

@ -4006,7 +4006,7 @@ begin
T.TypeConstraint:=ExpectIdentifier;
NextToken;
end;
if not (CurToken in [tkComma,tkGreaterThan]) then
if not (CurToken in [tkComma,tkSemicolon,tkGreaterThan]) then
ParseExc(nParserExpectToken2Error,SParserExpectToken2Error,
[TokenInfos[tkComma], TokenInfos[tkColon], TokenInfos[tkGreaterThan]]);
until CurToken = tkGreaterThan;

View File

@ -21,6 +21,7 @@ Type
procedure TestDeclarationConstraint;
Procedure TestDeclarationDelphi;
Procedure TestDeclarationDelphiSpecialize;
procedure TestDeclarationFPC;
Procedure TestMethodImplementation;
Procedure TestInlineSpecializationInArgument;
Procedure TestSpecializeNested;
@ -86,6 +87,28 @@ begin
AssertSame('Parent 1 is class',T,TPasElement(T.GenericTemplateTypes[1]).Parent);
end;
procedure TTestGenerics.TestDeclarationFPC;
Var
T : TPasClassType;
begin
Scanner.CurrentModeSwitches:=[msDelphi]+Scanner.CurrentModeSwitches ;
Source.Add('Type');
Source.Add(' TSomeClass<T;T2> = Class(TObject)');
Source.Add(' b : T;');
Source.Add(' b2 : T2;');
Source.Add('end;');
ParseDeclarations;
AssertNotNull('have generic definition',Declarations.Classes);
AssertEquals('have generic definition',1,Declarations.Classes.Count);
AssertEquals('Pascal class',TPasClassType,TObject(Declarations.Classes[0]).ClassType);
T:=TPasClassType(Declarations.Classes[0]);
AssertNotNull('have generic templates',T.GenericTemplateTypes);
AssertEquals('2 template types',2,T.GenericTemplateTypes.Count);
AssertSame('Parent 0 is class',T,TPasElement(T.GenericTemplateTypes[0]).Parent);
AssertSame('Parent 1 is class',T,TPasElement(T.GenericTemplateTypes[1]).Parent);
end;
procedure TTestGenerics.TestDeclarationConstraint;
Var
T : TPasClassType;