Browse Source

* allow overloads with same result type for external Java classes due to Java supporting covariant return types for interfaces

git-svn-id: trunk@45988 -
svenbarth 5 years ago
parent
commit
848ec1d219
1 changed files with 9 additions and 1 deletions
  1. 9 1
      compiler/pparautl.pas

+ 9 - 1
compiler/pparautl.pas

@@ -1155,7 +1155,15 @@ implementation
          end;
          end;
 
 
         if sameparasfound and
         if sameparasfound and
-            not (currpd.proctypeoption=potype_operator) then
+            not (currpd.proctypeoption=potype_operator) and
+            (
+              { allow overloads with different result types for external java
+                classes as Java supports covariant return types when implementing
+                interfaces and e.g. AbstractStringBuilder uses that }
+              not assigned(currpd.struct) or
+              not is_java_class_or_interface(currpd.struct) or
+              not (oo_is_external in tobjectdef(currpd.struct).objectoptions)
+            ) then
           begin
           begin
             MessagePos(currpd.fileinfo,parser_e_overloaded_have_same_parameters);
             MessagePos(currpd.fileinfo,parser_e_overloaded_have_same_parameters);
             tprocsym(currpd.procsym).write_parameter_lists(currpd);
             tprocsym(currpd.procsym).write_parameter_lists(currpd);