@@ -3714,6 +3714,18 @@ struct Thunk{FTy,tag,IsClosure,ArgTypes,ExecTy,DeviceTy,ClientTy,GD,DAM}
37143714 donated_args_mask:: DAM
37153715end
37163716
3717+ for fn in (:get_tag , :get_isclosure , :get_compiled_argtypes )
3718+ @eval $ fn (thunk:: Thunk ) = $ fn (typeof (thunk))
3719+ end
3720+
3721+ function get_compiled_argtypes (:: Type{<:Thunk{<:Any,<:Any,<:Any,ArgTypes}} ) where {ArgTypes}
3722+ return ArgTypes
3723+ end
3724+
3725+ get_tag (:: Type{<:Thunk{<:Any,tag}} ) where {tag} = tag
3726+
3727+ get_isclosure (:: Type{<:Thunk{<:Any,<:Any,IsClosure}} ) where {IsClosure} = IsClosure
3728+
37173729function Base. show (io:: IO , thunk:: Thunk{<:Any,tag} ) where {tag}
37183730 return print (io, " Reactant compiled function $(thunk. f) (with tag $(tag) )" )
37193731end
@@ -3752,24 +3764,13 @@ function Base.showerror(
37523764 )
37533765end
37543766
3755- @generated function (
3756- thunk:: Thunk{FTy,tag,IsClosure,ArgTypes,ExecTy,DeviceTy,ClientTy,GD,DAM}
3757- )(
3758- args...
3759- ) where {FTy,tag,IsClosure,ArgTypes,ExecTy,DeviceTy,ClientTy,GD,DAM}
3767+ @generated function (thunk:: Thunk )(args... )
37603768 FoundTypes = Tuple{args... }
3761- if ArgTypes != FoundTypes
3762- return quote
3763- throw (
3764- $ (MisMatchedThunkTypeError{
3765- Thunk{FTy,tag,IsClosure,ArgTypes,ExecTy,DeviceTy,ClientTy,GD,DAM},
3766- FoundTypes,
3767- }()),
3768- )
3769- end
3769+ if get_compiled_argtypes (thunk) != FoundTypes
3770+ return :(throw ($ (MisMatchedThunkTypeError {thunk,FoundTypes} ())))
37703771 end
3771- body = __thunk_fwd_body_cache[tag ]
3772- if IsClosure
3772+ body = __thunk_fwd_body_cache[get_tag (thunk) ]
3773+ if get_isclosure (thunk)
37733774 return quote
37743775 args = (thunk. f, args... )
37753776 $ body
0 commit comments