Skip to content

Commit

Permalink
Need to limit this search so we don't walk module-included modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Apr 17, 2015
1 parent 457a569 commit c725c69
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions core/src/main/java/org/jruby/IncludedModuleWrapper.java
Expand Up @@ -208,7 +208,17 @@ public IRubyObject getAutoloadConstant(String name) {

@Override
protected DynamicMethod searchMethodCommon(String name) {
// try us and superclasses (from prepend)
return origin.searchMethodInner(name);
// IncludedModuleWrapper needs to search prepended modules too, but not included ones.
RubyModule module = this;
for (; module.isPrepended(); module = module.getSuperClass()) {
DynamicMethod method = module.getMethods().get(name);
if (method != null) return method.isNull() ? null : method;
}

// Last non-prepended module should be our regular module, do one last search.
DynamicMethod method = module.getMethods().get(name);
if (method != null) return method.isNull() ? null : method;

return null;
}
}

0 comments on commit c725c69

Please sign in to comment.