Project

General

Profile

Actions

Bug #11089

open

equals functions are not translated properly

Added by Roel Standaert about 2 years ago. Updated almost 2 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
11/21/2022
Due date:
% Done:

0%

Estimated time:

Description

We turn the following C++:

class C {
public:
  bool operator==(const C& other) {
    ...
  }
};

into:

public class C {
  public boolean equals(final C other) {
    ...
  }
}

As a consequence, Object#equals is not properly overridden.

We should turn it into something like:

public class C {
   @Override
   public boolean equals(Object otherObject) {
     if (!(otherObject instanceof C)) {
       return false;
     }
     final C other = (C)otherObject;
     ...
   }
}

One function that is affected by this issue is WApplication#require. If require is called twice:

require("lib.js"); // returns true
require("lib.js"); // ERROR: also returns true

This also generates JavaScript like:

Wt._p_.loadScript('lib.js', '');
Wt._p_.onJsLoad('lib.js', function() {
  Wt._p_.loadScript('lib.js', '');
  Wt._p_.onJsLoad('lib.js', function() {
    ...

Instead, it should be:

Wt._p_.loadScript('lib.js', '');
Wt._p_.onJsLoad('lib.js', function() {
  ...

Related to this is the fact that hashCode is rarely properly overridden.

No data to display

Actions

Also available in: Atom PDF