浏览代码

* allow the usage of fields of parent classes for property readers/writers, resolves #9095

git-svn-id: trunk@8799 -
florian 18 年之前
父节点
当前提交
00fef0fdd0
共有 3 个文件被更改,包括 54 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 2 0
      compiler/pdecvar.pas
  3. 51 0
      tests/webtbs/tw9095.pp

+ 1 - 0
.gitattributes

@@ -8441,6 +8441,7 @@ tests/webtbs/tw9073.pp svneol=native#text/plain
 tests/webtbs/tw9076.pp svneol=native#text/plain
 tests/webtbs/tw9076.pp svneol=native#text/plain
 tests/webtbs/tw9076a.pp svneol=native#text/plain
 tests/webtbs/tw9076a.pp svneol=native#text/plain
 tests/webtbs/tw9085.pp svneol=native#text/plain
 tests/webtbs/tw9085.pp svneol=native#text/plain
+tests/webtbs/tw9095.pp svneol=native#text/plain
 tests/webtbs/tw9096.pp svneol=native#text/plain
 tests/webtbs/tw9096.pp svneol=native#text/plain
 tests/webtbs/tw9098.pp svneol=native#text/plain
 tests/webtbs/tw9098.pp svneol=native#text/plain
 tests/webtbs/tw9107.pp svneol=native#text/plain
 tests/webtbs/tw9107.pp svneol=native#text/plain

+ 2 - 0
compiler/pdecvar.pas

@@ -133,6 +133,8 @@ implementation
                           if assigned(st) then
                           if assigned(st) then
                            begin
                            begin
                              sym:=tsym(st.Find(pattern));
                              sym:=tsym(st.Find(pattern));
+                             if not(assigned(sym)) and is_object(def) then
+                               sym:=search_class_member(tobjectdef(def),pattern);
                              if assigned(sym) then
                              if assigned(sym) then
                               begin
                               begin
                                 pl.addsym(sl_subscript,sym);
                                 pl.addsym(sl_subscript,sym);

+ 51 - 0
tests/webtbs/tw9095.pp

@@ -0,0 +1,51 @@
+{$mode objfpc}
+
+type
+    ta = byte;
+    pa = ^byte;
+    panother = pa;
+
+type
+    tRec = record
+        a : ta;
+        p : panother;
+    end;
+
+    tNestedObj = object
+        arec : tRec;
+        p : panother;
+    end;
+
+    tChildObj = object(tNestedObj)
+        dummy : byte;
+    end;
+
+type
+
+    tObj = object
+        arec : tRec;
+        aobj : tNestedObj;
+        achild : tChildObj;
+
+        property a_rec : byte read arec.a;
+        property a_obj : byte read aobj.arec.a;
+        property p_obj : pa read aobj.p;
+        property dummy_child : byte read achild.dummy;
+        property a_child : byte read achild.arec.a;
+{ Error: Unknown record field identifier "arec" ^
+            Error: Unknown record field identifier "a" ^
+}
+        property p_child : pa read achild.p;
+{ Error: Unknown record field identifier "p" ^
+}
+    end;
+
+var
+  Obj : tObj;
+
+begin
+  Obj.achild.p:=panother($deadbeef);
+  if Obj.p_child<>panother($deadbeef) then
+    halt(1);
+  writeln('ok');
+end.