Deprecate method of extended function

deprecation
#1

Say I have the following dummy module

module MyModule

struct MyType end

Base.length(m::MyType) = 5

export length

end

What I want to do is @deprecate the length function in favor of a different function, say mylength. The following works:

module MyModule

struct MyType end

mylength(m::MyType) = 6

import Base: length
@deprecate length(m::MyType) mylength(m)

export length, mylength

end

Note the explicit import Base.length. A simple
@deprecate Base.length(m::MyType) mylength(m) doesn’t work.

Is it possible to avoid the explicit import statement somehow?

0 Likes

#2

I think this is a bug — @deprecate could be extended to handle this. Please open an issue if there isn’t an existing one.

0 Likes

#3

Turns out there is one: https://github.com/JuliaLang/julia/issues/30310

1 Like