Skip to content

Commit

Permalink
fix broken backward compatibility (use the same approach as for all t…
Browse files Browse the repository at this point in the history
…he other symbol based methods)
  • Loading branch information
rbri committed Jun 7, 2023
1 parent 3df3c89 commit 689f813
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 46 deletions.
20 changes: 0 additions & 20 deletions examples/Matrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.Symbol;

/**
* Matrix: An example host object class that implements the Scriptable interface.
Expand Down Expand Up @@ -94,17 +93,6 @@ public boolean has(int index, Scriptable start) {
return true;
}

/**
* Defines all numeric properties by returning true.
*
* @param key the key of the property
* @param start the object where lookup began
*/
@Override
public boolean has(Symbol key, Scriptable start) {
return true;
}

/**
* Get the named property.
*
Expand Down Expand Up @@ -184,14 +172,6 @@ public void delete(String id) {}
@Override
public void delete(int index) {}

/**
* Remove an symbol property.
*
* <p>This method shouldn't even be called since we define all properties as PERMANENT.
*/
@Override
public void delete(Symbol key) {}

/** Get prototype. */
@Override
public Scriptable getPrototype() {
Expand Down
6 changes: 0 additions & 6 deletions src/org/mozilla/javascript/Scriptable.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ public interface Scriptable {
*/
public boolean has(int index, Scriptable start);

/** A version of delete for properties with Symbol keys. */
public boolean has(Symbol key, Scriptable start);

/**
* Sets a named property in this object.
*
Expand Down Expand Up @@ -231,9 +228,6 @@ public interface Scriptable {
*/
public void delete(int index);

/** A version of delete for properties with Symbol keys. */
public void delete(Symbol key);

/**
* Get the prototype of the object.
*
Expand Down
5 changes: 3 additions & 2 deletions src/org/mozilla/javascript/ScriptableObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -2284,8 +2284,9 @@ public static boolean deleteProperty(Scriptable obj, int index) {
public static boolean deleteProperty(Scriptable obj, Symbol key) {
Scriptable base = getBase(obj, key);
if (base == null) return true;
base.delete(key);
return !base.has(key, obj);
SymbolScriptable scriptable = ensureSymbolScriptable(base);
scriptable.delete(key);
return !scriptable.has(key, obj);
}

/**
Expand Down
8 changes: 0 additions & 8 deletions src/org/mozilla/javascript/Undefined.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ public boolean has(int index, Scriptable start) {
return false;
}

@Override
public boolean has(Symbol key, Scriptable start) {
return false;
}

@Override
public void put(String name, Scriptable start, Object value) {}

Expand All @@ -96,9 +91,6 @@ public void delete(String name) {}
@Override
public void delete(int index) {}

@Override
public void delete(Symbol key) {}

@Override
public Scriptable getPrototype() {
return null;
Expand Down
10 changes: 0 additions & 10 deletions testsrc/org/mozilla/javascript/tests/IterableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,6 @@ public boolean has(int index, Scriptable start) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public boolean has(Symbol key, Scriptable start) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public void put(String name, Scriptable start, Object value) {
throw new UnsupportedOperationException("Not supported yet.");
Expand All @@ -264,11 +259,6 @@ public void delete(int index) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public void delete(Symbol key) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public void setPrototype(Scriptable prototype) {
throw new UnsupportedOperationException("Not supported yet.");
Expand Down

0 comments on commit 689f813

Please sign in to comment.