Browse Source

* 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 years ago
parent
commit
ddc03bdf03
1 changed files with 20 additions and 15 deletions
  1. 20 15
      compiler/pdecvar.pas

+ 20 - 15
compiler/pdecvar.pas

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