Skip to content

Commit 84659b9

Browse files
committed
Replace isIntOrLong() by the correct isImplicitLong()
* Otherwise byte/short=>int/long implicit casts would be ignored.
1 parent c717947 commit 84659b9

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

src/main/java/org/truffleruby/core/numeric/IntegerNodes.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ protected long powTwoLong(int base, int exponent) {
16381638
@ExplodeLoop(kind = LoopExplosionKind.FULL_UNROLL)
16391639
@Specialization(
16401640
guards = {
1641-
"isIntOrLong(base)",
1641+
"isImplicitLong(base)",
16421642
"exponent == cachedExponent",
16431643
"cachedExponent >= 0",
16441644
"cachedExponent <= 10" },
@@ -1667,7 +1667,7 @@ protected Object powConstantExponent(Object base, int exponent,
16671667
return result;
16681668
}
16691669

1670-
@Specialization(guards = { "isIntOrLong(base)", "exponent >= 0" })
1670+
@Specialization(guards = { "isImplicitLong(base)", "exponent >= 0" })
16711671
protected Object powLoop(Object base, long exponent,
16721672
@Cached BranchProfile overflowProfile,
16731673
@Cached MulNode mulNode) {
@@ -1789,10 +1789,6 @@ protected Object pow(Object base, Object exponent) {
17891789
return FAILURE;
17901790
}
17911791

1792-
protected static boolean isIntOrLong(Object value) {
1793-
return value instanceof Integer || value instanceof Long;
1794-
}
1795-
17961792
protected int getLimit() {
17971793
return getLanguage().options.POW_CACHE;
17981794
}

src/main/java/org/truffleruby/core/range/RangeNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ protected RubyLongRange longRange(RubyClass rubyClass, long begin, long end, boo
541541
return range;
542542
}
543543

544-
@Specialization(guards = { "rubyClass != getRangeClass() || (!isIntOrLong(begin) || !isIntOrLong(end))" })
544+
@Specialization(guards = { "rubyClass != getRangeClass() || (!isImplicitLong(begin) || !isImplicitLong(end))" })
545545
protected RubyObjectRange objectRange(RubyClass rubyClass, Object begin, Object end, boolean excludeEnd,
546546
@Cached DispatchNode compare) {
547547

src/main/java/org/truffleruby/language/RubyGuards.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ public static boolean isString(Object value) {
5858
return value instanceof String;
5959
}
6060

61-
public static boolean isIntOrLong(Object value) {
62-
return value instanceof Integer || value instanceof Long;
63-
}
64-
6561
public static boolean isImplicitDouble(Object object) {
6662
return object instanceof Float || object instanceof Double;
6763
}

0 commit comments

Comments
 (0)