Skip to content

Commit 1200296

Browse files
committed
[base] Inline one-line UnapplyExprs companion object methods, removing need for UnapplyExprs companion object
1 parent 072d78a commit 1200296

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

Base/src/main/scala/Extractor.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ final class Extractor[Ctx, Expr[+_], Type[_], -A] private[stringContextParserCom
5757
val argWithPoss = strings.init.map(x => (((), x._2 + x._1.size)))
5858

5959
val input = new Input[Unit, Int](strings, argWithPoss)
60-
implicit val exprs:UnapplyExprs[IdCtx, Id, ClassTag] = UnapplyExprs.forId
60+
implicit val exprs:UnapplyExprs[IdCtx, Id, ClassTag] = new UnapplyExprs
6161

6262
impl.asInstanceOf[internal.Extractor[IdCtx, Id, ClassTag, A]].extractor(input)(implicitly, implicitly, exprs) match {
6363
case s:Success[_, _, _] => {
@@ -127,7 +127,7 @@ final class Extractor[Ctx, Expr[+_], Type[_], -A] private[stringContextParserCom
127127
val args = strings.init.map(x => (((), x._2 + x._1.size)))
128128

129129
val input = new Input[Unit, c.universe.Position](strings, args)
130-
implicit val exprs:UnapplyExprs[c.type, c.Expr, c.TypeTag] = UnapplyExprs.forContext(c)
130+
implicit val exprs:UnapplyExprs[c.type, c.Expr, c.TypeTag] = new UnapplyExprs()(using typeclass.Exprs.forContext[c.type])
131131

132132
impl.asInstanceOf[internal.Extractor[c.type, c.Expr, c.TypeTag, A]].extractor(input)(c, implicitly, exprs) match {
133133
case s:Success[_, _, _] => {
@@ -185,7 +185,7 @@ final class Extractor[Ctx, Expr[+_], Type[_], -A] private[stringContextParserCom
185185
val args2 = strings2.init.map(x => (((), x._2 + x._1.size)))
186186

187187
val input = new Input[Unit, quotes.reflect.Position](strings2, args2)
188-
implicit val exprs:UnapplyExprs[quoted.Quotes, quoted.Expr, TypeCreator] = UnapplyExprs.forQuoted
188+
implicit val exprs:UnapplyExprs[quoted.Quotes, quoted.Expr, TypeCreator] = new UnapplyExprs
189189

190190
impl.asInstanceOf[internal.Extractor[quoted.Quotes, quoted.Expr, TypeCreator, A]].extractor(input) match {
191191
case s:Success[_, _, _] => {

Base/src/main/scala/UnapplyExpr.scala

-18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package name.rayrobdod.stringContextParserCombinator
22

3-
import com.eed3si9n.ifdef.ifdef
4-
import scala.reflect.ClassTag
5-
63
/**
74
* The data needed to create an Unapply
85
*/
@@ -173,18 +170,3 @@ final class UnapplyExprs[Ctx, Expr[+_], Type[_]](implicit exprs: typeclass.Exprs
173170
UnapplyExpr[Ctx, Expr, Type, Z]({(value, ctx) => ev.contraNone(value)(ctx)}, Nil)
174171
}
175172
}
176-
177-
private[stringContextParserCombinator]
178-
object UnapplyExprs {
179-
def forId: UnapplyExprs[IdCtx, Id, ClassTag] = new UnapplyExprs[IdCtx, Id, ClassTag]
180-
181-
@ifdef("scalaEpochVersion:2")
182-
def forContext(c: scala.reflect.macros.blackbox.Context): UnapplyExprs[c.type, c.Expr, c.TypeTag] = {
183-
new UnapplyExprs[c.type, c.Expr, c.TypeTag]()(using typeclass.Exprs.forContext[c.type])
184-
}
185-
186-
@ifdef("scalaBinaryVersion:3")
187-
def forQuoted: UnapplyExprs[quoted.Quotes, quoted.Expr, TypeCreator] = {
188-
new UnapplyExprs[quoted.Quotes, quoted.Expr, TypeCreator]()
189-
}
190-
}

0 commit comments

Comments
 (0)