Skip to content

Commit

Permalink
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/module/alias_method_tags.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
fails:Module#alias_method converts the names using #to_str
fails:Module#alias_method is a private method
fails:Module#alias_method aliasing special methods keeps initialize private when aliasing
fails:Module#alias_method aliasing special methods keeps initialize_copy private when aliasing
fails:Module#alias_method aliasing special methods keeps initialize_clone private when aliasing
fails:Module#alias_method aliasing special methods keeps initialize_dup private when aliasing
fails:Module#alias_method aliasing special methods keeps respond_to_missing? private when aliasing
fails:Module#alias_method preserves the arguments information of the original methods
Original file line number Diff line number Diff line change
@@ -281,25 +281,32 @@ public Object compare(VirtualFrame frame, RubyModule self, RubyBasicObject other
}

@CoreMethod(names = "alias_method", required = 2)
public abstract static class AliasMethodNode extends CoreMethodArrayArgumentsNode {
@NodeChildren({
@NodeChild(type = RubyNode.class, value = "module"),
@NodeChild(type = RubyNode.class, value = "newName"),
@NodeChild(type = RubyNode.class, value = "oldName")
})
public abstract static class AliasMethodNode extends CoreMethodNode {

public AliasMethodNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public RubyModule aliasMethod(RubyModule module, RubySymbol newName, RubySymbol oldName) {
CompilerDirectives.transferToInterpreter();
@CreateCast("newName")
public RubyNode coercetNewNameToString(RubyNode newName) {
return SymbolOrToStrNodeGen.create(getContext(), getSourceSection(), newName);
}

module.alias(this, newName.toString(), oldName.toString());
return module;
@CreateCast("oldName")
public RubyNode coerceOldNameToString(RubyNode oldName) {
return SymbolOrToStrNodeGen.create(getContext(), getSourceSection(), oldName);
}

@Specialization
public RubyModule aliasMethod(RubyModule module, RubyString newName, RubyString oldName) {
public RubyModule aliasMethod(RubyModule module, String newName, String oldName) {
CompilerDirectives.transferToInterpreter();

module.alias(this, newName.toString(), oldName.toString());
module.alias(this, newName, oldName);
return module;
}

0 comments on commit 42fcefa

Please sign in to comment.