Skip to content

Commit

Permalink
Showing 6 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
fails:BasicObject#singleton_method_added is a private method
fails:BasicObject#singleton_method_added is called when a method is defined on self
fails:BasicObject#singleton_method_added is called when a method is defined in the singleton class
fails:BasicObject#singleton_method_added is called when a method is defined with alias_method in the singleton class
fails:BasicObject#singleton_method_added is called when a method is defined with syntax alias in the singleton class
fails:BasicObject#singleton_method_added is called when define_method is used in the singleton class
fails:BasicObject#singleton_method_added is called when a singleton method is defined on an object
fails:BasicObject#singleton_method_added is called when a singleton method is defined on a module
1 change: 0 additions & 1 deletion spec/truffle/tags/core/module/method_added_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@ public static DynamicObject createSingletonClassOfObject(RubyContext context, Dy
// See rb_singleton_class() documentation in MRI.
// Allocator is null here, we cannot create instances of singleton classes.
assert RubyGuards.isRubyClass(superclass);
assert attached == null || RubyGuards.isRubyModule(attached);
assert attached != null;
return ensureSingletonConsistency(context, createRubyClass(context, Layouts.BASIC_OBJECT.getLogicalClass(superclass), null, superclass, name, true, attached));
}

Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.core.klass.ClassNodes;
import org.jruby.truffle.core.method.MethodFilter;
import org.jruby.truffle.core.module.ModuleNodes.IsSingletonClassNode;
import org.jruby.truffle.language.RubyConstant;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
@@ -31,7 +32,6 @@
import org.jruby.truffle.language.objects.IsFrozenNodeGen;
import org.jruby.truffle.language.objects.ObjectGraphNode;
import org.jruby.truffle.language.objects.ObjectIDOperations;

import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Collections;
@@ -348,7 +348,12 @@ public void addMethod(RubyContext context, Node currentNode, InternalMethod meth
newVersion();

if (context.getCoreLibrary().isLoaded() && !method.isUndefined()) {
context.send(rubyModuleObject, "method_added", null, context.getSymbolTable().getSymbol(method.getName()));
if (Layouts.CLASS.isClass(rubyModuleObject) && Layouts.CLASS.getIsSingleton(rubyModuleObject)) {
DynamicObject receiver = Layouts.CLASS.getAttached(rubyModuleObject);
context.send(receiver, "singleton_method_added", null, context.getSymbolTable().getSymbol(method.getName()));
} else {
context.send(rubyModuleObject, "method_added", null, context.getSymbolTable().getSymbol(method.getName()));
}
}
}

Original file line number Diff line number Diff line change
@@ -385,10 +385,10 @@ private static <R> R classVariableLookup(DynamicObject module, Function1<R, Dyna
return result;
}

// If singleton class, check attached module.
// If singleton class of a module, check the attached module.
if (RubyGuards.isRubyClass(module)) {
DynamicObject klass = module;
if (Layouts.CLASS.getIsSingleton(klass) && Layouts.CLASS.getAttached(klass) != null) {
if (Layouts.CLASS.getIsSingleton(klass) && Layouts.MODULE.isModule(Layouts.CLASS.getAttached(klass))) {
module = Layouts.CLASS.getAttached(klass);

result = action.apply(module);
Original file line number Diff line number Diff line change
@@ -145,17 +145,11 @@ protected DynamicObject getSingletonClassForInstance(DynamicObject object) {

final DynamicObject logicalClass = Layouts.BASIC_OBJECT.getLogicalClass(object);

DynamicObject attached = null;

if (RubyGuards.isRubyModule(object)) {
attached = object;
}

final String name = String.format("#<Class:#<%s:0x%x>>", Layouts.MODULE.getFields(logicalClass).getName(),
ObjectIDOperations.verySlowGetObjectID(getContext(), object));

final DynamicObject singletonClass = ClassNodes.createSingletonClassOfObject(
getContext(), logicalClass, attached, name);
getContext(), logicalClass, object, name);

if (isFrozenNode == null) {
isFrozenNode = insert(IsFrozenNodeGen.create(getContext(), getSourceSection(), null));

0 comments on commit 9bda28a

Please sign in to comment.