gcj/322: Overloaded method resolution should not cross contexts
bryce@albatross.co.nz
bryce@albatross.co.nz
Wed Aug 16 19:30:00 GMT 2000
>Number: 322
>Category: gcj
>Synopsis: Overloaded method resolution should not cross contexts
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: apbianco
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Aug 16 19:30:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Bryce McKinlay
>Release: current
>Organization:
>Environment:
>Description:
gcj goes to some lengths to try and resolve calls to
overloaded methods where methods in an outer context share
the same name (see find_most_specific_methods_list etc).
However this is unneccessary (and wrong), as demonstrated
by the following example.
class Overload
{
void p(String s) {}
class A
{
void p(int i) {}
void a()
{
p("One");
}
}
}
Here gcj will patch the call through to p(String) in the
outer context. But both jikes and javac reject this code
because overload resolution should stop at the first context
in which an appropriatly named method is discovered.
Jikes's error message is particularly intelligent here:
$ jikes Overload.java
Found 1 semantic error compiling "Overload.java":
11. p("One");
<------>
*** Error: The method "void p(java.lang.String s);" contained in the enclosing type "Overload" is a perfect match for this method call. However, it is not visible in this nested class because a method with the same name in an intervening class is hiding it.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Java-prs
mailing list