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

 
 

bug #40253: problems with boolean parameter in overloaded methods

Submitted by:  Per Bothner <bothner>
Submitted on:  Sun 13 Oct 2013 06:50:20 AM UTC  
 
Category: Type declaration and inferenceSeverity: 3 - Normal
Item Group: Unexpected resultStatus: None
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project AdministratorIn charge of this item.

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

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

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup