Need help with resolving method ambiguities

In your original code, I get the following error:

julia> p = Proxy(42)
Error showing value of type Proxy{Int64}:
ERROR: MethodError: convert(::Type{Any}, ::Proxy{Int64}) is ambiguous. Candidates:
  convert(::Type{Any}, x) in Base at essentials.jl:170
  convert(targettype::Type{var"#s2"} where var"#s2"<:T, p::Proxy{TInner}) where {T, TInner} in Main at REPL[4]:1
Possible fix, define
  convert(::Type{Any}, ::Proxy{TInner}) where TInner

The last line suggests an ambiguity fix:

function Base.convert(::Type{Any}, ::Proxy{TInner}) where TInner
    convert(Any, inner(p))
end

That gets rid of the ambiguities, but then you have more methods to implement to get your tests passing.

1 Like