From 848ec1d2197dfbd696b5c69a8fcb39011ec5ec56 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Sun, 2 Aug 2020 12:28:46 +0000 Subject: [PATCH] * allow overloads with same result type for external Java classes due to Java supporting covariant return types for interfaces git-svn-id: trunk@45988 - --- compiler/pparautl.pas | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/pparautl.pas b/compiler/pparautl.pas index 792f7ea346..4608decce3 100644 --- a/compiler/pparautl.pas +++ b/compiler/pparautl.pas @@ -1155,7 +1155,15 @@ implementation end; 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 MessagePos(currpd.fileinfo,parser_e_overloaded_have_same_parameters); tprocsym(currpd.procsym).write_parameter_lists(currpd);