Skip to content

Commit

Permalink
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
Original file line number Diff line number Diff line change
@@ -432,7 +432,7 @@ public boolean isClassVariableDefined(RubyModule module, RubySymbol name) {

}

@CoreMethod(names = "constants", maxArgs = 0)
@CoreMethod(names = "constants", minArgs = 0, maxArgs = 1)
public abstract static class ConstantsNode extends CoreMethodNode {

public ConstantsNode(RubyContext context, SourceSection sourceSection) {
@@ -444,11 +444,17 @@ public ConstantsNode(ConstantsNode prev) {
}

@Specialization
public RubyArray constants(@SuppressWarnings("unused") RubyModule module) {
public RubyArray constants(RubyModule module, UndefinedPlaceholder unused) {
return constants(module, true);
}

@Specialization
public RubyArray constants(RubyModule module, boolean inherit) {
notDesignedForCompilation();

final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());

// TODO(cs): handle inherit
for (String constant : module.getConstants().keySet()) {
array.slowPush(getContext().newSymbol(constant));
}

0 comments on commit 8ec4a4a

Please sign in to comment.