git-svn-id: trunk@35617 -
This commit is contained in:
michael 2017-03-18 14:08:03 +00:00
parent 90f3ec2e3b
commit 72c8dc8a65
2 changed files with 24 additions and 15 deletions

View File

@ -1092,6 +1092,11 @@ begin
ParseExcTokenError(';');
UnGetToken;
end
else if (CurToken = tkLessThan) then // A = B<t>;
begin
K:=stkSpecialize;
UnGetToken;
end
else if (CurToken in [tkBraceOpen,tkDotDot]) then // A: B..C;
begin
K:=stkRange;
@ -2918,22 +2923,9 @@ end;
function TPasParser.ParseSpecializeType(Parent: TPasElement;
const TypeName: String): TPasClassType;
var
ok: Boolean;
begin
Result := TPasClassType(CreateElement(TPasClassType, TypeName, Parent,
Scanner.CurSourcePos));
ok:=false;
try
Result.ObjKind := okSpecialize;
Result.AncestorType := ParseType(Result,Scanner.CurSourcePos);
Result.IsShortDefinition:=True;
ReadGenericArguments(TPasClassType(Result).GenericTemplateTypes,Result);
ok:=true;
finally
if not ok then
Result.Release;
end;
NextToken;
Result:=ParseSimpleType(Parent,Scanner.CurSourcePos,TypeName) as TPasClassType;
end;
function TPasParser.ParseProcedureType(Parent: TPasElement;

View File

@ -18,6 +18,7 @@ Type
Procedure TestDeclarationDelphi;
Procedure TestDeclarationDelphiSpecialize;
Procedure TestMethodImplementation;
Procedure TestInlineSpecializationInProcedure;
end;
implementation
@ -99,6 +100,22 @@ begin
ParseModule;
end;
procedure TTestGenerics.TestInlineSpecializationInProcedure;
begin
With source do
begin
Add('unit afile;');
Add('{$MODE DELPHI}');
Add('interface');
Add('type');
Add(' TFoo=class');
Add(' procedure foo(var Node:TSomeGeneric<TBoundingBox>;const index:Integer);');
Add(' end;');
Add('implementation');
end;
ParseModule;
end;
initialization
RegisterTest(TTestGenerics);
end.