Commit 33fbfa3b
33fbfa3b8755Merged
sacckey <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified
Description
fix(codegen): box polymorphic method returns as sp_RbVal
Details
- Commit
- 33fbfa3b8755
- Parent
- c98048e104bd
spinel_codegen.rbmodifiedView file
@@ -18488,6 +18488,18 @@
1848818488
if args_id >= 01848918489
arg_ids = get_args(args_id)1849018490
if arg_ids.length > 018491+
if @current_method_return == "poly"18492+
ret_expr = box_expr_to_poly(arg_ids[0])18493+
if @in_gc_scope == 118494+
tmp = new_temp18495+
emit(" sp_RbVal " + tmp + " = " + ret_expr + ";")18496+
emit(" SP_GC_RESTORE();")18497+
emit(" return " + tmp + ";")18498+
else18499+
emit(" return " + ret_expr + ";")18500+
end18501+
return18502+
end1849118503
rt = infer_type(arg_ids[0])1849218504
# return nil in a nullable pointer method → return NULL1849318505
if rt == "nil" && is_nullable_pointer_type(@current_method_return) == 1@@ -23442,6 +23454,10 @@
2344223454
return2344323455
end2344423456
if return_type != "void"23457+
if return_type == "poly"23458+
emit(" return " + box_expr_to_poly(last) + ";")23459+
return23460+
end2344523461
val = compile_expr(last)2344623462
expr_type = infer_type(last)2344723463
if expr_type == "lambda"test/poly_dispatch_args_ret.rbaddedView file
Loading diff…