Skip to content

Commit

Permalink
Fix spelling in LowPriorityCoderDerivation
Browse files Browse the repository at this point in the history
  • Loading branch information
shnapz committed May 30, 2023
1 parent 8ba5341 commit af614e2
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ object LowPriorityCoderDerivation {
def id(v: T): Int = subTypes.collectFirst { case (isType, index) if isType(v) => index }.get
}

def colsureFunction[E, D, R](enclosed: E)(gen: E => D => R): D => R = gen(enclosed)
def closureFunction[E, D, R](enclosed: E)(gen: E => D => R): D => R = gen(enclosed)

def colsureSupplier[E, R](enclosed: E)(gen: E => R): () => R = () => gen(enclosed)
def closureSupplier[E, R](enclosed: E)(gen: E => R): () => R = () => gen(enclosed)

}

Expand All @@ -114,11 +114,11 @@ trait LowPriorityCoderDerivation {
if (ctx.isValueClass) {
val p = ctx.parameters.head
Coder.xmap(p.typeclass.asInstanceOf[Coder[Any]])(
colsureFunction(constructor)(c => v => c.rawConstruct(Seq(v))),
closureFunction(constructor)(c => v => c.rawConstruct(Seq(v))),
p.dereference
)
} else if (ctx.isObject) {
Coder.singleton(typeName, colsureSupplier(constructor)(_.rawConstruct(Seq.empty)))
Coder.singleton(typeName, closureSupplier(constructor)(_.rawConstruct(Seq.empty)))
} else {
Coder.ref(typeName) {
val cs = Array.ofDim[(String, Coder[Any])](ctx.parameters.length)
Expand All @@ -128,7 +128,7 @@ trait LowPriorityCoderDerivation {
}

Coder.record[T](typeName, cs)(
colsureFunction(constructor)(_.rawConstruct),
closureFunction(constructor)(_.rawConstruct),
v => ProductIndexedSeqLike(v.asInstanceOf[Product])
)
}
Expand All @@ -145,10 +145,10 @@ trait LowPriorityCoderDerivation {
val booleanId: Int => Boolean = _ != 0
val cs = coders.map { case (key, v) => (booleanId(key), v) }
Coder.disjunction[T, Boolean](typeName, cs)(
colsureFunction(identifier)(_.id).andThen(booleanId)
closureFunction(identifier)(_.id).andThen(booleanId)
)
} else {
Coder.disjunction[T, Int](typeName, coders)(colsureFunction(identifier)(_.id))
Coder.disjunction[T, Int](typeName, coders)(closureFunction(identifier)(_.id))
}
}

Expand Down

0 comments on commit af614e2

Please sign in to comment.