2
0
Эх сурвалжийг харах

* don't check for duplicate symbols when adding a class helper symbol, see
added comments why (solves duplicate symbol error when adding a category
for an objcclass in the interface and then another one in the
implementation of a unit, problem reported by Ryan Joseph on the
mac-pascal list)

git-svn-id: trunk@16902 -

Jonas Maebe 14 жил өмнө
parent
commit
a199344bf4

+ 1 - 0
.gitattributes

@@ -9628,6 +9628,7 @@ tests/test/tobjc35h.pp svneol=native#text/plain
 tests/test/tobjc35i.pp svneol=native#text/plain
 tests/test/tobjc36.pp svneol=native#text/plain
 tests/test/tobjc36a.pp svneol=native#text/plain
+tests/test/tobjc37.pp svneol=native#text/plain
 tests/test/tobjc4.pp svneol=native#text/plain
 tests/test/tobjc4a.pp svneol=native#text/plain
 tests/test/tobjc5.pp svneol=native#text/plain

+ 11 - 1
compiler/symdef.pas

@@ -4475,7 +4475,17 @@ implementation
             psym:=tprocsym.create(nname);
             { avoid warning about this symbol being unused }
             psym.IncRefCount;
-            st.insert(psym,true);
+            { don't check for duplicates:
+               a) we checked above
+               b) in case we are in the implementation section of a unit, this
+                  will also check for this symbol in the interface section
+                  (since you normally cannot have symbols with the same name
+                   both interface and implementation), and it's possible to
+                   have class helpers for the same class in the interface and
+                   in the implementation, and they cannot be merged since only
+                   the once in the interface must be saved to the ppu/visible
+                   from other units }
+            st.insert(psym,false);
           end
         else if (psym.typ<>procsym) then
           internalerror(2009111501);

+ 45 - 0
tests/test/tobjc37.pp

@@ -0,0 +1,45 @@
+{ %norun }
+
+{$mode objfpc}
+{$modeswitch objectivec1}
+
+unit tobjc37;
+interface
+uses
+	CocoaAll;
+
+type
+	MyWindow = objcclass(NSWindow)
+		procedure awakeFromNib; override;
+	end;
+	
+	
+implementation
+
+type
+	MyView = objcclass(NSView)
+		procedure awakeFromNib; override;
+	end;
+
+procedure MyWindow.awakeFromNib;
+begin
+end;
+
+procedure MyView.awakeFromNib;
+begin
+end;
+
+procedure test;
+var
+  w: mywindow;
+  v: myview;
+begin
+  w:=mywindow.alloc.init;
+  w.awakefromnib;
+  w.release;
+  v:=myview.alloc.init;
+  v.awakefromnib;
+  v.release;
+end;
+	
+end.