bugKawa - Bugs: bug #40253, problems with boolean parameter in...

 
 

bug #40253: problems with boolean parameter in overloaded methods

Submitter:  Per Bothner <bothner>
Submitted:  Sun 13 Oct 2013 06:50:20 AM UTC
   
 
Category:  Type declaration and inference Severity:  3 - Normal
Item Group:  Unexpected result Status:  None
Privacy:  Public Assigned to:  bothner
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 13 Oct 2013 06:50:20 AM UTC, original submission:  

Notwithstanding bug #39047, there are still problems with overloaded methods with a boolean parameter.

(1) Consider Java file:
public class bar {
      public void ff(java.util.List x) { System.out.println("s/x: "+x); System.out.flush();}
    public void ff(boolean x) { System.out.println("b/x: "+x); System.out.flush();}
}
and Scheme file:
(define bb (bar))
(define x::integer 12)
(bb:ff x)

This doesn't work.  The java.util.List methods is preferred as "possibly applicable", which fails at run-time, even though the boolean method should work.

Note it works if we comment out the List method, but we get a compile-time warning.

(2) Overload resolution at compile-time vs run-time is inconsistent.  Consider:

(define wtr
   (java.io.PrintWriter
       (java.io.OutputStreamWriter (java.lang.System:.out) "UTF-8")))
(define (print-it)
    (wtr:println "PRINT ME"))
(print-it)
((->java.io.PrintWriter wtr):flush)

This works if loaded in whole-module mode, but if we use --script (or -f) the boolean method is chosen, because it is earlier in the sort order when building a GenericProc.

A possible approach is to consider a method:
  foo(boolean x)
as if it where two methods:
  foo(boolean_strict x) // requires argument to be a boolean
  foo(convert_to_boolean x) // convert argument to boolean
The former would be very specific and applicable only to booleans, just as in Java.  The latter is very non-specific and applicable to all arguments - it would be views as "less specific" than Object.

Per Bothner <bothner>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bothner (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code