浏览代码

* when automatically generating (s|g)etters, make sure that the visibility of
(g|s)etters whose naming convention is already correct is adjusted if
necessary

git-svn-id: trunk@23546 -

Jonas Maebe 12 年之前
父节点
当前提交
ddc03bdf03
共有 1 个文件被更改,包括 20 次插入15 次删除
  1. 20 15
      compiler/pdecvar.pas

+ 20 - 15
compiler/pdecvar.pas

@@ -332,9 +332,6 @@ implementation
          hdef : tdef;
          arraytype : tdef;
          def : tdef;
-{$ifdef jvm}
-         orgaccesspd : tprocdef;
-{$endif}
          pt : tnode;
          sc : TFPObjectList;
          paranr : word;
@@ -346,6 +343,10 @@ implementation
          storedprocdef: tprocvardef;
          readprocdef,
          writeprocdef : tprocdef;
+ {$ifdef jvm}
+          orgaccesspd : tprocdef;
+          wrongvisibility : boolean;
+ {$endif}
       begin
          { Generate temp procdefs to search for matching read/write
            procedures. the readprocdef will store all definitions }
@@ -534,18 +535,20 @@ implementation
                             begin
 {$ifdef jvm}
                               orgaccesspd:=tprocdef(p.propaccesslist[palt_read].procdef);
+                              wrongvisibility:=tprocdef(p.propaccesslist[palt_read].procdef).visibility<p.visibility;
+                              if (prop_auto_getter_prefix<>'') and
+                                 (wrongvisibility or
+                                   (p.propaccesslist[palt_read].firstsym^.sym.RealName<>prop_auto_getter_prefix+p.RealName)) then
+                                jvm_create_getter_for_property(p,orgaccesspd)
                               { if the visibility of the getter is lower than
                                 the visibility of the property, wrap it so that
                                 we can call it from all contexts in which the
                                 property is visible }
-                              if (tprocdef(p.propaccesslist[palt_read].procdef).visibility<p.visibility) then
-                                begin
-                                  p.propaccesslist[palt_read].procdef:=jvm_wrap_method_with_vis(tprocdef(p.propaccesslist[palt_read].procdef),p.visibility);
-                                  p.propaccesslist[palt_read].firstsym^.sym:=tprocdef(p.propaccesslist[palt_read].procdef).procsym;
-                                end;
-                              if (prop_auto_getter_prefix<>'') and
-                                 (p.propaccesslist[palt_read].firstsym^.sym.RealName<>prop_auto_getter_prefix+p.RealName) then
-                                jvm_create_getter_for_property(p,orgaccesspd);
+                              else if wrongvisibility then
+                               begin
+                                 p.propaccesslist[palt_read].procdef:=jvm_wrap_method_with_vis(tprocdef(p.propaccesslist[palt_read].procdef),p.visibility);
+                                 p.propaccesslist[palt_read].firstsym^.sym:=tprocdef(p.propaccesslist[palt_read].procdef).procsym;
+                               end;
 {$endif jvm}
                             end;
                         end;
@@ -615,18 +618,20 @@ implementation
                             begin
 {$ifdef jvm}
                               orgaccesspd:=tprocdef(p.propaccesslist[palt_write].procdef);
+                              wrongvisibility:=tprocdef(p.propaccesslist[palt_write].procdef).visibility<p.visibility;
+                              if (prop_auto_setter_prefix<>'') and
+                                 ((sym.RealName<>prop_auto_setter_prefix+p.RealName) or
+                                  wrongvisibility) then
+                                jvm_create_setter_for_property(p,orgaccesspd)
                               { if the visibility of the setter is lower than
                                 the visibility of the property, wrap it so that
                                 we can call it from all contexts in which the
                                 property is visible }
-                              if (tprocdef(p.propaccesslist[palt_write].procdef).visibility<p.visibility) then
+                              else if wrongvisibility then
                                 begin
                                   p.propaccesslist[palt_write].procdef:=jvm_wrap_method_with_vis(tprocdef(p.propaccesslist[palt_write].procdef),p.visibility);
                                   p.propaccesslist[palt_write].firstsym^.sym:=tprocdef(p.propaccesslist[palt_write].procdef).procsym;
                                 end;
-                              if (prop_auto_setter_prefix<>'') and
-                                 (sym.RealName<>prop_auto_setter_prefix+p.RealName) then
-                                jvm_create_setter_for_property(p,orgaccesspd);
 {$endif jvm}
                             end;
                         end;