Browse Source

pastojs: filer: warn for generics

git-svn-id: trunk@43690 -
Mattias Gaertner 5 years ago
parent
commit
12084211bf
2 changed files with 34 additions and 2 deletions
  1. 7 0
      packages/pastojs/src/pas2jsfiler.pp
  2. 27 2
      packages/pastojs/tests/tcfiler.pas

+ 7 - 0
packages/pastojs/src/pas2jsfiler.pp

@@ -3920,6 +3920,13 @@ begin
   WritePasElement(Obj,El,aContext);
   WritePasElement(Obj,El,aContext);
   Scope:=El.CustomData as TPas2JSProcedureScope;
   Scope:=El.CustomData as TPas2JSProcedureScope;
   //writeln('TPCUWriter.WriteProcedure ',GetObjName(El),' ',GetObjName(Scope),' ',Resolver.GetElementSourcePosStr(El));
   //writeln('TPCUWriter.WriteProcedure ',GetObjName(El),' ',GetObjName(Scope),' ',Resolver.GetElementSourcePosStr(El));
+
+  if Scope.SpecializedFromItem<>nil then
+    begin
+    // ToDo: write spezialiation signature
+    RaiseMsg(20191120180305,El,GetObjPath(Scope.SpecializedFromItem.FirstSpecialize));
+    end;
+
   if Scope.DeclarationProc=nil then
   if Scope.DeclarationProc=nil then
     begin
     begin
     // declaration
     // declaration

+ 27 - 2
packages/pastojs/tests/tcfiler.pas

@@ -172,7 +172,8 @@ type
     procedure TestPC_ClassInterface;
     procedure TestPC_ClassInterface;
     procedure TestPC_Attributes;
     procedure TestPC_Attributes;
 
 
-    procedure TestPC_GenericFunction;
+    procedure TestPC_GenericClassSkip; // ToDo
+    procedure TestPC_GenericFunctionSkip;
 
 
     procedure TestPC_UseUnit;
     procedure TestPC_UseUnit;
     procedure TestPC_UseUnit_Class;
     procedure TestPC_UseUnit_Class;
@@ -2406,7 +2407,31 @@ begin
   WriteReadUnit;
   WriteReadUnit;
 end;
 end;
 
 
-procedure TTestPrecompile.TestPC_GenericFunction;
+procedure TTestPrecompile.TestPC_GenericClassSkip;
+begin
+  exit;
+
+  StartUnit(false);
+  Add([
+  'interface',
+  'type',
+  '  TObject = class',
+  '  end;',
+  '  generic TBird<T> = class',
+  '    a: T;',
+  '    generic function Run<T>(a: T): T;',
+  '  end;',
+  'implementation',
+  'function TBird.Run<T>(a: T): T;',
+  'var b: T;',
+  'begin',
+  '  b:=a; Result:=b;',
+  'end;',
+  '']);
+  WriteReadUnit;
+end;
+
+procedure TTestPrecompile.TestPC_GenericFunctionSkip;
 begin
 begin
   StartUnit(false);
   StartUnit(false);
   Add([
   Add([