cincheo / jsweet

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

If super.equals is called from equals itself, it generates an infinite loop #681

Open lgrignon opened 3 years ago

lgrignon commented 3 years ago

If super.equals is called from equals itself, it generates an infinite loop

  @Override
  public boolean equals(Object obj) {
    return super.equals(obj);
}  

will transpile to

XXX.prototype.equals = function (obj) {
        return /* equals */ (function (o1, o2) { if (o1 && o1.equals) {
            return o1.equals(o2);
        }
        else {
            return o1 === o2;
        } })(this, obj);
    };