From a2dcf5f4d692d76d36b5bce4f277d06f605a1a7a Mon Sep 17 00:00:00 2001 From: Niklas Klein Date: Wed, 20 Nov 2024 16:14:42 +0100 Subject: [PATCH] Fix warnings --- .../enumeration/ext/EnumerationValues.scala | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/modules/core/src/main/scala/io/taig/enumeration/ext/EnumerationValues.scala b/modules/core/src/main/scala/io/taig/enumeration/ext/EnumerationValues.scala index 6924f90..30331e3 100644 --- a/modules/core/src/main/scala/io/taig/enumeration/ext/EnumerationValues.scala +++ b/modules/core/src/main/scala/io/taig/enumeration/ext/EnumerationValues.scala @@ -14,37 +14,36 @@ abstract class EnumerationValues[A]: object EnumerationValues: type Aux[A, B] = EnumerationValues[A] { type Out = B } + inline def apply[A](using values: EnumerationValues[A]): EnumerationValues.Aux[A, values.Out] = values + + inline def apply[A, B](using values: EnumerationValues.Aux[A, B]): EnumerationValues.Aux[A, B] = values + + def apply[A, B](values: NonEmptyList[B]): EnumerationValues.Aux[A, B] = new EnumerationValues[A]: + override type Out = B + + override def toNonEmptyList: NonEmptyList[Out] = values + inline given [A](using mirror: Mirror.SumOf[A], values: EnumerationValues.Aux[mirror.MirroredElemTypes, A] - ): EnumerationValues.Aux[A, A] = new EnumerationValues[A]: - override type Out = A - override val toNonEmptyList: NonEmptyList[A] = values.toNonEmptyList + ): EnumerationValues.Aux[A, A] = EnumerationValues(values = values.toNonEmptyList) inline given singleton[A <: Singleton, B <: Tuple, C >: A](using values: EnumerationValues.Aux[B, C] - ): EnumerationValues.Aux[A *: B, C] = new EnumerationValues[A *: B]: - override type Out = C - override def toNonEmptyList: NonEmptyList[C] = valueOf[A] :: values.toNonEmptyList + ): EnumerationValues.Aux[A *: B, C] = EnumerationValues(values = valueOf[A] :: values.toNonEmptyList) inline given nested[A, B <: Tuple, C >: A](using mirror: Mirror.SumOf[A], head: EnumerationValues.Aux[mirror.MirroredElemTypes, C], tail: EnumerationValues.Aux[B, C] - ): EnumerationValues.Aux[A *: B, C] = new EnumerationValues[A *: B]: - override type Out = C - override def toNonEmptyList: NonEmptyList[C] = head.toNonEmptyList.concatNel(tail.toNonEmptyList) + ): EnumerationValues.Aux[A *: B, C] = EnumerationValues(values = head.toNonEmptyList.concatNel(tail.toNonEmptyList)) inline given nestedOne[A, B >: A](using mirror: Mirror.SumOf[A], head: EnumerationValues.Aux[mirror.MirroredElemTypes, B] - ): EnumerationValues.Aux[A *: EmptyTuple, B] = new EnumerationValues[A *: EmptyTuple]: - override type Out = B - override def toNonEmptyList: NonEmptyList[B] = head.toNonEmptyList + ): EnumerationValues.Aux[A *: EmptyTuple, B] = EnumerationValues(values = head.toNonEmptyList) inline given last[A <: Singleton, B >: A]: EnumerationValues.Aux[A *: EmptyTuple, B] = - new EnumerationValues[A *: EmptyTuple]: - override type Out = B - override def toNonEmptyList: NonEmptyList[B] = NonEmptyList.one(valueOf[A]) + EnumerationValues(values = NonEmptyList.one(valueOf[A])) def valuesOf[A](using values: EnumerationValues.Aux[A, A]): NonEmptyList[A] = values.toNonEmptyList