bugKawa - Bugs: bug #39047, Wrong incompatible type (boolean)...

 
 

bug #39047: Wrong incompatible type (boolean) with expected int

Submitter:  Matthieu Vachon <maoueh>
Submitted:  Thu 23 May 2013 03:32:51 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 03 Jun 2013 01:38:39 PM UTC, comment #3: 

Thanks Per.

Also, I find it really great that you take the time to explain the cause of the problem. It helps me understand more of the internals of Kawa.

Best regards,
Matt

Matthieu Vachon <maoueh>
Mon 03 Jun 2013 06:17:35 AM UTC, comment #2: 

This was somewhat tricky.  The problem is Kawa follows the Scheme handling of boolean - any value can be treated as boolean.  I.e. any value can be converted to boolean.  This confused the logic for comparing types, so I made some changes that I think are cleaner.

Checked in fix, and a testcase based on yours.  Thanks!

Per Bothner <bothner>
Group administrator
Mon 27 May 2013 01:20:46 AM UTC, comment #1: 

For this bug, we can reduce the test case to only a scheme file. Here it is:


(module-name <org.kawa.test.wrongincompatiblebool>)
(module-compile-options main: #t)

(define-simple-class <Simple> (<Object>)
  ((create (value :: <int>))
   (format (current-output-port) "Calling create int version with value [~a]~%" value))

  ((create (value :: <boolean>))
   (format (current-output-port) "Calling create bool version with value [~a]~%" value)))

(define (main)
  (let ((simple :: <Simple> (make <Simple>)))
    (invoke simple 'create #t)))

(main)


Although a warning is issued, the right method is called. I attached the new test case.

(file #28182)

Matthieu Vachon <maoueh>
Thu 23 May 2013 03:32:51 AM UTC, original submission:  

When a method is overloaded with two possibilities, one taking a boolean the other taking an int and the method is called in Kawa by using a boolean literal, Kawa picks the int one an issue a warning saying boolean is incompatible with type int.

Assume the following Java class:


package org.kawa.test.wrongincompatiblebool;

public class Simple {
    public void create(int updateFlags) {
        System.out.println("Integer Value: " + updateFlags);
    }

    public void create(boolean force) {
        System.out.println("Boolean Value: " + force);
    }
}


And the following Kawa script:

(module-name <org.kawa.test.wrongincompatiblebool>)

(define simple :: <org.kawa.test.wrongincompatiblebool.Simple> (make <org.kawa.test.wrongincompatiblebool.Simple>))
(invoke simple 'create #t)


Kawa will issue the following warning:


(compiling wrong-incompatible-bool.scm to org.kawa.test.wrongincompatiblebool)
wrong-incompatible-bool.scm:4:1: warning - type java.lang.Boolean is incompatible with required type int


Since a boolean literal is used, I would have expected Kawa to pick the boolean version and not issue a warning.

I have attached my two files to this bug report in a zip archive.

Regards,
Matt

Matthieu Vachon <maoueh>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #28182:  wrong-incompatible-bool.scm added by maoueh (487B - application/octet-stream - Same test case as before but only in scheme)
file #28142:  wrong-incompatible-bool.zip added by maoueh (1KiB - application/octet-stream - Test case (one java file, one kawa file))

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bothner (Posted a comment)
  • -email is unavailable- added by maoueh (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.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-06-03 bothner StatusNone Fixed
        Assigned toNone bothner
        Open/ClosedOpen Closed
    2013-05-27 maoueh Attached File- Added wrong-incompatible-bool.scm, #28182
    2013-05-23 maoueh Attached File- Added wrong-incompatible-bool.zip, #28142

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code