Răsfoiți Sursa

* fixed finding the real definition for formal Objective-C protocols
* fixed printed source code positions in error message in case the external
name of a formal and of a real definition don't match

git-svn-id: trunk@20425 -

Jonas Maebe 13 ani în urmă
părinte
comite
b9c54fab0d
4 a modificat fișierele cu 54 adăugiri și 2 ștergeri
  1. 2 0
      .gitattributes
  2. 2 2
      compiler/symtable.pas
  3. 36 0
      tests/test/tobjc39.pp
  4. 14 0
      tests/test/uobjc39.pp

+ 2 - 0
.gitattributes

@@ -10583,6 +10583,7 @@ 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/tobjc38.pp svneol=native#text/plain
+tests/test/tobjc39.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
@@ -11089,6 +11090,7 @@ tests/test/uobjc35d.pp svneol=native#text/plain
 tests/test/uobjc35e.pp svneol=native#text/plain
 tests/test/uobjc35f.pp svneol=native#text/plain
 tests/test/uobjc35g.pp svneol=native#text/plain
+tests/test/uobjc39.pp svneol=native#text/plain
 tests/test/uobjc7.pp svneol=native#text/plain
 tests/test/uobjcl1.pp svneol=native#text/plain
 tests/test/uprec6.pp svneol=native#text/plain

+ 2 - 2
compiler/symtable.pas

@@ -2262,13 +2262,13 @@ implementation
                 srsym:=tsym(srsymtable.FindWithHash(hashedid));
                 if assigned(srsym) and
                    (srsym.typ=typesym) and
-                   is_objcclass(ttypesym(srsym).typedef) and
+                   is_objc_class_or_protocol(ttypesym(srsym).typedef) and
                    not(oo_is_formal in tobjectdef(ttypesym(srsym).typedef).objectoptions) then
                   begin
                     { the external name for the formal and the real definition must match }
                     if tobjectdef(ttypesym(srsym).typedef).objextname^<>pd.objextname^ then
                       begin
-                        Message2(sym_e_external_class_name_mismatch1,pd.objextname^,pd.typename);
+                        MessagePos2(pd.typesym.fileinfo,sym_e_external_class_name_mismatch1,pd.objextname^,pd.typename);
                         MessagePos1(srsym.fileinfo,sym_e_external_class_name_mismatch2,tobjectdef(ttypesym(srsym).typedef).objextname^);
                       end;
                     result:=tobjectdef(ttypesym(srsym).typedef);

+ 36 - 0
tests/test/tobjc39.pp

@@ -0,0 +1,36 @@
+{ %opt=norun }
+
+{$mode objfpc}
+{$modeswitch objectivec1}
+
+program tobjc39;
+uses
+  uobjc39;
+	
+type
+ UITextInputProtocol = objcprotocol external name 'UITextInput'
+ required
+   procedure setInputDelegate(newValue: UITextInputDelegateProtocol); message 'setInputDelegate:';
+   function inputDelegate: UITextInputDelegateProtocol; message 'inputDelegate';
+   function tokenizer: UITextInputTokenizerProtocol; message 'tokenizer';
+ end;
+
+type
+ UITextInputDelegateProtocol = objcprotocol external name 'UITextInputDelegate'
+ end;
+
+type
+ UITextInputTokenizerProtocol = objcprotocol external name 'UITextInputTokenizer'
+ end;
+
+type
+ UITextField = objcclass external (UITextInputProtocol)
+ public
+   procedure setInputDelegate(newValue: UITextInputDelegateProtocol); message 'setInputDelegate:';
+   function inputDelegate: UITextInputDelegateProtocol; message 'inputDelegate';
+   function tokenizer: UITextInputTokenizerProtocol; message 'tokenizer';
+ end;
+
+begin
+
+end.

+ 14 - 0
tests/test/uobjc39.pp

@@ -0,0 +1,14 @@
+{$mode objfpc}
+{$modeswitch objectivec1}
+
+unit uobjc39;
+interface
+
+type
+ UITextInputDelegateProtocol = objcprotocol external name 'UITextInputDelegate'; 
+ UITextInputTokenizerProtocol = objcprotocol external name 'UITextInputTokenizer'; 
+ UITextInputProtocol = objcprotocol external name 'UITextInput'; 
+
+implementation
+
+end.