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
4 changes: 2 additions & 2 deletions base/opaque_closure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ the argument type may be fixed length even if the function is variadic.
This interface is experimental and subject to change or removal without notice.
"""
macro opaque(ex)
esc(Expr(:opaque_closure, nothing, nothing, nothing, ex))
esc(Expr(:opaque_closure, nothing, nothing, nothing, #= allow_partial =# true, ex))
end

macro opaque(ty, ex)
Expand All @@ -34,7 +34,7 @@ macro opaque(ty, ex)
end
AT = (AT !== :_) ? AT : nothing
RT = (RT !== :_) ? RT : nothing
return esc(Expr(:opaque_closure, AT, RT, RT, ex))
return esc(Expr(:opaque_closure, AT, RT, RT, #= allow_partial =# true, ex))
end

# OpaqueClosure construction from pre-inferred CodeInfo/IRCode
Expand Down
10 changes: 6 additions & 4 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,8 @@
(let* ((argt (something (list (expand-forms (cadr e)) #f)))
(rt_lb (something (list (expand-forms (caddr e)) #f)))
(rt_ub (something (list (expand-forms (cadddr e)) #f)))
(F (caddddr e))
(allow-partial (caddddr e))
(F (cadddddr e))
(isva (let* ((arglist (function-arglist F))
(lastarg (and (pair? arglist) (last arglist))))
(if (and argt (any (lambda (arg)
Expand All @@ -2460,7 +2461,7 @@
(let* ((argtype (foldl (lambda (var ex) `(call (core UnionAll) ,var ,ex))
(expand-forms `(curly (core Tuple) ,@argtypes))
(reverse tvars))))
`(_opaque_closure ,(or argt argtype) ,rt_lb ,rt_ub ,isva ,(length argtypes) ,functionloc ,lam))))
`(_opaque_closure ,(or argt argtype) ,rt_lb ,rt_ub ,isva ,(length argtypes) ,allow-partial ,functionloc ,lam))))

'block
(lambda (e)
Expand Down Expand Up @@ -4028,7 +4029,8 @@ f(x) = yt(x)
((_opaque_closure)
(let* ((isva (car (cddddr e)))
(nargs (cadr (cddddr e)))
(functionloc (caddr (cddddr e)))
(allow-partial (caddr (cddddr e)))
(functionloc (cadddr (cddddr e)))
(lam2 (last e))
(vis (lam:vinfo lam2))
(cvs (map car (cadr vis))))
Expand All @@ -4040,7 +4042,7 @@ f(x) = yt(x)
v)))
cvs)))
`(new_opaque_closure
,(cadr e) ,(or (caddr e) '(call (core apply_type) (core Union))) ,(or (cadddr e) '(core Any)) (true)
,(cadr e) ,(or (caddr e) '(call (core apply_type) (core Union))) ,(or (cadddr e) '(core Any)) ,allow-partial
(opaque_closure_method (null) ,nargs ,isva ,functionloc ,(convert-lambda lam2 (car (lam:args lam2)) #f '() (symbol-to-idx-map cvs)))
,@var-exprs))))
((method)
Expand Down
7 changes: 7 additions & 0 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,13 @@ precompile_test_harness("Generated Opaque") do load_path
Expr(:opaque_closure_method, nothing, 0, false, lno, ci))
end
@assert oc_re_generated_no_partial()() === 1
@generated function oc_re_generated_no_partial_macro()
AT = nothing
RT = nothing
allow_partial = false # makes this legal to generate during pre-compile
return Expr(:opaque_closure, AT, RT, RT, allow_partial, :(()->const_int_barrier()))
end
@assert oc_re_generated_no_partial_macro()() === 1
end
""")
Base.compilecache(Base.PkgId("GeneratedOpaque"))
Expand Down