@@ -1559,6 +1559,7 @@ public abstract static class RespondToNode extends CoreMethodNode {
1559
1559
@ Child private InternalRespondToNode dispatch ;
1560
1560
@ Child private InternalRespondToNode dispatchIgnoreVisibility ;
1561
1561
@ Child private InternalRespondToNode dispatchRespondToMissing ;
1562
+ @ Child private ReadCallerFrameNode readCallerFrame = ReadCallerFrameNode .create ();
1562
1563
@ Child private DispatchNode respondToMissingNode ;
1563
1564
@ Child private BooleanCastNode booleanCastNode ;
1564
1565
private final ConditionProfile ignoreVisibilityProfile = ConditionProfile .create ();
@@ -1587,6 +1588,7 @@ protected boolean doesRespondToString(
1587
1588
boolean includeProtectedAndPrivate ,
1588
1589
@ Cached ToJavaStringNode toJavaString ) {
1589
1590
final boolean ret ;
1591
+ useCallerRefinements (frame );
1590
1592
1591
1593
if (ignoreVisibilityProfile .profile (includeProtectedAndPrivate )) {
1592
1594
ret = dispatchIgnoreVisibility .execute (frame , object , toJavaString .executeToJavaString (name ));
@@ -1616,6 +1618,7 @@ protected boolean doesRespondToSymbol(
1616
1618
boolean includeProtectedAndPrivate ,
1617
1619
@ Cached ToJavaStringNode toJavaString ) {
1618
1620
final boolean ret ;
1621
+ useCallerRefinements (frame );
1619
1622
1620
1623
if (ignoreVisibilityProfile .profile (includeProtectedAndPrivate )) {
1621
1624
ret = dispatchIgnoreVisibility .execute (frame , object , toJavaString .executeToJavaString (name ));
@@ -1648,6 +1651,13 @@ private boolean respondToMissing(VirtualFrame frame, Object object, RubySymbol n
1648
1651
return booleanCastNode .executeToBoolean (
1649
1652
respondToMissingNode .call (object , "respond_to_missing?" , name , includeProtectedAndPrivate ));
1650
1653
}
1654
+
1655
+ private void useCallerRefinements (VirtualFrame frame ) {
1656
+ if (frame != null ) {
1657
+ DeclarationContext context = RubyArguments .getDeclarationContext (readCallerFrame .execute (frame ));
1658
+ RubyArguments .setDeclarationContext (frame , context );
1659
+ }
1660
+ }
1651
1661
}
1652
1662
1653
1663
@ CoreMethod (names = "respond_to_missing?" , required = 2 )
0 commit comments