Skip to content

Commit

Permalink
Restrict DeltaSurgeon.ofCaseObject to V <: Singlegon & Product
Browse files Browse the repository at this point in the history
  • Loading branch information
ckuessner committed Jul 23, 2024
1 parent 41f112a commit 2dec9df
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ object DeltaSurgeon {

inline def derived[T](using m: Mirror.Of[T], bottom: Bottom[T]): DeltaSurgeon[T] =
val elementLabels = getLabels[m.MirroredElemLabels].toArray
// TODO: Don't summon case object delta surgeons but provide them here
val elementSurgeons =
summonAll[Tuple.Map[m.MirroredElemTypes, DeltaSurgeon]].toIArray.map(_.asInstanceOf[DeltaSurgeon[Any]])
inline m match
Expand Down Expand Up @@ -133,9 +134,7 @@ object DeltaSurgeon {
// Used for values that should not be further isolated
def ofTerminalValue[V: Bottom: JsonValueCodec]: DeltaSurgeon[V] = new TerminalValueDeltaSurgeon[V]

// TODO: could be used inside of sum type derivation to avoid the need to specify instances externally
// TODO: Restrict type to case objects
def ofCaseObject[V](obj: V): DeltaSurgeon[V] = {
def ofCaseObject[V <: Singleton & Product](obj: V): DeltaSurgeon[V] = {
new DeltaSurgeon[V]:
override def isolate(delta: V): IsolatedDeltaParts = IsolatedDeltaParts(Array.empty)
override def recombine(parts: IsolatedDeltaParts): V = parts.inner match
Expand Down

0 comments on commit 2dec9df

Please sign in to comment.