From mboxrd@z Thu Jan 1 00:00:00 1970 From: bryce@albatross.co.nz To: java-gnats@sourceware.cygnus.com Subject: java/1348: Overloaded method resolution should not cross contexts Date: Wed, 20 Dec 2000 12:25:00 -0000 Message-id: <20000817022320.5598.qmail@sourceware.cygnus.com> X-SW-Source: 2000-q4/msg01158.html List-Id: >Number: 1348 >Category: java >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 Dec 20 12:19:16 PST 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: Formerly PR gcj/322 >Unformatted: