Skip to content

Commit f5d0b3d

Browse files
nirvdrumparacycle
andcommitted
Implement UnboundMethod#original_name.
Co-authored-by: Ufuk Kayserilioglu <[email protected]>
1 parent 9b4e6b8 commit f5d0b3d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Compatibility:
7676
* Fix `Enumerable` methods `each_cons` and `each_slice` to return receiver (#2733, @horakivo)
7777
* `Module` methods `#private`, `#public`, `#protected`, `#module_function` now returns their arguments like in CRuby 3.1 (#2733, @horakivo)
7878
* `Kernel#exit!`, killing Fibers and internal errors do not run code in `ensure` clauses anymore, the same as CRuby (@eregon).
79+
* Implement `UnboundMethod#original_name` (@paracycle, @nirvdrum).
7980

8081
Performance:
8182

spec/tags/core/unboundmethod/original_name_tags.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/main/java/org/truffleruby/core/method/UnboundMethodNodes.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.truffleruby.builtins.PrimitiveArrayArgumentsNode;
2020
import org.truffleruby.core.Hashing;
2121
import org.truffleruby.core.array.RubyArray;
22+
import org.truffleruby.core.cast.ToSymbolNode;
2223
import org.truffleruby.core.encoding.Encodings;
2324
import org.truffleruby.core.klass.RubyClass;
2425
import org.truffleruby.core.module.MethodLookupResult;
@@ -147,6 +148,19 @@ protected RubyModule origin(RubyUnboundMethod unboundMethod) {
147148

148149
}
149150

151+
@CoreMethod(names = "original_name")
152+
public abstract static class OriginalNameNode extends CoreMethodArrayArgumentsNode {
153+
154+
@Specialization
155+
protected RubySymbol originalName(RubyUnboundMethod unboundMethod,
156+
@Cached ToSymbolNode toSymbolNode) {
157+
String originalName = unboundMethod.method.getSharedMethodInfo().getBacktraceName();
158+
159+
return toSymbolNode.execute(originalName);
160+
}
161+
162+
}
163+
150164
@CoreMethod(names = "owner")
151165
public abstract static class OwnerNode extends CoreMethodArrayArgumentsNode {
152166

0 commit comments

Comments
 (0)