Skip to content

Commit 5408a80

Browse files
Add regression tests for #21352 and ..
* `neandertech/langoustine` - [#21344 (comment)] (#21344 (comment)) * `tpolcat/doobie` - [#21344 (comment)] (#21344 (comment)) Fixes #21352
1 parent 58f3407 commit 5408a80

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

tests/pos/i21352a/schema.scala

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//> using options -source:3.5
2+
3+
case class Schema[T](format: String):
4+
def asOption: Schema[Option[T]] = ???
5+
def name(name: Option[SName]): Schema[T] = ???
6+
def format(f: String): Schema[T] = ???
7+
8+
object Schema extends SchemaCompanionMacros:
9+
implicit def schemaForOption[T: Schema]: Schema[Option[T]] =
10+
implicitly[Schema[T]]
11+
???
12+
13+
trait SchemaCompanionMacros extends SchemaDerivation:
14+
given derivedStringBasedUnionEnumeration[S](using IsUnionOf[String, S]): Schema[S] =
15+
val x: Schema[S] = ???
16+
x.name(None)
17+
18+
@main def Test =
19+
case class Foo(x: Int) derives Schema
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//> using options -source:3.5
2+
3+
import scala.deriving.*
4+
import scala.quoted.*
5+
6+
trait SName
7+
abstract class CaseClass[Typeclass[_], Type]:
8+
def param: CaseClass.Param[Typeclass, Type]
9+
10+
object CaseClass:
11+
trait Param[Typeclass[_], Type]:
12+
type PType
13+
def typeclass: Typeclass[PType]
14+
15+
16+
sealed trait IsUnionOf[T, A]
17+
object IsUnionOf:
18+
transparent inline given derived[T, A]: IsUnionOf[T, A] = ${ deriveImpl[T, A] }
19+
private def deriveImpl[T, A](using quotes: Quotes): Expr[IsUnionOf[T, A]] = ???
20+
21+
trait SchemaDerivation:
22+
inline implicit def derived[T](implicit m: Mirror.Of[T]): Schema[T] =
23+
val ctx: CaseClass[Schema, T] = ???
24+
val valueSchema = ctx.param.typeclass
25+
val format = valueSchema.format
26+
???

tests/pos/i21352b.scala

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
object serializer:
3+
trait Reader[T]
4+
trait Writer[T]
5+
// Needs to be implicit val
6+
implicit val UnitReader: Reader[Unit] = ???
7+
implicit val StringReader: Reader[String] = ???
8+
// A way to derive instances needs to be available
9+
inline given superTypeReader[T: scala.reflect.ClassTag]: Reader[T] = ???
10+
import serializer.Reader
11+
12+
trait Codec[T]
13+
trait Channel[F[_]]:
14+
def notificationStub[In: Codec](): In => F[Unit]
15+
trait Monadic[F[_]]
16+
17+
sealed abstract class LSPNotification():
18+
type In
19+
given inputReader: Reader[In]
20+
21+
class PreparedNotification[X <: LSPNotification](val x: X, val in: x.In):
22+
type In = x.In
23+
24+
trait Communicate[F[_]]:
25+
def notification[X <: LSPNotification](notif: X, in: notif.In): F[Unit]
26+
27+
object Communicate:
28+
given codec[T: Reader]: Codec[T] = ???
29+
30+
def channel[F[_]: Monadic](channel: Channel[F]) =
31+
new Communicate[F]:
32+
override def notification[X <: LSPNotification](notif: X, in: notif.In): F[Unit] =
33+
channel.notificationStub().apply(in) // was error

tests/pos/i21352c.scala

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
trait Text[T]
3+
trait Read[A]
4+
object Read extends ReadImplicits:
5+
implicit val unit: Read[Unit] = ???
6+
trait ReadImplicits:
7+
import scala.deriving.*
8+
given roe: Read[Option[EmptyTuple]] = ???
9+
given rou: Read[Option[Unit]] = ???
10+
given cons1[H, T <: Tuple](using Read[Option[H]], Read[Option[T]]): Read[Option[H *: T]] = ???
11+
12+
trait Fragment:
13+
def query[B: Read]: String = ???
14+
15+
@main def Test =
16+
val f: Fragment = ???
17+
f.query // was error

0 commit comments

Comments
 (0)