Skip to content

Commit

Permalink
Close #208 - [refined4s-core] Change NewtypeBase.unapply and RefinedB…
Browse files Browse the repository at this point in the history
…ase.unapply to return Some[A] instead of Option[A]
  • Loading branch information
kevin-lee committed Dec 31, 2023
1 parent 590dffb commit 7497d41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ trait Newtype[A] extends NewtypeBase[A] {

def apply(a: A): Type = a

def unapply(typ: Type): Option[A] = Some(typ)
/* The reason to have `Some[A]` as a return type here is
* https://github.com/scala/bug/issues/12232
* So sad :(
*/
def unapply(typ: Type): Some[A] = Some(typ)

inline given wrap: Coercible[A, Type] = Coercible.instance

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ trait RefinedBase[A] extends NewtypeBase[A] {
override def create(a: A): Either[String, Type] = from(a)
}

def unapply(typ: Type): Option[A] = Some(typ)
/* The reason to have `Some[A]` as a return type here is
* https://github.com/scala/bug/issues/12232
* So sad :(
*/
def unapply(typ: Type): Some[A] = Some(typ)

@SuppressWarnings(Array("org.wartremover.warts.ToString"))
def from(a: A): Either[String, Type] =
Expand Down

0 comments on commit 7497d41

Please sign in to comment.