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.
Add regression tests for scala#21352 and ..
* `neandertech/langoustine` - [scala#21344 (comment)] (scala#21344 (comment)) * `tpolcat/doobie` - [scala#21344 (comment)] (scala#21344 (comment)) Fixes scala#21352
- Loading branch information
1 parent
58f3407
commit 5408a80
Showing
4 changed files
with
95 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//> using options -source:3.5 | ||
|
||
case class Schema[T](format: String): | ||
def asOption: Schema[Option[T]] = ??? | ||
def name(name: Option[SName]): Schema[T] = ??? | ||
def format(f: String): Schema[T] = ??? | ||
|
||
object Schema extends SchemaCompanionMacros: | ||
implicit def schemaForOption[T: Schema]: Schema[Option[T]] = | ||
implicitly[Schema[T]] | ||
??? | ||
|
||
trait SchemaCompanionMacros extends SchemaDerivation: | ||
given derivedStringBasedUnionEnumeration[S](using IsUnionOf[String, S]): Schema[S] = | ||
val x: Schema[S] = ??? | ||
x.name(None) | ||
|
||
@main def Test = | ||
case class Foo(x: Int) derives Schema |
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,26 @@ | ||
//> using options -source:3.5 | ||
|
||
import scala.deriving.* | ||
import scala.quoted.* | ||
|
||
trait SName | ||
abstract class CaseClass[Typeclass[_], Type]: | ||
def param: CaseClass.Param[Typeclass, Type] | ||
|
||
object CaseClass: | ||
trait Param[Typeclass[_], Type]: | ||
type PType | ||
def typeclass: Typeclass[PType] | ||
|
||
|
||
sealed trait IsUnionOf[T, A] | ||
object IsUnionOf: | ||
transparent inline given derived[T, A]: IsUnionOf[T, A] = ${ deriveImpl[T, A] } | ||
private def deriveImpl[T, A](using quotes: Quotes): Expr[IsUnionOf[T, A]] = ??? | ||
|
||
trait SchemaDerivation: | ||
inline implicit def derived[T](implicit m: Mirror.Of[T]): Schema[T] = | ||
val ctx: CaseClass[Schema, T] = ??? | ||
val valueSchema = ctx.param.typeclass | ||
val format = valueSchema.format | ||
??? |
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,33 @@ | ||
|
||
object serializer: | ||
trait Reader[T] | ||
trait Writer[T] | ||
// Needs to be implicit val | ||
implicit val UnitReader: Reader[Unit] = ??? | ||
implicit val StringReader: Reader[String] = ??? | ||
// A way to derive instances needs to be available | ||
inline given superTypeReader[T: scala.reflect.ClassTag]: Reader[T] = ??? | ||
import serializer.Reader | ||
|
||
trait Codec[T] | ||
trait Channel[F[_]]: | ||
def notificationStub[In: Codec](): In => F[Unit] | ||
trait Monadic[F[_]] | ||
|
||
sealed abstract class LSPNotification(): | ||
type In | ||
given inputReader: Reader[In] | ||
|
||
class PreparedNotification[X <: LSPNotification](val x: X, val in: x.In): | ||
type In = x.In | ||
|
||
trait Communicate[F[_]]: | ||
def notification[X <: LSPNotification](notif: X, in: notif.In): F[Unit] | ||
|
||
object Communicate: | ||
given codec[T: Reader]: Codec[T] = ??? | ||
|
||
def channel[F[_]: Monadic](channel: Channel[F]) = | ||
new Communicate[F]: | ||
override def notification[X <: LSPNotification](notif: X, in: notif.In): F[Unit] = | ||
channel.notificationStub().apply(in) // was error |
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,17 @@ | ||
|
||
trait Text[T] | ||
trait Read[A] | ||
object Read extends ReadImplicits: | ||
implicit val unit: Read[Unit] = ??? | ||
trait ReadImplicits: | ||
import scala.deriving.* | ||
given roe: Read[Option[EmptyTuple]] = ??? | ||
given rou: Read[Option[Unit]] = ??? | ||
given cons1[H, T <: Tuple](using Read[Option[H]], Read[Option[T]]): Read[Option[H *: T]] = ??? | ||
|
||
trait Fragment: | ||
def query[B: Read]: String = ??? | ||
|
||
@main def Test = | ||
val f: Fragment = ??? | ||
f.query // was error |