Procházet zdrojové kódy

* also give a warning when a field masks an identifier from a category
* also give a warning when a field/parameter/local variable masks an
identifier from a class helper that's in scope

git-svn-id: trunk@29498 -

Jonas Maebe před 10 roky
rodič
revize
8fe981cccb
3 změnil soubory, kde provedl 28 přidání a 2 odebrání
  1. 1 0
      .gitattributes
  2. 3 2
      compiler/symtable.pas
  3. 24 0
      tests/test/thlp48.pp

+ 1 - 0
.gitattributes

@@ -11760,6 +11760,7 @@ tests/test/thlp44.pp svneol=native#text/pascal
 tests/test/thlp45.pp svneol=native#text/pascal
 tests/test/thlp46.pp svneol=native#text/pascal
 tests/test/thlp47.pp svneol=native#text/pascal
+tests/test/thlp48.pp svneol=native#text/plain
 tests/test/thlp5.pp svneol=native#text/pascal
 tests/test/thlp6.pp svneol=native#text/pascal
 tests/test/thlp7.pp svneol=native#text/pascal

+ 3 - 2
compiler/symtable.pas

@@ -1498,8 +1498,9 @@ implementation
                     happen due to all possible categories being imported via
                     CocoaAll }
                   warn:=
-                    is_objccategory(tdef(hsym.owner.defowner)) and
-                    (sym.typ in [paravarsym,localvarsym]);
+                    (is_objccategory(tdef(hsym.owner.defowner)) or
+                     is_classhelper(tdef(hsym.owner.defowner))) and
+                    (sym.typ in [paravarsym,localvarsym,fieldvarsym]);
                   DuplicateSym(hashedid,sym,hsym,warn);
                   result:=true;
                 end;

+ 24 - 0
tests/test/thlp48.pp

@@ -0,0 +1,24 @@
+{ %fail }
+{ %opt=-vw -Sew }
+
+program thelper;
+
+{$mode objfpc}
+
+type
+  TTest = class;
+
+  TTestHelper = class helper for TTest
+    procedure Test;
+  end;
+
+  TTest = class
+    Test: LongInt;
+  end;
+
+procedure TTestHelper.Test;
+begin
+end;
+
+begin
+end.