Skip to content

Commit fbb9154

Browse files
committed
Minor cleanup
1 parent 35a42df commit fbb9154

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

spec/ruby/core/module/const_added_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ class SubClass
122122
ScratchPad.recorded.should == [line + 2, line + 4, line + 7, line + 11]
123123
end
124124

125-
it "is called when the constant is ready to be used" do
125+
it "is called when the constant is already assigned a value" do
126+
ScratchPad.record []
127+
126128
mod = Module.new do
127129
def self.const_added(name)
128130
ScratchPad.record const_get(name)

spec/truffleruby.next-specs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ spec/ruby/core/sizedqueue/deq_spec.rb
3030
spec/ruby/core/sizedqueue/pop_spec.rb
3131
spec/ruby/core/sizedqueue/shift_spec.rb
3232

33+
spec/ruby/core/module/const_added_spec.rb
3334
spec/ruby/core/module/refinements_spec.rb
3435
spec/ruby/core/refinement/refined_class_spec.rb
3536
spec/ruby/core/module/used_refinements_spec.rb
3637
spec/ruby/optional/capi/hash_spec.rb
37-
spec/ruby/core/module/const_added_spec.rb

src/main/java/org/truffleruby/core/module/ModuleFields.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ public void setAutoloadConstant(RubyContext context, Node currentNode, String na
458458
context.getFeatureLoader().addAutoload(autoloadConstant);
459459
}
460460

461+
@TruffleBoundary
461462
private RubyConstant setConstantInternal(RubyContext context, Node currentNode, String name, Object value,
462463
boolean autoload) {
463464
checkFrozen(context, currentNode);
@@ -497,8 +498,8 @@ private RubyConstant setConstantInternal(RubyContext context, Node currentNode,
497498

498499
final CoreLibrary coreLibrary = context.getCoreLibrary();
499500
if (currentNode != null && coreLibrary != null && coreLibrary.isLoaded()) {
500-
final RubySymbol constSymbol = context.getLanguageSlow().getSymbol(name);
501-
RubyContext.send(currentNode, rubyModule, "const_added", constSymbol);
501+
final RubySymbol nameSymbol = context.getLanguageSlow().getSymbol(name);
502+
RubyContext.send(currentNode, rubyModule, "const_added", nameSymbol);
502503
}
503504

504505
return autoload ? newConstant : previous;

src/main/ruby/truffleruby/core/module.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ def include?(mod)
6161
ancestors.any? { |m| Primitive.equal?(mod, m) }
6262
end
6363

64+
private def const_added(name)
65+
end
66+
6467
private def method_added(name)
6568
end
6669

@@ -105,9 +108,6 @@ def prepend(*modules)
105108
self
106109
end
107110

108-
private def const_added(name)
109-
end
110-
111111
def const_defined?(name, inherit = true)
112112
Primitive.module_const_defined?(self, name, inherit, true)
113113
end

0 commit comments

Comments
 (0)