Skip to content

Commit 9e0af49

Browse files
committed
[Truffle] Implemented NilClass#dup.
1 parent 96be43f commit 9e0af49

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

core/src/main/java/org/jruby/truffle/nodes/core/NilClassNodes.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.oracle.truffle.api.source.*;
1313
import com.oracle.truffle.api.dsl.*;
1414
import org.jruby.truffle.runtime.*;
15+
import org.jruby.truffle.runtime.control.RaiseException;
1516
import org.jruby.truffle.runtime.core.*;
1617

1718
@CoreClass(name = "NilClass")
@@ -119,6 +120,23 @@ public RubyString toS() {
119120
}
120121
}
121122

123+
@CoreMethod(names = "dup", needsSelf = false)
124+
public abstract static class DupNode extends CoreMethodNode {
125+
126+
public DupNode(RubyContext context, SourceSection sourceSection) {
127+
super(context, sourceSection);
128+
}
129+
130+
public DupNode(DupNode prev) {
131+
super(prev);
132+
}
133+
134+
@Specialization
135+
public RubyString dup() {
136+
throw new RaiseException(getContext().getCoreLibrary().typeError("can't dup NilClass", this));
137+
}
138+
}
139+
122140
@CoreMethod(names = "&", needsSelf = false, required = 1)
123141
public abstract static class AndNode extends CoreMethodNode {
124142

spec/truffle/tags/core/nil/dup_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)