From a02baf10c2fc58081357d386909b8aaf139bed2a Mon Sep 17 00:00:00 2001 From: CarloLucibello Date: Sat, 15 May 2021 10:50:48 +0200 Subject: [PATCH] fix isgenerated on nightly --- src/reflection/reflection.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/reflection/reflection.jl b/src/reflection/reflection.jl index 6a1653e..77485fb 100644 --- a/src/reflection/reflection.jl +++ b/src/reflection/reflection.jl @@ -2,6 +2,12 @@ using Core: CodeInfo, Typeof using Core.Compiler: InferenceState, MethodInstance, svec using InteractiveUtils: typesof +if isdefined(Base, :hasgenerator) # VERSION >= v"1.7.0" + hasgenerator(x) = Base.hasgenerator(x) +else + hasgenerator(x) = Base.isgenerated(x) +end + worldcounter() = ccall(:jl_get_world_counter, UInt, ()) isprecompiling() = ccall(:jl_generating_output, Cint, ()) == 1 @@ -46,10 +52,10 @@ function meta(T; types = T, world = worldcounter()) sps = svec(map(untvar, sps)...) @static if VERSION >= v"1.2-" mi = Core.Compiler.specialize_method(method, types, sps) - ci = Base.isgenerated(mi) ? Core.Compiler.get_staged(mi) : Base.uncompressed_ast(method) + ci = hasgenerator(mi) ? Core.Compiler.get_staged(mi) : Base.uncompressed_ast(method) else mi = Core.Compiler.code_for_method(method, types, sps, world, false) - ci = Base.isgenerated(mi) ? Core.Compiler.get_staged(mi) : Base.uncompressed_ast(mi) + ci = hasgenerator(mi) ? Core.Compiler.get_staged(mi) : Base.uncompressed_ast(mi) end Base.Meta.partially_inline!(ci.code, [], method.sig, Any[sps...], 0, 0, :propagate) Meta(method, mi, ci, method.nargs, sps)