Browse Source

* fixed abstract method accounting for external Objective-C/Java classes:
in that case if an "override" directive is missing but we interpret
the declaration as an "override" anyway, make sure to replace the vmtpd
with the overriding definition or child classes will keep seeing
the abstract method in the base class and keep decreasing their abstract
method count below zero
* only decrease the abstract method count in case we're not processing
category methods

git-svn-id: branches/jvmbackend@18923 -

Jonas Maebe 14 years ago
parent
commit
c163a327d7
1 changed files with 23 additions and 16 deletions
  1. 23 16
      compiler/nobj.pas

+ 23 - 16
compiler/nobj.pas

@@ -356,16 +356,23 @@ implementation
                         { no new entry, but copy the message name if any from
                         { no new entry, but copy the message name if any from
                           the procdef in the parent class }
                           the procdef in the parent class }
                         check_msg_str(vmtpd,pd);
                         check_msg_str(vmtpd,pd);
-                        { in case of Java, copy the real name from the parent,
-                          since overriding "Destroy" with "destroy" is not
-                          going to work very well }
-                        if is_java_class_or_interface(_class) and
-                           (pd.procsym.realname<>vmtpd.procsym.realname) then
-                          pd.procsym.realname:=vmtpd.procsym.realname;
-                        { in case we are overriding an abstract method,
-                          decrease the number of abstract methods in this class }
-                        if (po_abstractmethod in vmtpd.procoptions) then
-                          dec(tobjectdef(pd.owner.defowner).abstractcnt);
+                        if updatevalues then
+                          begin
+                            { in case of Java, copy the real name from the parent,
+                              since overriding "Destroy" with "destroy" is not
+                              going to work very well }
+                            if is_java_class_or_interface(_class) and
+                               (pd.procsym.realname<>vmtpd.procsym.realname) then
+                              pd.procsym.realname:=vmtpd.procsym.realname;
+                            { in case we are overriding an abstract method,
+                              decrease the number of abstract methods in this class }
+                            if (po_abstractmethod in vmtpd.procoptions) then
+                              dec(tobjectdef(pd.owner.defowner).abstractcnt);
+                            if (vmtpd.extnumber<>i) then
+                              internalerror(2011083101);
+                            pd.extnumber:=vmtpd.extnumber;
+                            vmtpd:=pd;
+                          end;
                         result:=true;
                         result:=true;
                         exit;
                         exit;
 {$ifdef jvm}
 {$ifdef jvm}
@@ -424,15 +431,15 @@ implementation
                         vmtentryvis:=pd.visibility;
                         vmtentryvis:=pd.visibility;
                     end;
                     end;
 
 
-                  { in case we are overriding an abstract method,
-                    decrease the number of abstract methods in this class }
-                  if (po_overridingmethod in pd.procoptions) and
-                     (po_abstractmethod in vmtpd.procoptions) then
-                    dec(tobjectdef(pd.owner.defowner).abstractcnt);
-
                   { override old virtual method in VMT }
                   { override old virtual method in VMT }
                   if updatevalues then
                   if updatevalues then
                     begin
                     begin
+                      { in case we are overriding an abstract method,
+                        decrease the number of abstract methods in this class }
+                      if (po_overridingmethod in pd.procoptions) and
+                         (po_abstractmethod in vmtpd.procoptions) then
+                        dec(tobjectdef(pd.owner.defowner).abstractcnt);
+
                       if (vmtpd.extnumber<>i) then
                       if (vmtpd.extnumber<>i) then
                         internalerror(200611084);
                         internalerror(200611084);
                       pd.extnumber:=vmtpd.extnumber;
                       pd.extnumber:=vmtpd.extnumber;