bugKawa - Bugs: bug #52390, kawa 3.0 anonymous class...

 
 

bug #52390: kawa 3.0 anonymous class instantiation in map issue

Submitter:  None
Submitted:  Fri 10 Nov 2017 10:01:25 PM UTC
   
 
Category:  Type declaration and inference Severity:  3 - Normal
Item Group:  Unexpected result Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 16 Jan 2018 05:02:49 AM UTC, comment #2: 

I fixed this by reverting a patch for issue #11 (on GitLab). (I found a simpler and better patch for the issues.

I also checked in a testcase based on yours. Thanks!

Per Bothner <bothner>
Group administrator
Fri 10 Nov 2017 11:04:59 PM UTC, comment #1: 

It is definitely supposed to create only one subclass - classes are generally generated at compile-time (or load-time if you think of the actual Class object, not during execution.

The problem is how 'map' is inlined to a loop.  The bug is that there is only one variable for 'prefix', and each instance shares the same 'prefix'.

Here is a work-around:

(let ((v (map (lambda (prefix0)
                (object (java.lang.Object)
                        (prefix prefix0)
                  ((my-method value) (string-append prefix "-" (number->string value)))))
           (list "ALPHA" "BETA" "GAMMA"))))
   ....

New bugs should probably be reported on the gitlab bug-tracker.

Per Bothner <bothner>
Group administrator
Fri 10 Nov 2017 10:01:25 PM UTC, original submission:  

The following code:

(let ((v (map (lambda (prefix)
                (object (java.lang.Object)
                  ((my-method value) (string-append prefix "-" (number->string value)))))
           (list "ALPHA" "BETA" "GAMMA"))))
  (display (format "~a ~a ~a : test-map\n"
             ((car v):my-method 100)
             ((cadr v):my-method 200)
             ((caddr v):my-method 300))))

gives different results with kawa-2.4 (expected):

ALPHA-100 BETA-200 GAMMA-300 : test-map

and kawa-3.0 (unexpected):

GAMMA-100 GAMMA-200 GAMMA-300 : test-map

It seems it's creating only one subclass, instantiating three times from that, rather than create three subclasses, instantiating from each one.

Anonymous

 

(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 (Posted a comment)
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-01-16 bothner StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2017-11-10 bothner StatusNone Confirmed
        Assigned toNone bothner

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code