Skip to content

Commit a749280

Browse files
committed
Clean up Location.setInternal.
1 parent 89d716a commit a749280

File tree

1 file changed

+15
-2
lines changed
  • truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object

1 file changed

+15
-2
lines changed

truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/Location.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,15 +552,28 @@ final void setInternal(DynamicObject receiver, Object value, boolean guard, Shap
552552
longValue = Integer.toUnsignedLong(intValue);
553553
}
554554
} else if (this instanceof LongLocation longLocation) {
555-
longValue = longLocation.isImplicitCastIntToLong() && value instanceof Integer ? ((int) value & 0xffffffffL) : (long) value;
555+
if (value instanceof Long l) {
556+
longValue = l;
557+
} else if (longLocation.isImplicitCastIntToLong() && value instanceof Integer i) {
558+
longValue = Integer.toUnsignedLong(i);
559+
} else {
560+
return;
561+
}
556562
if (field == null) {
557563
Object array = getPrimitiveArray(receiver, guard);
558564
long offset = getPrimitiveArrayOffset();
559565
UnsafeAccess.unsafePutLong(array, offset, longValue, this);
560566
return;
561567
}
562568
} else if (this instanceof DoubleLocation doubleLocation) {
563-
double doubleValue = doubleLocation.isImplicitCastIntToDouble() && value instanceof Integer ? (double) (int) value : (double) value;
569+
double doubleValue;
570+
if (value instanceof Double d) {
571+
doubleValue = d;
572+
} else if (doubleLocation.isImplicitCastIntToDouble() && value instanceof Integer i) {
573+
doubleValue = (double) i;
574+
} else {
575+
return;
576+
}
564577
if (field == null) {
565578
Object array = getPrimitiveArray(receiver, guard);
566579
long offset = getPrimitiveArrayOffset();

0 commit comments

Comments
 (0)