nitc :: JavaCompilerVisitor :: add_cast
# Add a dynamic cast
fun add_cast(value: RuntimeVariable, mtype: MType) do
var res = type_test(value, mtype)
add("if (!{res}) \{")
add("System.err.print(\"Runtime error: Cast failed. Expected `{mtype.to_s.escape_to_c}`, got `\" + {value}.rtclass.class_name + \"`\");")
add_raw_abort
add("\}")
end
src/compiler/java_compiler.nit:802,2--809,4