Browse Source

* made all objcclasses assignment-compatible with id, and vice versa

git-svn-id: branches/objc@13170 -
Jonas Maebe 16 years ago
parent
commit
112ea5e5a8
3 changed files with 29 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 14 1
      compiler/defcmp.pas
  3. 14 0
      tests/test/tobjc2.pp

+ 1 - 0
.gitattributes

@@ -7916,6 +7916,7 @@ tests/test/tmsg3.pp svneol=native#text/plain
 tests/test/tmsg4.pp svneol=native#text/plain
 tests/test/tmt1.pp svneol=native#text/plain
 tests/test/tobjc1.pp svneol=native#text/plain
+tests/test/tobjc2.pp svneol=native#text/plain
 tests/test/tobject1.pp svneol=native#text/plain
 tests/test/tobject2.pp svneol=native#text/plain
 tests/test/tobject3.pp svneol=native#text/plain

+ 14 - 1
compiler/defcmp.pas

@@ -1121,6 +1121,12 @@ implementation
                        begin
                          doconv:=tc_equal;
                          eq:=te_convert_l2;
+                       end
+                     else if is_objcclass(def_from) and
+                             (def_to=objc_idtype) then
+                       begin
+                         doconv:=tc_equal;
+                         eq:=te_convert_l1;
                        end;
                    end;
                end;
@@ -1282,7 +1288,14 @@ implementation
                        doconv:=tc_int_2_int;
                        eq:=te_convert_l1;
                      end;
-                 end;
+                 end
+                else if is_objcclass(def_to) and
+                        (def_from=objc_idtype) then
+                  begin
+                    { All Objective-C classes are compatible with ID }
+                    doconv:=tc_equal;
+                    eq:=te_convert_l1;
+                  end;
              end;
 
            classrefdef :

+ 14 - 0
tests/test/tobjc2.pp

@@ -0,0 +1,14 @@
+{ %target=darwin}
+{ %cpu=powerpc,i386}
+{ %norun }
+
+{$mode objfpc}
+{$modeswitch objectivec1}
+
+var
+  a: NSObject;
+  b: id;
+begin
+  a:=b;
+  b:=a;
+end.