Browse Source

* don't generate typed constant initializers for interfaces (since they
can't have class constructors)

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

Jonas Maebe 14 years ago
parent
commit
2964ea3e9b
2 changed files with 12 additions and 1 deletions
  1. 2 1
      compiler/pdecobj.pas
  2. 10 0
      compiler/symdef.pas

+ 2 - 1
compiler/pdecobj.pas

@@ -1387,7 +1387,8 @@ implementation
               if is_javaclass(current_structdef) then
                 maybe_add_public_default_java_constructor(tobjectdef(current_structdef));
               { need method to hold the initialization code for typed constants? }
-              if target_info.system in systems_typed_constants_node_init then
+              if (target_info.system in systems_typed_constants_node_init) and
+                 not is_any_interface_kind(current_structdef) then
                 add_typedconst_init_routine(current_structdef);
             end;
 

+ 10 - 0
compiler/symdef.pas

@@ -838,6 +838,7 @@ interface
     { should be in the types unit, but the types unit uses the node stuff :( }
     function is_interfacecom(def: tdef): boolean;
     function is_interfacecom_or_dispinterface(def: tdef): boolean;
+    function is_any_interface_kind(def: tdef): boolean;
     function is_interfacecorba(def: tdef): boolean;
     function is_interface(def: tdef): boolean;
     function is_dispinterface(def: tdef): boolean;
@@ -5907,6 +5908,15 @@ implementation
           (tobjectdef(def).objecttype in [odt_interfacecom,odt_dispinterface]);
       end;
 
+    function is_any_interface_kind(def: tdef): boolean;
+      begin
+        result:=
+          assigned(def) and
+          (def.typ=objectdef) and
+          ((tobjectdef(def).objecttype in [odt_interfacecom,odt_dispinterface,odt_interfacecorba,odt_interfacejava,odt_objcprotocol]) or
+           is_objccategory(def));
+      end;
+
     function is_interfacecorba(def: tdef): boolean;
       begin
         is_interfacecorba:=