summaryrefslogtreecommitdiff
path: root/packages/pastojs
diff options
context:
space:
mode:
authormattias <mattias@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-01-16 21:23:15 +0000
committermattias <mattias@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-01-16 21:23:15 +0000
commit91c2b0eaad3491a0fe7d6a59c26ab282208492df (patch)
tree3a566d1f42043d350f776b4c29f5f3401d1636db /packages/pastojs
parentdc728680b1db235a5e7877df728049b4db89a9b6 (diff)
downloadfpc-91c2b0eaad3491a0fe7d6a59c26ab282208492df.tar.gz
pastojs: filer: generic class
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@43960 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/pastojs')
-rw-r--r--packages/pastojs/src/pas2jsfiler.pp5
-rw-r--r--packages/pastojs/tests/tcfiler.pas20
2 files changed, 17 insertions, 8 deletions
diff --git a/packages/pastojs/src/pas2jsfiler.pp b/packages/pastojs/src/pas2jsfiler.pp
index 4d53137b02..8175bd8ea9 100644
--- a/packages/pastojs/src/pas2jsfiler.pp
+++ b/packages/pastojs/src/pas2jsfiler.pp
@@ -3721,7 +3721,7 @@ begin
Templ:=TPasGenericTemplateType(GenericTemplateTypes[i]);
TemplObj:=TJSONObject.Create;
Arr.Add(TemplObj);
- TemplObj.Add('Name',Templ.Name);
+ WritePasElement(TemplObj,Templ,aContext);
WriteElementArray(TemplObj,Parent,'Constraints',Templ.Constraints,aContext,true);
end;
end;
@@ -6300,7 +6300,7 @@ var
begin
if not ReadArray(Obj,'Declarations',Arr,Decls) then exit;
{$IFDEF VerbosePCUFiler}
- writeln('TPCUReader.ReadDeclarations ',GetObjName(Section),' ',Arr.Count);
+ writeln('TPCUReader.ReadDeclarations ',GetObjName(Decls),' ',Arr.Count);
{$ENDIF}
for i:=0 to Arr.Count-1 do
begin
@@ -7551,6 +7551,7 @@ begin
RaiseMsg(20190720224130,Parent,IntToStr(i));
GenType:=TPasGenericTemplateType(CreateElement(TPasGenericTemplateType,GenTypeName,Parent));
GenericTemplateTypes.Add(GenType);
+ ReadPasElement(TemplObj,GenType,aContext);
ReadElementArray(TemplObj,Parent,'Constraints',GenType.Constraints,
{$IFDEF CheckPasTreeRefCount}'TPasGenericTemplateType.Constraints'{$ELSE}true{$ENDIF},
aContext);
diff --git a/packages/pastojs/tests/tcfiler.pas b/packages/pastojs/tests/tcfiler.pas
index 459506ebc9..44e172eb75 100644
--- a/packages/pastojs/tests/tcfiler.pas
+++ b/packages/pastojs/tests/tcfiler.pas
@@ -1171,10 +1171,20 @@ begin
//writeln('TCustomTestPrecompile.CheckRestoredElement Checking Parent... Orig=',GetObjName(Orig),' Rest=',GetObjName(Rest));
CheckRestoredReference(Path+'.Parent',Orig.Parent,Rest.Parent);
+ C:=Orig.ClassType;
//writeln('TCustomTestPrecompile.CheckRestoredElement Checking CustomData... Orig=',GetObjName(Orig),' Rest=',GetObjName(Rest));
- CheckRestoredCustomData(Path+'.CustomData',Rest,Orig.CustomData,Rest.CustomData,Flags);
+ if C=TPasGenericTemplateType then
+ begin
+ // TPasGenericParamsScope is only needed during parsing
+ if Orig.CustomData=nil then
+ else if not (Orig.CustomData is TPasGenericParamsScope) then
+ Fail(Path+'Orig.CustomData='+GetObjName(Orig.CustomData))
+ else if Rest.CustomData<>nil then
+ CheckRestoredCustomData(Path+'.CustomData',Rest,Orig.CustomData,Rest.CustomData,Flags);
+ end
+ else
+ CheckRestoredCustomData(Path+'.CustomData',Rest,Orig.CustomData,Rest.CustomData,Flags);
- C:=Orig.ClassType;
if C=TUnaryExpr then
CheckRestoredUnaryExpr(Path,TUnaryExpr(Orig),TUnaryExpr(Rest),Flags)
else if C=TBinaryExpr then
@@ -2671,8 +2681,6 @@ end;
procedure TTestPrecompile.TestPC_GenericClass;
begin
- exit;
-
StartUnit(false);
Add([
'interface',
@@ -2681,10 +2689,10 @@ begin
' end;',
' generic TBird<T> = class',
' a: T;',
- ' generic function Run<T>(a: T): T;',
+ ' function Run: T;',
' end;',
'implementation',
- 'function TBird.Run<T>(a: T): T;',
+ 'function TBird.Run: T;',
'var b: T;',
'begin',
' b:=a; Result:=b;',