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
Priority:  5 - Normal Item Group:  Unexpected result
Status:  None Privacy:  Public
Assigned to:  bothner Open/Closed:  Open
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

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

 

Attached Files

This item currently has no attached files.

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

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

    Votes

    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.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

    History

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.16-598c.
    Corresponding source code