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 @@ -29,6 +29,7 @@ Compatibility:
29
29
* Add ` Module#refinements ` (#3039 , @itarato ).
30
30
* Add ` Refinement#refined_class ` (#3039 , @itarato ).
31
31
* Add ` rb_hash_new_capa ` function (#3039 , @itarato ).
32
+ * Add ` Module#undefined_instance_methods ` (#3039 , @itarato ).
32
33
33
34
Performance:
34
35
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 @@ -34,3 +34,4 @@ spec/ruby/core/module/refinements_spec.rb
34
34
spec/ruby/core/refinement/refined_class_spec.rb
35
35
spec/ruby/core/module/used_refinements_spec.rb
36
36
spec/ruby/optional/capi/hash_spec.rb
37
+ spec/ruby/core/module/undefined_instance_methods_spec.rb
Original file line number Diff line number Diff line change @@ -2355,4 +2355,22 @@ protected Object doClass(RubyClass rubyClass) {
2355
2355
return rubyClass .isSingleton ;
2356
2356
}
2357
2357
}
2358
+
2359
+ @ CoreMethod (names = "undefined_instance_methods" )
2360
+ public abstract static class UndefinedInstanceMethodsNode extends CoreMethodArrayArgumentsNode {
2361
+
2362
+ @ Specialization
2363
+ @ TruffleBoundary
2364
+ protected RubyArray undefinedInstanceMethods (RubyModule module ) {
2365
+ List <RubySymbol > methodNames = new ArrayList <>();
2366
+
2367
+ for (InternalMethod methodEntry : module .fields .getMethods ()) {
2368
+ if (methodEntry != null && methodEntry .isUndefined ()) {
2369
+ methodNames .add (getLanguage ().getSymbol (methodEntry .getName ()));
2370
+ }
2371
+ }
2372
+
2373
+ return createArray (methodNames .toArray ());
2374
+ }
2375
+ }
2358
2376
}
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