cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 160 forks source link

Different output between java and jsweet #640

Open BestleonLTY opened 3 years ago

BestleonLTY commented 3 years ago
package org.jsweet;

import static def.dom.Globals.*;

/**
 * This is a very simple example that just shows an alert.
 */

public class HelloWorld {
    public static class Human {
        String name = "human";
    }
    public static class Boy extends Human {
        String name = "boy";
    }
    public static void main(String[] args) {
        Human h = new Boy();
        System.out.println(h.name);
    }
}

I have found the output of this JAVA code should be "human" because of Shadow. But the output of JS code which is transpiled by jsweet is "boy".

lgrignon commented 3 years ago

Hello @BestleonLTY That's a good one, thanks

lgrignon commented 3 years ago

Do you think you would have time to contribute on this? This would be pretty low prio on our side unfortunately.

It could be solved by raising an error on such a side case by the way :)

BestleonLTY commented 3 years ago

I will do it if I have any good ideas.