Protocol Reconsolidation in Elixir 1.2 or later

I have a macro that creates a module, a structure for a module and implements a protocol for this structure.

In my package, I have a simple test module that calls a macro and then makes statements in the generated module / structure / protocol implementation. One test calls a protocol function using a structure to assert that it has been implemented. Before 1.2, this worked, but now it fails, and I get the following warning when I run the package.

test/dogma/rule_builder_test.exs:7: warning: the Dogma.Rule \ protocol has already been consolidated, an implementation for \ Dogma.RuleBuilderTest.MagicTestRule has no effect 

I removed this test for now, as I believe that the rest of my package checks this functionality enough, but I'm curious if there is a way to do this work again or at least silence the warning.

I played with Process.consilodate/2 but was unsuccessful.

+7
elixir metaprogramming
source share
1 answer

Starting with Elixir 1.2, Mix combines the default protocols, which may cause the problem described here:

https://github.com/elixir-lang/elixir/blob/v1.2/CHANGELOG.md#workflow-improvements

It seems to me that you have a different taste of this problem, but the fix is ​​most likely the same. Set the consolidation protocol for the consolidation protocol to false: false (only when running in a test environment).

+10
source share

All Articles