forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix algorithm to prevent recursive givens
Fixes scala#19404 Fixes scala#19407
- Loading branch information
Showing
3 changed files
with
65 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
given ipEncoder[IP <: IpAddress]: Encoder[IP] = Encoder[String].contramap(_.toString) | ||
|
||
class Encoder[A] { | ||
final def contramap[B](f: B => A): Encoder[B] = new Encoder[B] | ||
} | ||
|
||
object Encoder { | ||
final def apply[A](implicit instance: Encoder[A]): Encoder[A] = instance | ||
implicit final val encodeString: Encoder[String] = new Encoder[String] | ||
} | ||
|
||
trait Json | ||
trait IpAddress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
trait GeneratedEnum | ||
trait Decoder[A] | ||
|
||
object Decoder: | ||
given Decoder[Int] = ??? | ||
|
||
object GeneratedEnumDecoder: | ||
|
||
given [A <: GeneratedEnum]: Decoder[A] = | ||
summon[Decoder[Int]] | ||
??? |