Skip to content

Instantly share code, notes, and snippets.

@headius

headius/.diff Secret

Created January 26, 2023 15:37
Show Gist options
  • Save headius/b9d3b5d7f9fb79b9013d78079ac773ef to your computer and use it in GitHub Desktop.
Save headius/b9d3b5d7f9fb79b9013d78079ac773ef to your computer and use it in GitHub Desktop.
diff --git a/core/src/main/java/org/jruby/ir/IRBuilder.java b/core/src/main/java/org/jruby/ir/IRBuilder.java
index 6750379b09..d38d6f2b25 100644
--- a/core/src/main/java/org/jruby/ir/IRBuilder.java
+++ b/core/src/main/java/org/jruby/ir/IRBuilder.java
@@ -3575,14 +3575,28 @@ public class IRBuilder {
IRScope outerScope = scope.getNearestTopLocalVariableScope();
// 'using single_mod_arg' possible nearly everywhere but method scopes.
- if (!(outerScope instanceof IRMethod) && args.length == 1
- && (
- CommonByteLists.USING_METHOD.equals(methodName.getBytes())
- // FIXME: This sets the bit for the whole module, but really only the refine block needs it
- || CommonByteLists.REFINE_METHOD.equals(methodName.getBytes())
- )) {
- scope.setIsMaybeUsingRefinements();
+ boolean refinement = false;
+ if (!(outerScope instanceof IRMethod)) {
+ ByteList methodBytes = methodName.getBytes();
+ if (args.length == 1) {
+ refinement = isRefinementCall(methodBytes);
+ } else if (args.length == 2
+ && CommonByteLists.SEND.equal(methodBytes)) {
+ if (args[1] instanceof Symbol) {
+ Symbol sendName = (Symbol) args[1];
+ methodBytes = sendName.getBytes();
+ refinement = isRefinementCall(methodBytes);
+ }
+ }
}
+
+ if (refinement) scope.setIsMaybeUsingRefinements();
+ }
+
+ private static boolean isRefinementCall(ByteList methodBytes) {
+ return CommonByteLists.USING_METHOD.equals(methodBytes)
+ // FIXME: This sets the bit for the whole module, but really only the refine block needs it
+ || CommonByteLists.REFINE_METHOD.equals(methodBytes);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment