Skip to content

Commit 54b6b00

Browse files
committed
[base] Flatten out Eithered.forContext
1 parent 93d2f7a commit 54b6b00

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

Base/src/main/scala/typeclass/Eithered.scala

+2-13
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,8 @@ object Eithered extends LowPrioEithered {
102102
* @version 0.1.1
103103
*/
104104
@ifdef("scalaEpochVersion:2")
105-
trait Eithereds[Ctx, Expr[+_]] {
106-
def splicePiece[A]: Eithered[Ctx, Expr[A], Expr[Iterable[A]], Repeated.SplicePiece[Expr, A]]
107-
}
108-
/**
109-
* @version 0.1.1
110-
*/
111-
@ifdef("scalaEpochVersion:2")
112-
def forContext(c:scala.reflect.macros.blackbox.Context):Eithereds[c.type, c.Expr] = {
113-
new Eithereds[c.type, c.Expr] {
114-
def splicePiece[A]: Eithered[c.type, c.Expr[A], c.Expr[Iterable[A]], Repeated.SplicePiece[c.Expr, A]] =
115-
Eithered((value, _) => new Repeated.SplicePiece.One(value), (value, _) => new Repeated.SplicePiece.Many(value))
116-
}
117-
}
105+
def contextSplicePiece[Ctx <: scala.reflect.macros.blackbox.Context with Singleton, A]: Eithered[Ctx, Ctx#Expr[A], Ctx#Expr[Iterable[A]], Repeated.SplicePiece[Ctx#Expr, A]] =
106+
Eithered((value, _) => new Repeated.SplicePiece.One(value), (value, _) => new Repeated.SplicePiece.Many(value))
118107

119108
/**
120109
* @version 0.1.1

JsonParser/src/main/scala-2/MacroImpl.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ final class MacroImpl(val c:Context {type PrefixType = JsonStringContext}) {
166166
}
167167

168168
val splicableValues: Interpolator[typeclass.Repeated.SplicePiece[c.Expr, JValue]] = {
169-
implicit val eitherSplicePiece: typeclass.Eithered[c.type, c.Expr[JValue], c.Expr[List[JValue]], typeclass.Repeated.SplicePiece[c.Expr,JValue]] = typeclass.Eithered.forContext(c).splicePiece
169+
implicit val eitherSplicePiece: typeclass.Eithered[c.type, c.Expr[JValue], c.Expr[List[JValue]], typeclass.Repeated.SplicePiece[c.Expr,JValue]] = typeclass.Eithered.contextSplicePiece
170170

171171
val value = jvalue.toInterpolator
172172
val array = (isString("..").toInterpolator ~> liftedArray)
@@ -217,7 +217,7 @@ final class MacroImpl(val c:Context {type PrefixType = JsonStringContext}) {
217217
}
218218

219219
val splicableValues:Interpolator[typeclass.Repeated.SplicePiece[c.Expr,(String, JValue)]] = {
220-
implicit val eitherSplicePiece: typeclass.Eithered[c.type, c.Expr[(String, JValue)], c.Expr[List[(String, JValue)]], typeclass.Repeated.SplicePiece[c.Expr,(String, JValue)]] = typeclass.Eithered.forContext(c).splicePiece
220+
implicit val eitherSplicePiece: typeclass.Eithered[c.type, c.Expr[(String, JValue)], c.Expr[List[(String, JValue)]], typeclass.Repeated.SplicePiece[c.Expr,(String, JValue)]] = typeclass.Eithered.contextSplicePiece
221221

222222
val keyValue = (liftedKeyValue <~ whitespace.toInterpolator)
223223
val keyThenValue = (key <~ separator.toInterpolator <~> jvalue.toInterpolator)

0 commit comments

Comments
 (0)