Does defimpl not work inside the target module?

I’m trying to defimpl inside an Ecto module, using __MODULE__ as the for. When I do this, Elixir errors that it cannot find an implementation. Is defimpl not intended to be used like this? It works fine when I declare it outisde of the module using the module’s name.

I’m guessing I’m just using it wrong, but wanted to double-check.

If you defimpl inside the target module you just leave off for entirely. Perhaps there is a bug if it’s supplied?

Using __MODULE__ is supposed to work as well, but there was a bug around that in 1.14, which was resolved in one of the latest patch releases.

2 Likes

Oh nice, I thought I was current but I guess I’m behind by some patches. Dropping for feels cleaner as well vs referencing the module.

Thanks!