Closed
Description
I attempted to java_import org.jruby.util.TypeConverter and ran into this error inside Array#flatten! logic:
ArgumentError: wrong number of arguments (0 for 2)
flatten! at org/jruby/RubyArray.java:2839
java_import at file:/Users/headius/projects/jruby/lib/jruby.jar!/jruby/java/core_ext/object.rb:20
(root) at file:/Users/headius/projects/jruby/lib/jruby.jar!/jruby/kernel/jruby/type.rb:3
(root) at file:/Users/headius/projects/jruby/lib/jruby.jar!/jruby/kernel.rb:1
(root) at file:/Users/headius/projects/jruby/lib/jruby.jar!/jruby/kernel.rb:4
load at org/jruby/RubyKernel.java:969
(root) at :1
The cause: flatten attempts to coerce elements to Array by calling to_ary with no arguments, but TypeConverter defines a static utility method to_ary(ThreadContext, IRubyObject).
The associated lines of code are seen in the trace above. I think we should just back off flatten! call and do something dumber and more manual that just requires everything already be an Array. That will avoid any future issues with unusual method names getting called for coercion.