Skip to content

Commit

Permalink
Fixes #4732. Error executing elm-install from elm_install gem.
Browse files Browse the repository at this point in the history
Wow!  So order of when method_added and singleton_method_added matter for some
gems (in this case contracts).
enebo committed Aug 17, 2017

Unverified

This user has not yet uploaded their public signing key.
1 parent 9bd7e92 commit f0594e2
Showing 2 changed files with 28 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -1788,14 +1788,15 @@ public static RubySymbol addInstanceMethod(RubyModule containingClass, String na
containingClass.addMethod(name, method);

RubySymbol sym = runtime.fastNewSymbol(name);
if (visibility == Visibility.MODULE_FUNCTION) {
addModuleMethod(containingClass, name, method, context, sym);
}

if (!containingClass.isRefinement()) {
callNormalMethodHook(containingClass, context, sym);
}

if (visibility == Visibility.MODULE_FUNCTION) {
addModuleMethod(containingClass, name, method, context, sym);
}

return sym;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
describe "Module#module_function" do
it "will call method_added before method_singleton_added" do
module GH4732
def self.order
@order ||= []
end

def self.method_added(name)
order << [:method_added, name]
end

def self.singleton_method_added(name)
order << [:singleton_method_added, name]
end

module_function

def foo
end
end

expect(GH4732.order).to eq([[:singleton_method_added, :singleton_method_added], [:method_added, :foo], [:singleton_method_added, :foo]])
end
end

0 comments on commit f0594e2

Please sign in to comment.