Skip to content

Commit

Permalink
Fix up spark
Browse files Browse the repository at this point in the history
  • Loading branch information
deusaquilus committed Nov 5, 2023
1 parent e5dfeb6 commit d987e27
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions quill-core/src/main/scala/io/getquill/quat/QuatMaking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,24 @@ trait QuatMaking extends QuatMakingBase with MacroUtilBase {
cachedEncoderLookups.get(tpe) match {
case Some(value) =>
value

// c.inferImplicitValue(expanderTpe.tpe, silent = true) match {
// case EmptyTree => c.fail(s"Can't find an implicit `${prefix}Meta` for type `${t.tpe}`")
// case tree => tree
// }

case None =>
val lookup =
if (OptionalTypecheck(c)(q"implicitly[io.getquill.quat.QuatMaking.IgnoreDecoders]").isDefined) {
false
} else if (OptionalTypecheck(c)(q"implicitly[${c.prefix}.Encoder[$tpe]]").isDefined) {
if (OptionalTypecheck(c)(q"implicitly[${c.prefix}.Encoder[$tpe]]").isDefined) {
true
} else if (OptionalTypecheck(c)(q"implicitly[${c.prefix}.Decoder[$tpe]]").isDefined) {
val inferred = c.inferImplicitValue(typeOf[io.getquill.quat.QuatMaking.IgnoreDecoders], silent = true)
inferred match {
case EmptyTree => true
case tree => false
}
} else {
OptionalTypecheck(c)(q"implicitly[${c.prefix}.Decoder[$tpe]]").isDefined
false
}
cachedEncoderLookups.put(tpe, lookup)
lookup
Expand Down Expand Up @@ -249,7 +259,7 @@ trait QuatMakingBase extends MacroUtilUniverse {

object DefiniteValue {
def unapply(tpe: Type): Option[Type] =
// UDTs (currently only used by cassandra) are created as tables even though there is an encoder for them.
// UDTs (currently only used by cassandra) are created as tables even though there is an encoder for them.
if (tpe <:< typeOf[Udt])
None
else if (isType[AnyVal](tpe))
Expand Down Expand Up @@ -284,7 +294,7 @@ trait QuatMakingBase extends MacroUtilUniverse {
// run(is80Proof(query[Gin]))
// When processing is80Prof, we assume that Spirit is actually a base class to be extended
case Param(Signature(RealTypeBounds(lower, Deoption(upper))))
if (!upper.typeSymbol.isFinal && !existsEncoderFor(tpe)) =>
if (!upper.typeSymbol.isFinal && !existsEncoderFor(tpe)) =>
parseType(upper, true) match {
case p: Quat.Product => p.copy(tpe = Quat.Product.Type.Abstract)
case other => other
Expand Down Expand Up @@ -353,6 +363,7 @@ trait QuatMakingBase extends MacroUtilUniverse {

// Otherwise it's a terminal value
case _ =>
println(Messages.qprint(s"Could not infer SQL-type of ${tpe}, assuming it is a Unknown Quat."))
Messages.trace(s"Could not infer SQL-type of ${tpe}, assuming it is a Unknown Quat.")
Quat.Unknown
}
Expand All @@ -363,7 +374,7 @@ trait QuatMakingBase extends MacroUtilUniverse {
@tailrec
private[getquill] final def innerOptionParam(tpe: Type, maxDepth: Option[Int]): Type = tpe match {
case TypeRef(_, cls, List(arg))
if (cls.isClass && cls.asClass.fullName == "scala.Option") && maxDepth.forall(_ > 0) =>
if (cls.isClass && cls.asClass.fullName == "scala.Option") && maxDepth.forall(_ > 0) =>
innerOptionParam(arg, maxDepth.map(_ - 1))
// If it's not a ref-type but an Option, convert to a ref-type and reprocess
// also since Nothing is a subtype of everything need to know to stop searching once Nothing
Expand Down

0 comments on commit d987e27

Please sign in to comment.