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: 86815ef7d29f
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d335b276c000
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 9, 2015

  1. Copy the full SHA
    911ae8a View commit details
  2. Copy the full SHA
    d335b27 View commit details
Original file line number Diff line number Diff line change
@@ -225,6 +225,15 @@ public static Map<String, Object> getAllClassVariables(RubyModule module) {
public static Object lookupClassVariable(RubyModule module, String name) {
CompilerAsserts.neverPartOfCompilation();

// If singleton class, check attached module.
if (module instanceof RubyClass) {
RubyClass klass = (RubyClass) module;

if (klass.isSingleton() && klass.getAttached() != null) {
module = klass.getAttached();
}
}

Object value;

// Look in the current module
@@ -243,30 +252,6 @@ public static Object lookupClassVariable(RubyModule module, String name) {
}
}

// If singleton class, check attached module as well.
if (module instanceof RubyClass) {
RubyClass klass = (RubyClass) module;

if (klass.isSingleton() && klass.getAttached() != null) {

// Look in the attached module.
value = klass.getAttached().getClassVariables().get(name);

if (value != null) {
return value;
}

// Look in the attached module's ancestors.
for (RubyModule ancestor : klass.getAttached().parentAncestors()) {
value = ancestor.getClassVariables().get(name);

if (value != null) {
return value;
}
}
}
}

// Nothing found

return null;
Original file line number Diff line number Diff line change
@@ -103,15 +103,15 @@ public RubyClass getSingletonClass(Node currentNode) {
}

final RubyClass logicalClass = metaClass;
RubyModule attached = null;

if (this instanceof RubyModule) {
metaClass = RubyClass.createSingletonClassOfObject(getContext(), logicalClass, (RubyModule) this,
String.format("#<Class:#<%s:0x%x>>", logicalClass.getName(), getObjectID()));
} else {
metaClass = RubyClass.createSingletonClassOfObject(getContext(), logicalClass, null,
String.format("#<Class:#<%s:0x%x>>", logicalClass.getName(), getObjectID()));
attached = (RubyModule) this;
}

metaClass = RubyClass.createSingletonClassOfObject(getContext(), logicalClass, attached,
String.format("#<Class:#<%s:0x%x>>", logicalClass.getName(), getObjectID()));

if (DebugOperations.verySlowIsFrozen(this)) {
DebugOperations.verySlowFreeze(metaClass);
}