Browse Source

* fix #41063: don't add classrefdefs or objectdefs to the WPOInfo if they are declared locally (e.g. capturer instances)
+ added test

Sven/Sarah Barth 7 months ago
parent
commit
32b3477fe2
3 changed files with 37 additions and 2 deletions
  1. 4 2
      compiler/symdef.pas
  2. 11 0
      tests/webtbs/tw41063.pp
  3. 22 0
      tests/webtbs/uw41063.pp

+ 4 - 2
compiler/symdef.pas

@@ -8724,7 +8724,8 @@ implementation
         if not classref_created_in_current_module then
           begin
             classref_created_in_current_module:=true;
-            current_module.wpoinfo.addcreatedobjtypeforclassref(self);
+            if not (owner.symtabletype in [localsymtable]) then
+              current_module.wpoinfo.addcreatedobjtypeforclassref(self);
           end;
       end;
 
@@ -8734,7 +8735,8 @@ implementation
         if not created_in_current_module then
           begin
             created_in_current_module:=true;
-            current_module.wpoinfo.addcreatedobjtype(self);
+            if not (owner.symtabletype in [localsymtable]) then
+              current_module.wpoinfo.addcreatedobjtype(self);
           end;
       end;
 

+ 11 - 0
tests/webtbs/tw41063.pp

@@ -0,0 +1,11 @@
+{ %wpoparas=optvmts }
+{ %wpopasses=1 }
+
+program tw41063;
+{$mode objfpc}{$h+}
+
+uses uw41063;
+
+begin
+end.
+

+ 22 - 0
tests/webtbs/uw41063.pp

@@ -0,0 +1,22 @@
+unit uw41063;
+
+{$mode objfpc}{$h+}
+{$modeswitch functionreferences}
+
+interface
+
+type
+  TMyClass = class
+    FProcRef: reference to procedure;
+    procedure proc;
+  end;
+
+implementation
+
+procedure TMyClass.proc;
+begin
+  FProcRef := @proc;
+end;
+
+end.
+