@@ -34,7 +34,7 @@ struct CassetteOverlayGenerator <: (@static isdefined(Core, :CachedGenerator) ?
3434 selfname:: Symbol
3535 fargsname:: Symbol
3636end
37- function (generator:: CassetteOverlayGenerator )(world:: UInt , source:: LineNumberNode , passtype, fargtypes)
37+ function (generator:: CassetteOverlayGenerator )(world:: UInt , source:: SourceType , passtype, fargtypes)
3838 @nospecialize passtype fargtypes
3939 (; selfname, fargsname) = generator
4040 try
@@ -48,7 +48,7 @@ function (generator::CassetteOverlayGenerator)(world::UInt, source::LineNumberNo
4848 end
4949end
5050
51- function generate_overlay_src (world:: UInt , #= source=# :: LineNumberNode , passtype, fargtypes,
51+ function generate_overlay_src (world:: UInt , #= source=# :: SourceType , passtype, fargtypes,
5252 selfname:: Symbol , fargsname:: Symbol )
5353 @nospecialize passtype fargtypes
5454 tt = Base. to_tuple_type (fargtypes)
@@ -135,23 +135,29 @@ macro overlaypass(args...)
135135
136136 push! (topblk. args, :(return $ retval))
137137
138- return topblk
138+ # attach :latestworld if necessary (N.B. adding it the :toplevel block doesn't work)
139+ @static if VERSION ≥ v " 1.12.0-DEV.1662"
140+ return Expr (:block , Expr (:(= ), :pass , topblk), Expr (:latestworld ), :pass )
141+ else
142+ return topblk
143+ end
139144end
140145
141146abstract type AbstractBindingOverlay{M, S} <: OverlayPass ; end
142147function methodtable (:: Type{<:AbstractBindingOverlay{M, S}} ) where {M, S}
143148 if M === nothing
144149 return nothing
145150 end
146- @assert isconst (M, S)
147- return getglobal (M, S):: MethodTable
151+ @assert @invokelatest isconst (M, S)
152+ mt = @invokelatest getglobal (M, S)
153+ return mt:: MethodTable
148154end
149155@overlaypass AbstractBindingOverlay nothing
150156
151157struct Overlay{M, S} <: AbstractBindingOverlay{M, S} ; end
152158function Overlay (mt:: MethodTable )
153- @assert isconst (mt. module, mt. name)
154- @assert getglobal (mt. module, mt. name) === mt
159+ @assert @invokelatest isconst (mt. module, mt. name)
160+ @assert mt === @invokelatest getglobal (mt. module, mt. name)
155161 return Overlay {mt.module, mt.name} ()
156162end
157163
0 commit comments