Skip to content

Commit 072d78a

Browse files
committed
[base] Factor out remaining differences between UnapplyExprs
1 parent 5c65913 commit 072d78a

File tree

8 files changed

+162
-257
lines changed

8 files changed

+162
-257
lines changed

Base/src/main/scala-2/VersionSpecificUnapplyExpr.scala

-36
This file was deleted.

Base/src/main/scala-3/VersionSpecificUnapplyExpr.scala

-32
This file was deleted.

Base/src/main/scala-3/typeclass/ExprsImpl.scala

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package name.rayrobdod.stringContextParserCombinator
22
package typeclass
33

4+
import scala.annotation.nowarn
45
import scala.quoted.*
56

67
// scala 2 reads the `'{Some($value}` as an unclosed character literal
78
// and ifdef is insufficient to hide that construct from the scala 2 compiler
89

910
private[typeclass]
10-
final class ExprsForQuotes extends Exprs[scala.quoted.Quotes, scala.quoted.Expr] {
11+
final class ExprsForQuotes extends Exprs[scala.quoted.Quotes, scala.quoted.Expr, TypeCreator] {
1112
override def constBoolean(b: Boolean)(implicit ctx: Quotes): Expr[Boolean] = {
1213
implicit val quotes = ctx
1314
Expr(b)
@@ -23,4 +24,9 @@ final class ExprsForQuotes extends Exprs[scala.quoted.Quotes, scala.quoted.Expr]
2324
case _ => '{$left && $right}
2425
}
2526
}
27+
28+
override def isEqualTo[A](left: Expr[A], right: Expr[A])(implicit ctx: Quotes, typA: TypeCreator[A]): Expr[Boolean] = {
29+
@nowarn("msg=unused local definition") implicit val typ: Type[A] = summon[TypeCreator[A]].createType
30+
'{$left == $right}
31+
}
2632
}

Base/src/main/scala/PartialExprFunction.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ object PartialExprFunction {
2222
}
2323

2424
private[stringContextParserCombinator]
25-
def identity[Ctx, Expr[+_], A](
26-
implicit backing: Exprs[Ctx, Expr]
25+
def identity[Ctx, Expr[+_], Type[_], A](
26+
implicit backing: Exprs[Ctx, Expr, Type]
2727
):PartialExprFunction[Ctx, Expr, A, A] = {
2828
new PartialExprFunction[Ctx, Expr, A, A] {
2929
override def isDefinedAt(a:A)(implicit ctx: Ctx):Expr[Boolean] = backing.constTrue

0 commit comments

Comments
 (0)