Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 74617f09d10a
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 579b8f2aea6a
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Oct 28, 2014

  1. Revert "Add current-scope/module instrs after arg receive"

    This reverts commit 2fbbf60.
    
    Conflicts:
    	core/src/main/java/org/jruby/ir/IRBuilder.java
    
    Because optional arguments need to be able to run code, we can't
    move these loads later in the method body.
    headius committed Oct 28, 2014
    Copy the full SHA
    0d38e26 View commit details
  2. Copy the full SHA
    579b8f2 View commit details
Showing with 8 additions and 3 deletions.
  1. +2 −3 core/src/main/java/org/jruby/ir/IRBuilder.java
  2. +6 −0 spec/compiler/general_spec.rb
5 changes: 2 additions & 3 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -1660,13 +1660,12 @@ private IRMethod defineMethodInner(MethodDefNode defNode, IRMethod method, IRSco
// Set %current_scope = <current-scope>
// Set %current_module = isInstanceMethod ? %self.metaclass : %self
int nearestScopeDepth = parent.getNearestModuleReferencingScopeDepth();
addInstr(method, new CopyInstr(method.getCurrentScopeVariable(), new CurrentScope(nearestScopeDepth == -1 ? 1 : nearestScopeDepth)));
addInstr(method, new CopyInstr(method.getCurrentModuleVariable(), new ScopeModule(nearestScopeDepth == -1 ? 1 : nearestScopeDepth)));

// Build IR for arguments (including the block arg)
receiveMethodArgs(defNode.getArgsNode(), method);

addInstr(method, new CopyInstr(method.getCurrentScopeVariable(), new CurrentScope(nearestScopeDepth == -1 ? 1 : nearestScopeDepth)));
addInstr(method, new CopyInstr(method.getCurrentModuleVariable(), new ScopeModule(nearestScopeDepth == -1 ? 1 : nearestScopeDepth)));

// Thread poll on entry to method
addInstr(method, new ThreadPollInstr());

6 changes: 6 additions & 0 deletions spec/compiler/general_spec.rb
Original file line number Diff line number Diff line change
@@ -860,4 +860,10 @@ class JRUBY4925
expect(x).to eq false
end
end

it "compiles optional arguments with a constant" do
run 'def foo(a = Object); a; end; foo' do |x|
expect(x).to eq Object
end
end
end