Skip to content

Commit b077989

Browse files
committed
Use Collectable instead of Inspect to avoid accidental protocol loading
1 parent ba945e9 commit b077989

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/mix/test/mix/tasks/compile.elixir_test.exs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,24 +1861,24 @@ defmodule Mix.Tasks.Compile.ElixirTest do
18611861
defstruct []
18621862
end
18631863
1864-
defimpl Inspect, for: A do
1865-
def inspect(_, _), do: "sample"
1864+
defimpl Collectable, for: A do
1865+
def into(_), do: fn _, _ -> raise "oops" end
18661866
end
18671867
""")
18681868

18691869
Mix.Project.push(MixTest.Case.Sample)
18701870
assert Mix.Tasks.Compile.run([]) == {:ok, []}
1871-
assert inspect(struct(A, [])) == "sample"
1871+
assert is_function(Collectable.into(struct(A, [])), 2)
18721872

1873-
purge([A, B, Inspect.A])
1873+
purge([A, B, Collectable.A])
18741874
Mix.Task.clear()
18751875

18761876
assert capture_io(:stderr, fn ->
18771877
{:ok, [_]} = Mix.Tasks.Compile.run(["--force"])
18781878
end) =~
1879-
"the Inspect protocol has already been consolidated"
1879+
"the Collectable protocol has already been consolidated"
18801880

1881-
purge([A, B, Inspect.A])
1881+
purge([A, B, Collectable.A])
18821882
Mix.Task.clear()
18831883
consolidation = Mix.Project.consolidation_path()
18841884
args = ["--force", "--purge-consolidation-path-if-stale", consolidation]

0 commit comments

Comments
 (0)