You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2023/06/22 13:17:00 UTC
[jira] [Commented] (GROOVY-11106) Failed to detect an ambiguous method call?
[ https://issues.apache.org/jira/browse/GROOVY-11106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17736123#comment-17736123 ]
Paul King commented on GROOVY-11106:
------------------------------------
This is part of the current method selection algorithm which favours interfaces over classes. It perhaps lacks a more formal justification/specification.
> Failed to detect an ambiguous method call?
> ------------------------------------------
>
> Key: GROOVY-11106
> URL: https://issues.apache.org/jira/browse/GROOVY-11106
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Priority: Minor
> Labels: overloading
>
> I have the following code:
> {code}
> import java.io.*;
> import java.util.*;
> class Main {
> void test() {
> ObjectOutputStream y = null;
> m(y);
> }
> Number m(OutputStream x) { return 1; }
> Number m(DataOutput x) { return 2; }
> }
> {code}
> h3. Actual behaviour
> The code compiles successfully. The compiler resolves the second method, that is m(DataOutput).
> h3. Expected behaviour
> It seems that the method call is ambiguous, and thus the compiler should have rejected the above program. javac seems to reject the program with a method ambiguity error.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)