Skip to content

Commit 6322bec

Browse files
committed
Use the Node of the UnsupportedSpecializationException to show the correct line in the backtrace
1 parent 965a0b9 commit 6322bec

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/main/java/org/truffleruby/language/methods/TranslateExceptionNode.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ protected boolean needsSpecialTranslation(Throwable e) {
114114
private static RaiseException doTranslateSpecial(Node node, Throwable e) {
115115
if (e instanceof TruffleString.IllegalByteArrayLengthException) {
116116
return new RaiseException(getContext(node), coreExceptions(node).argumentError(e.getMessage(), node));
117-
} else if (e instanceof UnsupportedSpecializationException) {
117+
} else if (e instanceof UnsupportedSpecializationException unsupported) {
118118
return new RaiseException(getContext(node),
119-
translateUnsupportedSpecialization(node, getContext(node), (UnsupportedSpecializationException) e));
120-
} else if (e instanceof StackOverflowError) {
119+
translateUnsupportedSpecialization(unsupported.getNode(), getContext(node), unsupported));
120+
} else if (e instanceof StackOverflowError stackOverflowError) {
121121
return new RaiseException(getContext(node),
122-
translateStackOverflow(node, getContext(node), (StackOverflowError) e));
122+
translateStackOverflow(node, getContext(node), stackOverflowError));
123123
} else {
124124
return new RaiseException(getContext(node),
125125
translateOutOfMemory(node, getContext(node), (OutOfMemoryError) e));
@@ -175,16 +175,14 @@ public static StringBuilder argumentsToString(StringBuilder builder, Object[] ar
175175

176176
if (value == null) {
177177
builder.append("null");
178-
} else if (value instanceof RubyDynamicObject) {
179-
final RubyDynamicObject dynamicObject = (RubyDynamicObject) value;
178+
} else if (value instanceof RubyDynamicObject dynamicObject) {
180179

181180
builder.append(dynamicObject.getLogicalClass().fields.getName());
182181
builder.append("(");
183182
builder.append(value.getClass().getName());
184183
builder.append(")");
185184

186-
if (value instanceof RubyArray) {
187-
final RubyArray array = (RubyArray) value;
185+
if (value instanceof RubyArray array) {
188186
builder.append("[");
189187

190188
if (array.getStore() == null) {

0 commit comments

Comments
 (0)