From 2aa97ee9048022db06febb9a6b0ef2070410510a Mon Sep 17 00:00:00 2001 From: Michael St Clair Date: Sat, 24 Oct 2026 22:02:25 -0600 Subject: [PATCH] Fix redundant sync/4 fallback on Elixir 1.20 __using__ and @before_compile both defined catch-all sync/4, so a LiveView with only sync/3 got two; 1.20 flags the second as redundant. Keep only the @before_compile fallbacks. impl_for! in opts/1 and subscription_key/1. Bump to 0.1.13, Elixir 1.20.4 / OTP 29.1.2. Co-Authored-By: Claude Opus 5.5 --- .tool-versions | 4 ++-- lib/live_sync.ex | 11 +++-------- mix.exs | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.tool-versions b/.tool-versions index f7487cb..e223891 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -elixir 1.19.5-otp-28 -erlang 28.4.1 +elixir 1.20.4-otp-29 +erlang 29.1.2 diff --git a/lib/live_sync.ex b/lib/live_sync.ex index a389d98..dc31b54 100644 --- a/lib/live_sync.ex +++ b/lib/live_sync.ex @@ -172,12 +172,8 @@ defmodule LiveSync do quote do on_mount({LiveSync, unquote(opts)}) - def sync(key, value, socket), do: assign(socket, key, value) - def sync(key, value, _operations, socket), do: sync(key, value, socket) - + # the fallbacks go last so they catch whatever the LiveView's own clauses don't @before_compile {LiveSync, :add_sync_fallback} - - defoverridable sync: 3, sync: 4 end end @@ -205,7 +201,7 @@ defmodule LiveSync do end def opts(module) do - LiveSync.Watch.impl_for(struct(module)).opts() + LiveSync.Watch.impl_for!(struct(module)).opts() end @doc """ @@ -228,7 +224,6 @@ defmodule LiveSync do 2 """ def subscription_key(struct) do - impl = LiveSync.Watch.impl_for(struct) - impl.subscription_key(struct) + LiveSync.Watch.impl_for!(struct).subscription_key(struct) end end diff --git a/mix.exs b/mix.exs index 1af102e..901d72e 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule LiveSync.MixProject do def project do [ app: :live_sync, - version: "0.1.12", + version: "0.1.13", elixir: "~> 1.17", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod,