Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cassette method overloads not respected #44

Closed
jrevels opened this issue May 18, 2018 · 1 comment · Fixed by JuliaLang/julia#27351
Closed

cassette method overloads not respected #44

jrevels opened this issue May 18, 2018 · 1 comment · Fixed by JuliaLang/julia#27351
Labels

Comments

@jrevels
Copy link
Collaborator

jrevels commented May 18, 2018

Originally thought this was a straight up world age issue a la #6, but getting rid of the type parameter in the prehook definition "fixes" it...

@JeffBezanson
@vtjnash

julia> using Cassette

julia> Cassette.@context Ctx

julia> ctx = Ctx()
Ctx{Cassette.Unused,Cassette.Unused,Nothing}(Cassette.Unused(), Cassette.Unused(), nothing)

julia> Cassette.overdub_recurse(ctx, sin, 1)
0.8414709848078965

# Doing the following instead makes this work instead of break:
# 
#   Cassette.prehook(::Ctx, f::Any, args...) = println("1")
#
julia> Cassette.prehook(::C, f::Any, args...) where {C<:Ctx} = println("1")

julia> Cassette.overdub_recurse(ctx, sin, 1)
0.8414709848078965

julia> methods(Cassette.prehook)
# 2 methods for generic function "prehook":
[1] prehook(::C, f, args...) where C<:Ctx in Main at REPL[6]:1
[2] prehook(::Cassette.AbstractContext, ...) in Cassette at /Users/jarrettrevels/.julia/v0.7/Cassette/src/overdub.jl:5

julia> @which Cassette.prehook(ctx, sin, 1)
prehook(::C, f, args...) where C<:Ctx in Main at REPL[6]:1

# reflection gives us the right method, but it's still not getting called
julia> Cassette.prehook(ctx, sin, 1)
@jrevels
Copy link
Collaborator Author

jrevels commented May 31, 2018

Here's a non-Cassette version of a similar case that does not exhibit the same issue: https://gist.github.com/jrevels/1a41f9f1682acf324fc0e4b002bc6a77

...so a non-Cassette MWE of this lies somewhere "between" Cassette and the above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant