Skip to content

Commit

Permalink
[Truffle] Use the original method name for super.
Browse files Browse the repository at this point in the history
* Fix name in SharedMethodInfo of define_method's methods.
  • Loading branch information
eregon committed Mar 9, 2015
1 parent 9d31d67 commit 2063892
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion spec/truffle/tags/language/super_tags.txt
Expand Up @@ -2,4 +2,3 @@ fails:The super keyword passes along modified rest args when they weren't origin
fails:The super keyword passes along modified rest args when they were originally empty
fails:The super keyword raises a RuntimeError when called with implicit arguments from a method defined with define_method
fails:The super keyword calls method_missing when a superclass method is not found
fails:The super keyword sees the included version of a module a method is alias from
Expand Up @@ -973,7 +973,8 @@ private RubySymbol defineMethod(RubyModule module, String name, RubyProc proc) {
notDesignedForCompilation();

final CallTarget modifiedCallTarget = proc.getCallTargetForMethods();
final InternalMethod modifiedMethod = new InternalMethod(proc.getSharedMethodInfo(), name, module, Visibility.PUBLIC, false, modifiedCallTarget, proc.getDeclarationFrame());
final SharedMethodInfo info = proc.getSharedMethodInfo().withName(name);
final InternalMethod modifiedMethod = new InternalMethod(info, name, module, Visibility.PUBLIC, false, modifiedCallTarget, proc.getDeclarationFrame());
module.addMethod(this, modifiedMethod);

return getContext().getSymbolTable().getSymbol(name);
Expand Down
Expand Up @@ -67,7 +67,7 @@ private void lookup(VirtualFrame frame, boolean checkIfDefined) {

currentMethod = RubyArguments.getMethod(frame.getArguments());

String name = currentMethod.getName();
String name = currentMethod.getSharedMethodInfo().getName(); // use the original name
RubyModule declaringModule = currentMethod.getDeclaringModule();

selfMetaClass = getContext().getCoreLibrary().getMetaClass(RubyArguments.getSelf(frame.getArguments()));
Expand Down
Expand Up @@ -22,6 +22,7 @@ public class SharedMethodInfo {
private final SourceSection sourceSection;
private final LexicalScope lexicalScope;
private final Arity arity;
/** The original name of the method. Does not change when aliased. */
private final String name;
private final boolean isBlock;
private final org.jruby.ast.Node parseTree;
Expand Down Expand Up @@ -68,6 +69,10 @@ public boolean shouldAlwaysSplit() {
return alwaysSplit;
}

public SharedMethodInfo withName(String newName) {
return new SharedMethodInfo(sourceSection, lexicalScope, arity, newName, isBlock, parseTree, alwaysSplit);
}

@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
Expand Down

0 comments on commit 2063892

Please sign in to comment.