diff --git a/community-build/community-projects/sourcecode b/community-build/community-projects/sourcecode index 1e02adad684a..d1c22e19ed79 160000 --- a/community-build/community-projects/sourcecode +++ b/community-build/community-projects/sourcecode @@ -1 +1 @@ -Subproject commit 1e02adad684ae8ae1b6e3251f93759911311dfd5 +Subproject commit d1c22e19ed79f0a4f57cca8ae7f15193fc579aa6 diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 2d4b2b9ce1f3..562bf25fbf99 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -740,9 +740,6 @@ class Definitions { lazy val InternalQuotedMatcher_unapplyR: TermRef = InternalQuotedMatcherModule.requiredMethodRef(nme.unapply) def InternalQuotedMatcher_unapply(implicit ctx: Context) = InternalQuotedMatcher_unapplyR.symbol - lazy val QuotedExprsModule: TermSymbol = ctx.requiredModule("scala.quoted.Exprs") - def QuotedExprsClass(implicit ctx: Context): ClassSymbol = QuotedExprsModule.asClass - lazy val QuotedTypeType: TypeRef = ctx.requiredClassRef("scala.quoted.Type") def QuotedTypeClass(implicit ctx: Context): ClassSymbol = QuotedTypeType.symbol.asClass diff --git a/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala b/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala index 19e8f23e6ae0..6610ff90b2e5 100644 --- a/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala +++ b/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala @@ -15,8 +15,7 @@ import dotty.tools.dotc.core.tasty.TreePickler.Hole import dotty.tools.dotc.core.tasty.{PositionPickler, TastyPickler, TastyPrinter, TastyString} import dotty.tools.dotc.core.tasty.TreeUnpickler.UnpickleMode -import scala.quoted.Types._ -import scala.quoted.Exprs._ +import scala.internal.quoted._ import scala.reflect.ClassTag object PickledQuotes { diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 1a0b052682d2..c185d329c0ad 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -33,8 +33,7 @@ import config.Printers.pickling import core.quoted.PickledQuotes import scala.quoted -import scala.quoted.Types.TreeType -import scala.quoted.Exprs.TastyTreeExpr +import scala.internal.quoted.{TastyTreeExpr, TreeType} import scala.annotation.constructorOnly import scala.annotation.internal.sharable diff --git a/compiler/src/dotty/tools/dotc/quoted/ToolboxImpl.scala b/compiler/src/dotty/tools/dotc/quoted/ToolboxImpl.scala index 77a1e26b8db1..2e11424b4b38 100644 --- a/compiler/src/dotty/tools/dotc/quoted/ToolboxImpl.scala +++ b/compiler/src/dotty/tools/dotc/quoted/ToolboxImpl.scala @@ -3,7 +3,7 @@ package dotty.tools.dotc.quoted import dotty.tools.dotc.ast.tpd import scala.quoted._ -import scala.quoted.Exprs.{LiftedExpr, TastyTreeExpr} +import scala.internal.quoted.{LiftedExpr, TastyTreeExpr} /** Default runners for quoted expressions */ object ToolboxImpl { diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala b/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala index e02ce96705dc..2b2e38cc24c0 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala @@ -1747,7 +1747,7 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. tpd.Closure(closureMethod, tss => etaExpand(new tpd.TreeOps(term).appliedToArgs(tss.head))) case _ => term } - new scala.quoted.Exprs.TastyTreeExpr(etaExpand(self)) + new scala.internal.quoted.TastyTreeExpr(etaExpand(self)) } /** Checked cast to a `quoted.Expr[U]` */ @@ -1768,7 +1768,7 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. /** Convert `Type` to an `quoted.Type[_]` */ def QuotedType_seal(self: Type)(implicit ctx: Context): scala.quoted.Type[_] = { val dummySpan = ctx.owner.span // FIXME - new scala.quoted.Types.TreeType(tpd.TypeTree(self).withSpan(dummySpan)) + new scala.internal.quoted.TreeType(tpd.TypeTree(self).withSpan(dummySpan)) } // diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index 60f89f5d1815..c3b17958c433 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -102,10 +102,10 @@ object Splicer { } protected def interpretQuote(tree: Tree)(implicit env: Env): Object = - new scala.quoted.Exprs.TastyTreeExpr(Inlined(EmptyTree, Nil, tree).withSpan(tree.span)) + new scala.internal.quoted.TastyTreeExpr(Inlined(EmptyTree, Nil, tree).withSpan(tree.span)) protected def interpretTypeQuote(tree: Tree)(implicit env: Env): Object = - new scala.quoted.Types.TreeType(tree) + new scala.internal.quoted.TreeType(tree) protected def interpretLiteral(value: Any)(implicit env: Env): Object = value.asInstanceOf[Object] diff --git a/library/src-2.x/scala/quoted/Expr.scala b/library/src-2.x/scala/quoted/Expr.scala index d0efc9cfee3f..de6ed075280e 100644 --- a/library/src-2.x/scala/quoted/Expr.scala +++ b/library/src-2.x/scala/quoted/Expr.scala @@ -1,49 +1,54 @@ -package scala.quoted +package scala -import scala.runtime.quoted.Unpickler.Pickled +package quoted { -sealed abstract class Expr[+T] { + sealed abstract class Expr[+T] { - /** Evaluate the contents of this expression and return the result. - * - * May throw a FreeVariableError on expressions that came from a macro. - */ - final def run(implicit toolbox: Toolbox): T = toolbox.run(this) + /** Evaluate the contents of this expression and return the result. + * + * May throw a FreeVariableError on expressions that came from a macro. + */ + final def run(implicit toolbox: Toolbox): T = toolbox.run(this) -} - -/** All implementations of Expr[T]. - * These should never be used directly. - */ -object Exprs { - /** An Expr backed by a pickled TASTY tree */ - final class TastyExpr[+T](val tasty: Pickled, val args: Seq[Any]) extends Expr[T] { - override def toString: String = s"Expr()" } - /** An Expr backed by a lifted value. - * Values can only be of type Boolean, Byte, Short, Char, Int, Long, Float, Double, Unit, String or Null. - */ - final class LiftedExpr[+T](val value: T) extends Expr[T] { - override def toString: String = s"Expr($value)" - } +} - /** An Expr backed by a tree. Only the current compiler trees are allowed. - * - * These expressions are used for arguments of macros. They contain and actual tree - * from the program that is being expanded by the macro. - * - * May contain references to code defined outside this TastyTreeExpr instance. - */ - final class TastyTreeExpr[Tree](val tree: Tree) extends quoted.Expr[Any] { - override def toString: String = s"Expr()" - } +package internal { + package quoted { + + import scala.quoted._ + + /** An Expr backed by a pickled TASTY tree */ + final class TastyExpr[+T](val tasty: scala.runtime.quoted.Unpickler.Pickled, val args: Seq[Any]) extends Expr[T] { + override def toString: String = s"Expr()" + } + + /** An Expr backed by a lifted value. + * Values can only be of type Boolean, Byte, Short, Char, Int, Long, Float, Double, Unit, String or Null. + */ + final class LiftedExpr[+T](val value: T) extends Expr[T] { + override def toString: String = s"Expr($value)" + } + + /** An Expr backed by a tree. Only the current compiler trees are allowed. + * + * These expressions are used for arguments of macros. They contain and actual tree + * from the program that is being expanded by the macro. + * + * May contain references to code defined outside this TastyTreeExpr instance. + */ + final class TastyTreeExpr[Tree](val tree: Tree) extends quoted.Expr[Any] { + override def toString: String = s"Expr()" + } + + // TODO Use a List in FunctionAppliedTo(val f: Expr[_], val args: List[Expr[_]]) + // FIXME: Having the List in the code above trigers an assertion error while testing dotty.tools.dotc.reporting.ErrorMessagesTests.i3187 + // This test does redefine `scala.collection`. Further investigation is needed. + /** An Expr representing `'{($f).apply($x1, ..., $xn)}` but it is beta-reduced when the closure is known */ + final class FunctionAppliedTo[+R](val f: Expr[_], val args: Array[Expr[_]]) extends Expr[R] { + override def toString: String = s"Expr($f ${args.toList})" + } - // TODO Use a List in FunctionAppliedTo(val f: Expr[_], val args: List[Expr[_]]) - // FIXME: Having the List in the code above trigers an assertion error while testing dotty.tools.dotc.reporting.ErrorMessagesTests.i3187 - // This test does redefine `scala.collection`. Further investigation is needed. - /** An Expr representing `'{($f).apply($x1, ..., $xn)}` but it is beta-reduced when the closure is known */ - final class FunctionAppliedTo[+R](val f: Expr[_], val args: Array[Expr[_]]) extends Expr[R] { - override def toString: String = s"Expr($f ${args.toList})" } } diff --git a/library/src-2.x/scala/quoted/Type.scala b/library/src-2.x/scala/quoted/Type.scala index 206863ed2c41..b603d78a8c65 100644 --- a/library/src-2.x/scala/quoted/Type.scala +++ b/library/src-2.x/scala/quoted/Type.scala @@ -1,48 +1,53 @@ -package scala.quoted +package scala -import scala.quoted.Types.TaggedType -import scala.reflect.ClassTag -import scala.runtime.quoted.Unpickler.Pickled +package quoted { + import scala.internal.quoted.TaggedType -sealed abstract class Type[T] { - type `$splice` = T -} - -/** Some basic type tags, currently incomplete */ -object Type { + sealed abstract class Type[T] { + type `$splice` = T + } - implicit class TypeOps[T](tpe: Type[T]) { - /** Show a source code like representation of this type */ - def show(implicit toolbox: Toolbox): String = toolbox.show(tpe.asInstanceOf[Type[Any]]) + /** Some basic type tags, currently incomplete */ + object Type { + + implicit class TypeOps[T](tpe: Type[T]) { + /** Show a source code like representation of this type */ + def show(implicit toolbox: Toolbox): String = toolbox.show(tpe.asInstanceOf[Type[Any]]) + } + + implicit def UnitTag: Type[Unit] = new TaggedType[Unit] + implicit def BooleanTag: Type[Boolean] = new TaggedType[Boolean] + implicit def ByteTag: Type[Byte] = new TaggedType[Byte] + implicit def CharTag: Type[Char] = new TaggedType[Char] + implicit def ShortTag: Type[Short] = new TaggedType[Short] + implicit def IntTag: Type[Int] = new TaggedType[Int] + implicit def LongTag: Type[Long] = new TaggedType[Long] + implicit def FloatTag: Type[Float] = new TaggedType[Float] + implicit def DoubleTag: Type[Double] = new TaggedType[Double] } - implicit def UnitTag: Type[Unit] = new TaggedType[Unit] - implicit def BooleanTag: Type[Boolean] = new TaggedType[Boolean] - implicit def ByteTag: Type[Byte] = new TaggedType[Byte] - implicit def CharTag: Type[Char] = new TaggedType[Char] - implicit def ShortTag: Type[Short] = new TaggedType[Short] - implicit def IntTag: Type[Int] = new TaggedType[Int] - implicit def LongTag: Type[Long] = new TaggedType[Long] - implicit def FloatTag: Type[Float] = new TaggedType[Float] - implicit def DoubleTag: Type[Double] = new TaggedType[Double] } -/** All implementations of Type[T]. - * These should never be used directly. - */ -object Types { - /** A Type backed by a pickled TASTY tree */ - final class TastyType[T](val tasty: Pickled, val args: Seq[Any]) extends Type[T] { - override def toString(): String = s"Type()" - } +package internal { + package quoted { + import scala.quote.Type + import scala.reflect.ClassTag + import scala.runtime.quoted.Unpickler.Pickled - /** An Type backed by a value */ - final class TaggedType[T](implicit val ct: ClassTag[T]) extends Type[T] { - override def toString: String = s"Type($ct)" - } + /** A Type backed by a pickled TASTY tree */ + final class TastyType[T](val tasty: Pickled, val args: Seq[Any]) extends Type[T] { + override def toString(): String = s"Type()" + } + + /** An Type backed by a value */ + final class TaggedType[T](implicit val ct: ClassTag[T]) extends Type[T] { + override def toString: String = s"Type($ct)" + } + + /** An Type backed by a tree */ + final class TreeType[Tree](val typeTree: Tree) extends quoted.Type[Any] { + override def toString: String = s"Type()" + } - /** An Type backed by a tree */ - final class TreeType[Tree](val typeTree: Tree) extends quoted.Type[Any] { - override def toString: String = s"Type()" } } diff --git a/library/src-3.x/scala/quoted/Expr.scala b/library/src-3.x/scala/quoted/Expr.scala index cc5bce8ee581..a7cd41179407 100644 --- a/library/src-3.x/scala/quoted/Expr.scala +++ b/library/src-3.x/scala/quoted/Expr.scala @@ -1,334 +1,341 @@ -package scala.quoted +package scala -import scala.runtime.quoted.Unpickler.Pickled +package quoted { -sealed abstract class Expr[+T] { + sealed abstract class Expr[+T] { - /** Evaluate the contents of this expression and return the result. - * - * May throw a FreeVariableError on expressions that came from a macro. - */ - final def run(implicit toolbox: Toolbox): T = toolbox.run(this) - -} - -object Expr { - - implicit class ExprOps[T](expr: Expr[T]) { - /** Show a source code like representation of this expression */ - def show(implicit toolbox: Toolbox): String = toolbox.show(expr) - } - - implicit object FunctionBetaReduction { - - /** Beta-reduces the function appication. Generates the an expression only containing the body of the function */ - def (f: Expr[() => R]) apply[R] (): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array.empty) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1) => R]) apply[T1, R](x1: Expr[T1]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2) => R]) apply[T1, T2, R](x1: Expr[T1], x2: Expr[T2]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3) => R]) apply[T1, T2, T3, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4) => R]) apply[T1, T2, T3, T4, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5) => R]) apply[T1, T2, T3, T4, T5, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6) => R]) apply[T1, T2, T3, T4, T5, T6, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7) => R]) apply[T1, T2, T3, T4, T5, T6, T7, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + /** Evaluate the contents of this expression and return the result. + * + * May throw a FreeVariableError on expressions that came from a macro. */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20], x21: Expr[T21]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21)) - - /** Beta-reduces the function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20], x21: Expr[T21], x22: Expr[T22]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22)) + final def run(implicit toolbox: Toolbox): T = toolbox.run(this) } - implicit object ContextualFunctionBetaReduction { - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1) => R]) apply[T1, R](x1: Expr[T1]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2) => R]) apply[T1, T2, R](x1: Expr[T1], x2: Expr[T2]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3) => R]) apply[T1, T2, T3, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4) => R]) apply[T1, T2, T3, T4, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5) => R]) apply[T1, T2, T3, T4, T5, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6) => R]) apply[T1, T2, T3, T4, T5, T6, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7) => R]) apply[T1, T2, T3, T4, T5, T6, T7, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14)) - - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15)) + object Expr { + + import scala.internal.quoted._ + + implicit class ExprOps[T](expr: Expr[T]) { + /** Show a source code like representation of this expression */ + def show(implicit toolbox: Toolbox): String = toolbox.show(expr) + } + + implicit object FunctionBetaReduction { + + /** Beta-reduces the function appication. Generates the an expression only containing the body of the function */ + def (f: Expr[() => R]) apply[R] (): Expr[R] = + new FunctionAppliedTo[R](f, Array.empty) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1) => R]) apply[T1, R](x1: Expr[T1]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2) => R]) apply[T1, T2, R](x1: Expr[T1], x2: Expr[T2]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3) => R]) apply[T1, T2, T3, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4) => R]) apply[T1, T2, T3, T4, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5) => R]) apply[T1, T2, T3, T4, T5, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6) => R]) apply[T1, T2, T3, T4, T5, T6, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7) => R]) apply[T1, T2, T3, T4, T5, T6, T7, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20], x21: Expr[T21]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21)) + + /** Beta-reduces the function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20], x21: Expr[T21], x22: Expr[T22]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22)) + + } + + implicit object ContextualFunctionBetaReduction { + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1) => R]) apply[T1, R](x1: Expr[T1]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2) => R]) apply[T1, T2, R](x1: Expr[T1], x2: Expr[T2]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3) => R]) apply[T1, T2, T3, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4) => R]) apply[T1, T2, T3, T4, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5) => R]) apply[T1, T2, T3, T4, T5, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6) => R]) apply[T1, T2, T3, T4, T5, T6, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7) => R]) apply[T1, T2, T3, T4, T5, T6, T7, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20], x21: Expr[T21]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21)) + + /** Beta-reduces the contextual function appication. + * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + */ + def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20], x21: Expr[T21], x22: Expr[T22]): Expr[R] = + new FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22)) + + } - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16)) + } - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17)) +} - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)) +package internal { + package quoted { - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)) + import scala.quoted._ - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments - */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20)) + /** An Expr backed by a pickled TASTY tree */ + final class TastyExpr[+T](val tasty: scala.runtime.quoted.Unpickler.Pickled, val args: Seq[Any]) extends Expr[T] { + override def toString: String = s"Expr()" + } - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + /** An Expr backed by a lifted value. + * Values can only be of type Boolean, Byte, Short, Char, Int, Long, Float, Double, Unit, String or Null. */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20], x21: Expr[T21]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21)) + final class LiftedExpr[+T](val value: T) extends Expr[T] { + override def toString: String = s"Expr($value)" + } - /** Beta-reduces the contextual function appication. - * Generates the an expression that evaluates all arguments and then evaluates the body with the evaluated arguments + /** An Expr backed by a tree. Only the current compiler trees are allowed. + * + * These expressions are used for arguments of macros. They contain and actual tree + * from the program that is being expanded by the macro. + * + * May contain references to code defined outside this TastyTreeExpr instance. */ - def (f: Expr[given (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) => R]) apply[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R](x1: Expr[T1], x2: Expr[T2], x3: Expr[T3], x4: Expr[T4], x5: Expr[T5], x6: Expr[T6], x7: Expr[T7], x8: Expr[T8], x9: Expr[T9], x10: Expr[T10], x11: Expr[T11], x12: Expr[T12], x13: Expr[T13], x14: Expr[T14], x15: Expr[T15], x16: Expr[T16], x17: Expr[T17], x18: Expr[T18], x19: Expr[T19], x20: Expr[T20], x21: Expr[T21], x22: Expr[T22]): Expr[R] = - new Exprs.FunctionAppliedTo[R](f, Array(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22)) - - } - -} - -/** All implementations of Expr[T]. - * These should never be used directly. - */ -object Exprs { - /** An Expr backed by a pickled TASTY tree */ - final class TastyExpr[+T](val tasty: Pickled, val args: Seq[Any]) extends Expr[T] { - override def toString: String = s"Expr()" - } + final class TastyTreeExpr[Tree](val tree: Tree) extends Expr[Any] { + override def toString: String = s"Expr()" + } - /** An Expr backed by a lifted value. - * Values can only be of type Boolean, Byte, Short, Char, Int, Long, Float, Double, Unit, String or Null. - */ - final class LiftedExpr[+T](val value: T) extends Expr[T] { - override def toString: String = s"Expr($value)" - } - - /** An Expr backed by a tree. Only the current compiler trees are allowed. - * - * These expressions are used for arguments of macros. They contain and actual tree - * from the program that is being expanded by the macro. - * - * May contain references to code defined outside this TastyTreeExpr instance. - */ - final class TastyTreeExpr[Tree](val tree: Tree) extends quoted.Expr[Any] { - override def toString: String = s"Expr()" - } + // TODO Use a List in FunctionAppliedTo(val f: Expr[_], val args: List[Expr[_]]) + // FIXME: Having the List in the code above trigers an assertion error while testing dotty.tools.dotc.reporting.ErrorMessagesTests.i3187 + // This test does redefine `scala.collection`. Further investigation is needed. + /** An Expr representing `'{($f).apply($x1, ..., $xn)}` but it is beta-reduced when the closure is known */ + final class FunctionAppliedTo[+R](val f: Expr[_], val args: Array[Expr[_]]) extends Expr[R] { + override def toString: String = s"Expr($f ${args.toList})" + } - // TODO Use a List in FunctionAppliedTo(val f: Expr[_], val args: List[Expr[_]]) - // FIXME: Having the List in the code above trigers an assertion error while testing dotty.tools.dotc.reporting.ErrorMessagesTests.i3187 - // This test does redefine `scala.collection`. Further investigation is needed. - /** An Expr representing `'{($f).apply($x1, ..., $xn)}` but it is beta-reduced when the closure is known */ - final class FunctionAppliedTo[+R](val f: Expr[_], val args: Array[Expr[_]]) extends Expr[R] { - override def toString: String = s"Expr($f ${args.toList})" } } diff --git a/library/src-3.x/scala/quoted/Type.scala b/library/src-3.x/scala/quoted/Type.scala index 0f9b755a4962..ab580b78db29 100644 --- a/library/src-3.x/scala/quoted/Type.scala +++ b/library/src-3.x/scala/quoted/Type.scala @@ -1,48 +1,53 @@ -package scala.quoted +package scala -import scala.quoted.Types.TaggedType -import scala.reflect.ClassTag -import scala.runtime.quoted.Unpickler.Pickled +package quoted { + import scala.internal.quoted.TaggedType -sealed abstract class Type[T <: AnyKind] { - type `$splice` = T -} - -/** Some basic type tags, currently incomplete */ -object Type { + sealed abstract class Type[T <: AnyKind] { + type `$splice` = T + } - implicit object TypeOps { - /** Show a source code like representation of this type */ - def (tpe: Type[T]) show[T] given Toolbox: String = the[Toolbox].show(tpe.asInstanceOf[Type[Any]]) + /** Some basic type tags, currently incomplete */ + object Type { + + implicit object TypeOps { + /** Show a source code like representation of this type */ + def (tpe: Type[T]) show[T] given Toolbox: String = the[Toolbox].show(tpe.asInstanceOf[Type[Any]]) + } + + implied UnitTag for Type[Unit] = new TaggedType[Unit] + implied BooleanTag for Type[Boolean] = new TaggedType[Boolean] + implied ByteTag for Type[Byte] = new TaggedType[Byte] + implied CharTag for Type[Char] = new TaggedType[Char] + implied ShortTag for Type[Short] = new TaggedType[Short] + implied IntTag for Type[Int] = new TaggedType[Int] + implied LongTag for Type[Long] = new TaggedType[Long] + implied FloatTag for Type[Float] = new TaggedType[Float] + implied DoubleTag for Type[Double] = new TaggedType[Double] } - implied UnitTag for Type[Unit] = new TaggedType[Unit] - implied BooleanTag for Type[Boolean] = new TaggedType[Boolean] - implied ByteTag for Type[Byte] = new TaggedType[Byte] - implied CharTag for Type[Char] = new TaggedType[Char] - implied ShortTag for Type[Short] = new TaggedType[Short] - implied IntTag for Type[Int] = new TaggedType[Int] - implied LongTag for Type[Long] = new TaggedType[Long] - implied FloatTag for Type[Float] = new TaggedType[Float] - implied DoubleTag for Type[Double] = new TaggedType[Double] } -/** All implementations of Type[T]. - * These should never be used directly. - */ -object Types { - /** A Type backed by a pickled TASTY tree */ - final class TastyType[T](val tasty: Pickled, val args: Seq[Any]) extends Type[T] { - override def toString(): String = s"Type()" - } +package internal { + package quoted { + import scala.quoted.Type + import scala.reflect.ClassTag + import scala.runtime.quoted.Unpickler.Pickled - /** An Type backed by a value */ - final class TaggedType[T](implicit val ct: ClassTag[T]) extends Type[T] { - override def toString: String = s"Type($ct)" - } + /** A Type backed by a pickled TASTY tree */ + final class TastyType[T](val tasty: Pickled, val args: Seq[Any]) extends Type[T] { + override def toString(): String = s"Type()" + } + + /** An Type backed by a value */ + final class TaggedType[T](implicit val ct: ClassTag[T]) extends Type[T] { + override def toString: String = s"Type($ct)" + } + + /** An Type backed by a tree */ + final class TreeType[Tree](val typeTree: Tree) extends Type[Any] { + override def toString: String = s"Type()" + } - /** An Type backed by a tree */ - final class TreeType[Tree](val typeTree: Tree) extends quoted.Type[Any] { - override def toString: String = s"Type()" } } diff --git a/library/src/scala/runtime/quoted/Unpickler.scala b/library/src/scala/runtime/quoted/Unpickler.scala index ac4466b35fa5..1d261de2fb6b 100644 --- a/library/src/scala/runtime/quoted/Unpickler.scala +++ b/library/src/scala/runtime/quoted/Unpickler.scala @@ -1,7 +1,6 @@ package scala.runtime.quoted -import scala.quoted.Types.TastyType -import scala.quoted.Exprs.{LiftedExpr, TastyExpr} +import scala.internal.quoted.{LiftedExpr, TastyExpr, TastyType} import scala.quoted.{Expr, Type} /** Provides methods to unpickle `Expr` and `Type` trees. */ @@ -20,7 +19,7 @@ object Unpickler { /** Lift the `value` to an `Expr` tree. * Values can only be of type Boolean, Byte, Short, Char, Int, Long, Float, Double, Unit, String, Null or Class. */ - def liftedExpr[T](value: T): LiftedExpr[T] = new LiftedExpr[T](value) + def liftedExpr[T](value: T): Expr[T] = new LiftedExpr[T](value) /** Unpickle `repr` which represents a pickled `Type` tree, * replacing splice nodes with `args` diff --git a/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala b/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala index 67be3d130aea..62c1ce166d81 100644 --- a/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala +++ b/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala @@ -1,7 +1,6 @@ import scala.quoted._ import scala.tasty.Reflection import scala.language.implicitConversions -import scala.quoted.Exprs.LiftedExpr object Macro { diff --git a/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala b/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala index e5f48ed5ed62..bee2e93d6d7c 100644 --- a/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala +++ b/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala @@ -1,7 +1,6 @@ import scala.quoted._ import scala.tasty.Reflection import scala.language.implicitConversions -import scala.quoted.Exprs.LiftedExpr object Macro { diff --git a/tests/run-macros/tasty-interpolation-1/Macro.scala b/tests/run-macros/tasty-interpolation-1/Macro.scala index 334fb9cfa77d..099a9c766853 100644 --- a/tests/run-macros/tasty-interpolation-1/Macro.scala +++ b/tests/run-macros/tasty-interpolation-1/Macro.scala @@ -2,7 +2,6 @@ import scala.quoted._ import scala.tasty.Reflection import scala.language.implicitConversions -import scala.quoted.Exprs.LiftedExpr import scala.quoted.autolift._ object Macro { diff --git a/tests/run-with-compiler/quote-run-large.scala b/tests/run-with-compiler/quote-run-large.scala index a9772aeb6b62..043f549ef05a 100644 --- a/tests/run-with-compiler/quote-run-large.scala +++ b/tests/run-with-compiler/quote-run-large.scala @@ -1,6 +1,4 @@ -import scala.quoted.Exprs.TastyExpr - object Test { def main(args: Array[String]): Unit = { val a = '{ // ' @@ -62,7 +60,7 @@ object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - assert(a.asInstanceOf[TastyExpr[_]].tasty.size > 1, "Test should be testing a quote with TastyExpr encoded in more than one string") + assert(a.asInstanceOf[scala.internal.quoted.TastyExpr[_]].tasty.size > 1, "Test should be testing a quote with TastyExpr encoded in more than one string") a.show // Force unpiclking of the expression } } \ No newline at end of file diff --git a/tests/run/quote-compile-constants.check b/tests/run/quote-compile-constants.check index 624206cdecbb..7128f747bf3a 100644 --- a/tests/run/quote-compile-constants.check +++ b/tests/run/quote-compile-constants.check @@ -1,15 +1,15 @@ -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr -class scala.quoted.Exprs$LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr +class scala.internal.quoted.LiftedExpr