File tree Expand file tree Collapse file tree 5 files changed +30
-0
lines changed
src/main/java/org/truffleruby/core/module Expand file tree Collapse file tree 5 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ Compatibility:
31
31
* Add ` Refinement#refined_class ` (#3039 , @itarato ).
32
32
* Add ` rb_hash_new_capa ` function (#3039 , @itarato ).
33
33
* Fix ` Encoding::Converter#primitive_convert ` and raise ` FrozenError ` when a destination buffer argument is frozen (@andrykonchin ).
34
+ * Add ` Module#undefined_instance_methods ` (#3039 , @itarato ).
34
35
35
36
Performance:
36
37
Original file line number Diff line number Diff line change @@ -115,3 +115,4 @@ fails:Public methods on UnboundMethod should include protected?
115
115
fails:Public methods on UnboundMethod should include public?
116
116
fails:Public methods on String should not include bytesplice
117
117
fails:Public methods on Module should not include refinements
118
+ fails:Public methods on Module should not include undefined_instance_methods
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ spec/ruby/core/sizedqueue/pop_spec.rb
31
31
spec/ruby/core/sizedqueue/shift_spec.rb
32
32
33
33
spec/ruby/core/module/refinements_spec.rb
34
+ spec/ruby/core/module/undefined_instance_methods_spec.rb
34
35
spec/ruby/core/refinement/refined_class_spec.rb
35
36
spec/ruby/core/module/used_refinements_spec.rb
36
37
spec/ruby/optional/capi/hash_spec.rb
Original file line number Diff line number Diff line change @@ -2356,4 +2356,22 @@ protected Object doClass(RubyClass rubyClass) {
2356
2356
return rubyClass .isSingleton ;
2357
2357
}
2358
2358
}
2359
+
2360
+ @ CoreMethod (names = "undefined_instance_methods" )
2361
+ public abstract static class UndefinedInstanceMethodsNode extends CoreMethodArrayArgumentsNode {
2362
+
2363
+ @ Specialization
2364
+ @ TruffleBoundary
2365
+ protected RubyArray undefinedInstanceMethods (RubyModule module ) {
2366
+ List <RubySymbol > methodNames = new ArrayList <>();
2367
+
2368
+ for (InternalMethod methodEntry : module .fields .getMethods ()) {
2369
+ if (methodEntry .isUndefined ()) {
2370
+ methodNames .add (getLanguage ().getSymbol (methodEntry .getName ()));
2371
+ }
2372
+ }
2373
+
2374
+ return createArray (methodNames .toArray ());
2375
+ }
2376
+ }
2359
2377
}
Original file line number Diff line number Diff line change @@ -955,6 +955,15 @@ def test_public_instance_methods
955
955
assert_equal ( [ :bClass1 ] , BClass . public_instance_methods ( false ) )
956
956
end
957
957
958
+ def test_undefined_instance_methods
959
+ assert_equal ( [ ] , AClass . undefined_instance_methods )
960
+ assert_equal ( [ ] , BClass . undefined_instance_methods )
961
+ c = Class . new ( AClass ) { undef aClass }
962
+ assert_equal ( [ :aClass ] , c . undefined_instance_methods )
963
+ c = Class . new ( c )
964
+ assert_equal ( [ ] , c . undefined_instance_methods )
965
+ end
966
+
958
967
def test_s_public
959
968
o = ( c = Class . new ( AClass ) ) . new
960
969
assert_raise ( NoMethodError , /private method/ ) { o . aClass1 }
You can’t perform that action at this time.
0 commit comments