Validate that the expected type and the returned one are compatible. Not sure if we should return null or return exception :thinking: What do ppl think? Or should we just cover known cases and leave the current behavior as lat resort?
It was not my idea to close this yet. The latest fixes prevent returning invalid types but I still think it's worth thinking deeply about how we should expose the convert/load methods in a more Java-like way.
The following example converts an AsciiDoc source to a String, but has 2 problems:
org.jruby.gen.InterfaceImpl682315553
)Document.class
.Both happen because we don't validate the types, but just delegate in jRuby https://github.com/asciidoctor/asciidoctorj/blob/0240f02d54268bc484d6da210d0803c0156578e0/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JRubyAsciidoctor.java#L314.
I think we should: