You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// file a.scalainlinedefsummonAllOptimized[T<:Tuple]:T=${ summonAllOptimizedImpl[T] }
privatedefsummonAllOptimizedImpl[T<:Tuple:Type](usingq: Quotes):Expr[T] = {
importq.reflect.*Expr
.ofTupleFromSeq(typesOfTuple(TypeRepr.of[T], Nil).map { tpe =>
tpe.asType match {
case'[t] =>Expr.summon[t].getOrElse(report.errorAndAbort(s"Unable to to find implicit instance for ${tpe.show}"))
}
})
.asExprOf[T]
}
@tailrec
private[derivation] deftypesOfTuple(
using q: Quotes
)(tpe: q.reflect.TypeRepr, acc: List[q.reflect.TypeRepr]):List[q.reflect.TypeRepr] =importq.reflect.*valcons=Symbol.classSymbol("scala.*:")
tpe.widenTermRefByName.dealias matchcaseAppliedType(fn, tpes) if defn.isTupleClass(fn.typeSymbol) =>
tpes.reverse_:::(acc)
caseAppliedType(tp, List(headType, tailType)) if tp.derivesFrom(cons) =>
typesOfTuple(tailType, headType :: acc)
case tpe =>if tpe.derivesFrom(Symbol.classSymbol("scala.EmptyTuple")) then acc.reverse
else report.errorAndAbort(s"Unknown type encountered in tuple ${tpe.show}")
//file b.scalavaltest=Helpers.summonAllOptimized[(
ValueOf["a"], ValueOf["a"], ValueOf["a"], ValueOf["a"], ValueOf["a"],
ValueOf["a"], ValueOf["a"], ValueOf["a"], ValueOf["a"], ValueOf["a"],
ValueOf["a"], ValueOf["a"], ValueOf["a"], ValueOf["a"], ValueOf["a"],
ValueOf["a"], ValueOf["a"], ValueOf["a"], ValueOf["a"], ValueOf["a"],
ValueOf["a"], ValueOf["a"], ValueOf["a"] //Commenting out the last one here fixes the compile error
)]
Output
[error] |Exception occurred while executing macro expansion.
[error] |java.lang.Exception:Expr cast exception: scala.Tuple.fromIArray[scala.Any](scala.IArray$package.IArray.apply[scala.Any](new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"), new scala.ValueOf["a"]("a"))(scala.reflect.ClassTag.Any))
[error] |of type: scala.Tuple
[error] |did not conform to type: scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.*:[scala.ValueOf["a"], scala.Tuple$package.EmptyTuple]]]]]]]]]]]]]]]]]]]]]]]
[error] |
[error] | at scala.quoted.runtime.impl.QuotesImpl.asExprOf(QuotesImpl.scala:73)
[error] | at perspective.derivation.Helpers$.summonAllOptimizedImpl(Helpers.scala:157)
[error] | at perspective.derivation.Helpers$.inline$summonAllOptimizedImpl(Helpers.scala:147)
Expectatio
I would expect the above to work just like it works for tuples of size 22 or less, or that this was at least better communicated.
The text was updated successfully, but these errors were encountered:
I think this could be resolved in the implementation pf Expr.ofTupleFromSeq by constructing a tuple type from extracting the elements of the seq and casting the result.
I think this could be resolved in the implementation pf Expr.ofTupleFromSeq by constructing a tuple type from extracting the elements of the seq and casting the result.
Compiler version
3.2.2
Minimized code
Output
Expectatio
I would expect the above to work just like it works for tuples of size 22 or less, or that this was at least better communicated.
The text was updated successfully, but these errors were encountered: