Skip to content

Commit 7c28f67

Browse files
committed
fix test
1 parent 188f977 commit 7c28f67

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/RuntimeGeneratedFunctions.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module RuntimeGeneratedFunctions
22

33
using ExprTools, Serialization, SHA
4+
import Base.Experimental: @opaque
45

56
export RuntimeGeneratedFunction, @RuntimeGeneratedFunction, drop_expr
67

@@ -34,9 +35,7 @@ If `opaque_closures` is `true`, all closures in `function_expression` are
3435
converted to
3536
[opaque closures](https://github.com/JuliaLang/julia/pull/37849#issue-496641229).
3637
This allows for the use of closures and generators inside the generated function,
37-
but may not work in all cases due to slightly different semantics. This feature
38-
requires Julia 1.7.
39-
38+
but may not work in all cases due to slightly different semantics.
4039
# Examples
4140
```
4241
RuntimeGeneratedFunctions.init(@__MODULE__) # Required at module top-level
@@ -56,10 +55,7 @@ struct RuntimeGeneratedFunction{argnames, cache_tag, context_tag, id, B} <: Func
5655
def = splitdef(ex)
5756
args = normalize_args(get(def, :args, Symbol[]))
5857
body = def[:body]
59-
if opaque_closures && isdefined(Base, :Experimental) &&
60-
isdefined(Base.Experimental, Symbol("@opaque"))
61-
body = closures_to_opaque(body)
62-
end
58+
body = closures_to_opaque(body)
6359
id = expr_to_id(body)
6460
cached_body = _cache_body(cache_tag, id, body)
6561
new{Tuple(args), cache_tag, context_tag, id, typeof(cached_body)}(cached_body)
@@ -306,7 +302,8 @@ function closures_to_opaque(ex::Expr, return_type = nothing)
306302
fdef[:body] = body
307303
name = get(fdef, :name, nothing)
308304
name !== nothing && delete!(fdef, :name)
309-
_ex = Expr(:macrocall, Symbol("@opaque"), LineNumberNode(0), combinedef(fdef))
305+
opaque = Expr(:., Expr(:., :Base, QuoteNode(:Experimental)), QuoteNode(Symbol("@opaque")))
306+
_ex = Expr(:macrocall, opaque, LineNumberNode(0), combinedef(fdef))
310307
# TODO: emit named opaque closure for better stacktraces
311308
# (ref https://github.com/JuliaLang/julia/pull/40242)
312309
if name !== nothing

0 commit comments

Comments
 (0)