Browse Source

* Fix bug #31560

git-svn-id: trunk@35617 -
michael 8 years ago
parent
commit
72c8dc8a65
2 changed files with 24 additions and 15 deletions
  1. 7 15
      packages/fcl-passrc/src/pparser.pp
  2. 17 0
      packages/fcl-passrc/tests/tcgenerics.pp

+ 7 - 15
packages/fcl-passrc/src/pparser.pp

@@ -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;

+ 17 - 0
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<TBoundingBox>;const index:Integer);');
+    Add('  end;');
+    Add('implementation');
+    end;
+  ParseModule;
+end;
+
 initialization
   RegisterTest(TTestGenerics);
 end.