Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3809,7 +3809,7 @@ JL_DLLEXPORT jl_value_t *jl_normalize_to_compilable_sig(jl_tupletype_t *ti, jl_s
jl_method_instance_t *jl_normalize_to_compilable_mi(jl_method_instance_t *mi JL_PROPAGATES_ROOT)
{
jl_method_t *def = mi->def.method;
if (!jl_is_method(def) || !jl_is_datatype(mi->specTypes))
if (!jl_is_method(def) || !jl_is_datatype(mi->specTypes) || def->is_for_opaque_closure)
return mi;
jl_value_t *compilationsig = jl_normalize_to_compilable_sig((jl_datatype_t*)mi->specTypes, mi->sparam_vals, def, 1);
if (compilationsig == jl_nothing || jl_egal(compilationsig, mi->specTypes))
Expand Down
14 changes: 14 additions & 0 deletions test/opaque_closure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,20 @@ let src = code_typed((Int,Int)) do x, y...
@test oc(1,2) === (1,(2,))
@test_throws MethodError oc(1,2,3)
end

# with manually constructed IRCode, without round-trip to CodeInfo
f59222(xs...) = length(xs)
ir = Base.code_ircode_by_type(Tuple{typeof(f59222), Symbol, Symbol})[1][1]
ir.argtypes[1] = Tuple{}
let oc = OpaqueClosure(ir; isva=true)
@test oc(:a, :b) == 2
end
ir = Base.code_ircode_by_type(Tuple{typeof(f59222), Symbol, Vararg{Symbol}})[1][1]
ir.argtypes[1] = Tuple{}
let oc = OpaqueClosure(ir; isva=true)
@test oc(:a) == 1
@test oc(:a, :b, :c) == 3
end
end

# Check for correct handling in case of broken return type.
Expand Down