From 72c8dc8a651d29924ce9008a1bb3ed6080947302 Mon Sep 17 00:00:00 2001 From: michael Date: Sat, 18 Mar 2017 14:08:03 +0000 Subject: [PATCH] * Fix bug #31560 git-svn-id: trunk@35617 - --- packages/fcl-passrc/src/pparser.pp | 22 +++++++--------------- packages/fcl-passrc/tests/tcgenerics.pp | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/packages/fcl-passrc/src/pparser.pp b/packages/fcl-passrc/src/pparser.pp index 284870a822..9db579da29 100644 --- a/packages/fcl-passrc/src/pparser.pp +++ b/packages/fcl-passrc/src/pparser.pp @@ -1092,6 +1092,11 @@ begin ParseExcTokenError(';'); UnGetToken; end + else if (CurToken = tkLessThan) then // A = B; + 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; diff --git a/packages/fcl-passrc/tests/tcgenerics.pp b/packages/fcl-passrc/tests/tcgenerics.pp index a16f09ac5e..872c50d2b2 100644 --- a/packages/fcl-passrc/tests/tcgenerics.pp +++ b/packages/fcl-passrc/tests/tcgenerics.pp @@ -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;const index:Integer);'); + Add(' end;'); + Add('implementation'); + end; + ParseModule; +end; + initialization RegisterTest(TTestGenerics); end.