diff --git a/community-build/community-projects/dotty-cps-async b/community-build/community-projects/dotty-cps-async index 9a6680c57389..08abe3ab27ee 160000 --- a/community-build/community-projects/dotty-cps-async +++ b/community-build/community-projects/dotty-cps-async @@ -1 +1 @@ -Subproject commit 9a6680c57389e971e8aee7d807356740e0c0717e +Subproject commit 08abe3ab27eeac725641269a8e16d08b68f6f139 diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index 16aad428f5b3..1df03edfdeab 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit 16aad428f5b3057d462d101777783a83cd40aa43 +Subproject commit 1df03edfdeab48ccb73f170a820384d4200c31ce diff --git a/community-build/community-projects/shapeless b/community-build/community-projects/shapeless index dfcd200f3ff6..98a211b44ef4 160000 --- a/community-build/community-projects/shapeless +++ b/community-build/community-projects/shapeless @@ -1 +1 @@ -Subproject commit dfcd200f3ff68bfb76c93666b4f44c1d6f8f0277 +Subproject commit 98a211b44ef412673a68189d66f50b1b04806b10 diff --git a/community-build/community-projects/upickle b/community-build/community-projects/upickle index f21874cc62b1..f7e725676508 160000 --- a/community-build/community-projects/upickle +++ b/community-build/community-projects/upickle @@ -1 +1 @@ -Subproject commit f21874cc62b12bfab54fc6794eafdcc7b2cf2d07 +Subproject commit f7e72567650890eeeacb6c799a34f2423c3a7790 diff --git a/community-build/community-projects/utest b/community-build/community-projects/utest index f3333378b219..b438410da8c3 160000 --- a/community-build/community-projects/utest +++ b/community-build/community-projects/utest @@ -1 +1 @@ -Subproject commit f3333378b219fcccd7bd034fc6bee9f9cd367f72 +Subproject commit b438410da8c3466f7bb4d791b31671f9150075b6 diff --git a/community-build/community-projects/verify b/community-build/community-projects/verify index c250c41cef19..f90d8ae6d88c 160000 --- a/community-build/community-projects/verify +++ b/community-build/community-projects/verify @@ -1 +1 @@ -Subproject commit c250c41cef198bdb8d8dd678944af2181ee684e3 +Subproject commit f90d8ae6d88c9db74d57dbbe90da887bdf9867d3 diff --git a/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala b/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala index 224e7e2990c4..cb1ffa478d70 100644 --- a/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala @@ -166,7 +166,7 @@ class PickleQuotes extends MacroTransform { val literalValue = if lit.const.tag == Constants.NullTag || lit.const.tag == Constants.UnitTag then Nil else List(body) - val constant = reflect.select("Constant".toTermName).select(typeName.toTermName).select(nme.apply).appliedToArgs(literalValue) + val constant = reflect.select(s"${typeName}Constant".toTermName).select(nme.apply).appliedToArgs(literalValue) val literal = reflect.select("Literal".toTermName).select(nme.apply).appliedTo(constant) reflect.select("TreeMethods".toTermName).select("asExpr".toTermName).appliedTo(literal).asInstance(exprType) } diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala index 5b328f4a692c..66622a253a93 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala @@ -2087,100 +2087,160 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler type Constant = dotc.core.Constants.Constant - object Constant extends ConstantModule: + object Constant extends ConstantModule - object Boolean extends BooleanModule: - def apply(x: Boolean): Constant = dotc.core.Constants.Constant(x) - def unapply(constant: Constant): Option[Boolean] = - if constant.tag == dotc.core.Constants.BooleanTag then Some(constant.booleanValue) - else None - end Boolean + given ConstantMethods: ConstantMethods with + extension (self: Constant) + def value: Any = self.value + def show: String = Extractors.showConstant(using QuotesImpl.this)(self) + end extension + end ConstantMethods - object Byte extends ByteModule: - def apply(x: Byte): Constant = dotc.core.Constants.Constant(x) - def unapply(constant: Constant): Option[Byte] = - if constant.tag == dotc.core.Constants.ByteTag then Some(constant.byteValue) - else None - end Byte + type BooleanConstant = dotc.core.Constants.Constant - object Short extends ShortModule: - def apply(x: Short): Constant = dotc.core.Constants.Constant(x) - def unapply(constant: Constant): Option[Short] = - if constant.tag == dotc.core.Constants.ShortTag then Some(constant.shortValue) - else None - end Short + object BooleanConstantTypeTest extends TypeTest[Constant, BooleanConstant]: + def unapply(x: Constant): Option[BooleanConstant & x.type] = + if x.tag == dotc.core.Constants.BooleanTag then Some(x.asInstanceOf[BooleanConstant & x.type]) else None + end BooleanConstantTypeTest - object Int extends IntModule: - def apply(x: Int): Constant = dotc.core.Constants.Constant(x) - def unapply(constant: Constant): Option[Int] = - if constant.tag == dotc.core.Constants.IntTag then Some(constant.intValue) - else None - end Int + object BooleanConstant extends BooleanConstantModule: + def apply(x: Boolean): BooleanConstant = dotc.core.Constants.Constant(x) + def unapply(constant: BooleanConstant): Some[Boolean] = Some(constant.booleanValue) + end BooleanConstant - object Long extends LongModule: - def apply(x: Long): Constant = dotc.core.Constants.Constant(x) - def unapply(constant: Constant): Option[Long] = - if constant.tag == dotc.core.Constants.LongTag then Some(constant.longValue) - else None - end Long + type ByteConstant = dotc.core.Constants.Constant - object Float extends FloatModule: - def apply(x: Float): Constant = dotc.core.Constants.Constant(x) - def unapply(constant: Constant): Option[Float] = - if constant.tag == dotc.core.Constants.FloatTag then Some(constant.floatValue) - else None - end Float + object ByteConstantTypeTest extends TypeTest[Constant, ByteConstant]: + def unapply(x: Constant): Option[ByteConstant & x.type] = + if x.tag == dotc.core.Constants.ByteTag then Some(x.asInstanceOf[ByteConstant & x.type]) else None + end ByteConstantTypeTest - object Double extends DoubleModule: - def apply(x: Double): Constant = dotc.core.Constants.Constant(x) - def unapply(constant: Constant): Option[Double] = - if constant.tag == dotc.core.Constants.DoubleTag then Some(constant.doubleValue) - else None - end Double + object ByteConstant extends ByteConstantModule: + def apply(x: Byte): ByteConstant = dotc.core.Constants.Constant(x) + def unapply(constant: ByteConstant): Some[Byte] = Some(constant.byteValue) + end ByteConstant - object Char extends CharModule: - def apply(x: Char): Constant = dotc.core.Constants.Constant(x) - def unapply(constant: Constant): Option[Char] = - if constant.tag == dotc.core.Constants.CharTag then Some(constant.charValue) - else None - end Char + type ShortConstant = dotc.core.Constants.Constant - object String extends StringModule: - def apply(x: String): Constant = dotc.core.Constants.Constant(x) - def unapply(constant: Constant): Option[String] = - if constant.tag == dotc.core.Constants.StringTag then Some(constant.stringValue) - else None - end String - - object Unit extends UnitModule: - def apply(): Constant = dotc.core.Constants.Constant(()) - def unapply(constant: Constant): Boolean = - constant.tag == dotc.core.Constants.UnitTag - end Unit - - object Null extends NullModule: - def apply(): Constant = dotc.core.Constants.Constant(null) - def unapply(constant: Constant): Boolean = - constant.tag == dotc.core.Constants.NullTag - end Null - - object ClassOf extends ClassOfModule: - def apply(x: TypeRepr): Constant = - // TODO check that the type is a valid class when creating this constant or let Ycheck do it? - dotc.core.Constants.Constant(x) - def unapply(constant: Constant): Option[TypeRepr] = - if constant.tag == dotc.core.Constants.ClazzTag then Some(constant.typeValue) - else None - end ClassOf + object ShortConstantTypeTest extends TypeTest[Constant, ShortConstant]: + def unapply(x: Constant): Option[ShortConstant & x.type] = + if x.tag == dotc.core.Constants.ShortTag then Some(x.asInstanceOf[ShortConstant & x.type]) else None + end ShortConstantTypeTest - end Constant + object ShortConstant extends ShortConstantModule: + def apply(x: Short): ShortConstant = dotc.core.Constants.Constant(x) + def unapply(constant: ShortConstant): Some[Short] = Some(constant.shortValue) + end ShortConstant - given ConstantMethods: ConstantMethods with - extension (self: Constant) - def value: Any = self.value - def show: String = Extractors.showConstant(using QuotesImpl.this)(self) - end extension - end ConstantMethods + type IntConstant = dotc.core.Constants.Constant + + object IntConstantTypeTest extends TypeTest[Constant, IntConstant]: + def unapply(x: Constant): Option[IntConstant & x.type] = + if x.tag == dotc.core.Constants.IntTag then Some(x.asInstanceOf[IntConstant & x.type]) else None + end IntConstantTypeTest + + object IntConstant extends IntConstantModule: + def apply(x: Int): IntConstant = dotc.core.Constants.Constant(x) + def unapply(constant: IntConstant): Some[Int] = Some(constant.intValue) + end IntConstant + + type LongConstant = dotc.core.Constants.Constant + + object LongConstantTypeTest extends TypeTest[Constant, LongConstant]: + def unapply(x: Constant): Option[LongConstant & x.type] = + if x.tag == dotc.core.Constants.LongTag then Some(x.asInstanceOf[LongConstant & x.type]) else None + end LongConstantTypeTest + + object LongConstant extends LongConstantModule: + def apply(x: Long): LongConstant = dotc.core.Constants.Constant(x) + def unapply(constant: LongConstant): Some[Long] = Some(constant.longValue) + end LongConstant + + type FloatConstant = dotc.core.Constants.Constant + + object FloatConstantTypeTest extends TypeTest[Constant, FloatConstant]: + def unapply(x: Constant): Option[FloatConstant & x.type] = + if x.tag == dotc.core.Constants.FloatTag then Some(x.asInstanceOf[FloatConstant & x.type]) else None + end FloatConstantTypeTest + + object FloatConstant extends FloatConstantModule: + def apply(x: Float): FloatConstant = dotc.core.Constants.Constant(x) + def unapply(constant: FloatConstant): Some[Float] = Some(constant.floatValue) + end FloatConstant + + type DoubleConstant = dotc.core.Constants.Constant + + object DoubleConstantTypeTest extends TypeTest[Constant, DoubleConstant]: + def unapply(x: Constant): Option[DoubleConstant & x.type] = + if x.tag == dotc.core.Constants.DoubleTag then Some(x.asInstanceOf[DoubleConstant & x.type]) else None + end DoubleConstantTypeTest + + object DoubleConstant extends DoubleConstantModule: + def apply(x: Double): DoubleConstant = dotc.core.Constants.Constant(x) + def unapply(constant: DoubleConstant): Some[Double] = Some(constant.doubleValue) + end DoubleConstant + + type CharConstant = dotc.core.Constants.Constant + + object CharConstantTypeTest extends TypeTest[Constant, CharConstant]: + def unapply(x: Constant): Option[CharConstant & x.type] = + if x.tag == dotc.core.Constants.CharTag then Some(x.asInstanceOf[CharConstant & x.type]) else None + end CharConstantTypeTest + + object CharConstant extends CharConstantModule: + def apply(x: Char): CharConstant = dotc.core.Constants.Constant(x) + def unapply(constant: CharConstant): Some[Char] = Some(constant.charValue) + end CharConstant + + type StringConstant = dotc.core.Constants.Constant + + object StringConstantTypeTest extends TypeTest[Constant, StringConstant]: + def unapply(x: Constant): Option[StringConstant & x.type] = + if x.tag == dotc.core.Constants.StringTag then Some(x.asInstanceOf[StringConstant & x.type]) else None + end StringConstantTypeTest + + object StringConstant extends StringConstantModule: + def apply(x: String): StringConstant = dotc.core.Constants.Constant(x) + def unapply(constant: StringConstant): Some[String] = Some(constant.stringValue) + end StringConstant + + type UnitConstant = dotc.core.Constants.Constant + + object UnitConstantTypeTest extends TypeTest[Constant, UnitConstant]: + def unapply(x: Constant): Option[UnitConstant & x.type] = + if x.tag == dotc.core.Constants.UnitTag then Some(x.asInstanceOf[UnitConstant & x.type]) else None + end UnitConstantTypeTest + + object UnitConstant extends UnitConstantModule: + def apply(): UnitConstant = dotc.core.Constants.Constant(()) + def unapply(constant: UnitConstant): true = true + end UnitConstant + + type NullConstant = dotc.core.Constants.Constant + + object NullConstantTypeTest extends TypeTest[Constant, NullConstant]: + def unapply(x: Constant): Option[NullConstant & x.type] = + if x.tag == dotc.core.Constants.NullTag then Some(x.asInstanceOf[NullConstant & x.type]) else None + end NullConstantTypeTest + + object NullConstant extends NullConstantModule: + def apply(): NullConstant = dotc.core.Constants.Constant(null) + def unapply(constant: NullConstant): true = true + end NullConstant + + type ClassOfConstant = dotc.core.Constants.Constant + + object ClassOfConstantTypeTest extends TypeTest[Constant, ClassOfConstant]: + def unapply(x: Constant): Option[ClassOfConstant & x.type] = + if x.tag == dotc.core.Constants.ClazzTag then Some(x.asInstanceOf[ClassOfConstant & x.type]) else None + end ClassOfConstantTypeTest + + object ClassOfConstant extends ClassOfConstantModule: + def apply(x: TypeRepr): ClassOfConstant = + // TODO check that the type is a valid class when creating this constant or let Ycheck do it? + dotc.core.Constants.Constant(x) + def unapply(constant: ClassOfConstant): Some[TypeRepr] = Some(constant.typeValue) + end ClassOfConstant object Implicits extends ImplicitsModule: def search(tpe: TypeRepr): ImplicitSearchResult = diff --git a/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala b/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala index db4e7821df71..324a9183fd3a 100644 --- a/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala +++ b/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala @@ -176,19 +176,19 @@ object Extractors { } def visitConstant(x: Constant): this.type = x match { - case Constant.Unit() => this += "Constant.Unit()" - case Constant.Null() => this += "Constant.Null()" - case Constant.Boolean(value) => this += "Constant.Boolean(" += value += ")" - case Constant.Byte(value) => this += "Constant.Byte(" += value += ")" - case Constant.Short(value) => this += "Constant.Short(" += value += ")" - case Constant.Int(value) => this += "Constant.Int(" += value += ")" - case Constant.Long(value) => this += "Constant.Long(" += value += "L)" - case Constant.Float(value) => this += "Constant.Float(" += value += "f)" - case Constant.Double(value) => this += "Constant.Double(" += value += "d)" - case Constant.Char(value) => this += "Constant.Char('" += value += "')" - case Constant.String(value) => this += "Constant.String(\"" += value += "\")" - case Constant.ClassOf(value) => - this += "Constant.ClassOf(" + case UnitConstant() => this += "UnitConstant()" + case NullConstant() => this += "NullConstant()" + case BooleanConstant(value) => this += "BooleanConstant(" += value += ")" + case ByteConstant(value) => this += "ByteConstant(" += value += ")" + case ShortConstant(value) => this += "ShortConstant(" += value += ")" + case IntConstant(value) => this += "IntConstant(" += value += ")" + case LongConstant(value) => this += "LongConstant(" += value += "L)" + case FloatConstant(value) => this += "FloatConstant(" += value += "f)" + case DoubleConstant(value) => this += "DoubleConstant(" += value += "d)" + case CharConstant(value) => this += "CharConstant('" += value += "')" + case StringConstant(value) => this += "StringConstant(\"" += value += "\")" + case ClassOfConstant(value) => + this += "ClassOfConstant(" visitType(value) += ")" } diff --git a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala index e412bc6941f0..f1ee10777c7c 100644 --- a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala +++ b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala @@ -291,7 +291,7 @@ object SourceCode { case While(cond, body) => (cond, body) match { - case (Block(Block(Nil, body1) :: Nil, Block(Nil, cond1)), Literal(Constant.Unit())) => + case (Block(Block(Nil, body1) :: Nil, Block(Nil, cond1)), Literal(UnitConstant())) => this += highlightKeyword("do ") printTree(body1) += highlightKeyword(" while ") inParens(printTree(cond1)) @@ -562,7 +562,7 @@ object SourceCode { while (it.hasNext) extractFlatStats(it.next()) extractFlatStats(expansion) - case Literal(Constant.Unit()) => // ignore + case Literal(UnitConstant()) => // ignore case stat => flatStats += stat } def extractFlatExpr(term: Term): Term = term match { @@ -945,18 +945,18 @@ object SourceCode { inline private val qSc = '"' def printConstant(const: Constant): this.type = const match { - case Constant.Unit() => this += highlightLiteral("()") - case Constant.Null() => this += highlightLiteral("null") - case Constant.Boolean(v) => this += highlightLiteral(v.toString) - case Constant.Byte(v) => this += highlightLiteral(v.toString) - case Constant.Short(v) => this += highlightLiteral(v.toString) - case Constant.Int(v) => this += highlightLiteral(v.toString) - case Constant.Long(v) => this += highlightLiteral(v.toString + "L") - case Constant.Float(v) => this += highlightLiteral(v.toString + "f") - case Constant.Double(v) => this += highlightLiteral(v.toString) - case Constant.Char(v) => this += highlightString(s"${qc}${escapedChar(v)}${qc}") - case Constant.String(v) => this += highlightString(s"${qSc}${escapedString(v)}${qSc}") - case Constant.ClassOf(v) => + case UnitConstant() => this += highlightLiteral("()") + case NullConstant() => this += highlightLiteral("null") + case BooleanConstant(v) => this += highlightLiteral(v.toString) + case ByteConstant(v) => this += highlightLiteral(v.toString) + case ShortConstant(v) => this += highlightLiteral(v.toString) + case IntConstant(v) => this += highlightLiteral(v.toString) + case LongConstant(v) => this += highlightLiteral(v.toString + "L") + case FloatConstant(v) => this += highlightLiteral(v.toString + "f") + case DoubleConstant(v) => this += highlightLiteral(v.toString) + case CharConstant(v) => this += highlightString(s"${qc}${escapedChar(v)}${qc}") + case StringConstant(v) => this += highlightString(s"${qSc}${escapedString(v)}${qSc}") + case ClassOfConstant(v) => this += "classOf" inSquare(printType(v)) } diff --git a/library/src-bootstrapped/scala/quoted/ToExpr.scala b/library/src-bootstrapped/scala/quoted/ToExpr.scala index d5abc2c22c08..39dcf01ef3a1 100644 --- a/library/src-bootstrapped/scala/quoted/ToExpr.scala +++ b/library/src-bootstrapped/scala/quoted/ToExpr.scala @@ -21,63 +21,63 @@ object ToExpr { given BooleanToExpr[T <: Boolean]: ToExpr[T] with { def apply(x: T)(using Quotes) = import quotes.reflect._ - Literal(Constant.Boolean(x)).asExpr.asInstanceOf[Expr[T]] + Literal(BooleanConstant(x)).asExpr.asInstanceOf[Expr[T]] } /** Default implemetation of `ToExpr[Byte]` */ given ByteToExpr[T <: Byte]: ToExpr[T] with { def apply(x: T)(using Quotes) = import quotes.reflect._ - Literal(Constant.Byte(x)).asExpr.asInstanceOf[Expr[T]] + Literal(ByteConstant(x)).asExpr.asInstanceOf[Expr[T]] } /** Default implemetation of `ToExpr[Short]` */ given ShortToExpr[T <: Short]: ToExpr[T] with { def apply(x: T)(using Quotes) = import quotes.reflect._ - Literal(Constant.Short(x)).asExpr.asInstanceOf[Expr[T]] + Literal(ShortConstant(x)).asExpr.asInstanceOf[Expr[T]] } /** Default implemetation of `ToExpr[Int]` */ given IntToExpr[T <: Int]: ToExpr[T] with { def apply(x: T)(using Quotes) = import quotes.reflect._ - Literal(Constant.Int(x)).asExpr.asInstanceOf[Expr[T]] + Literal(IntConstant(x)).asExpr.asInstanceOf[Expr[T]] } /** Default implemetation of `ToExpr[Long]` */ given LongToExpr[T <: Long]: ToExpr[T] with { def apply(x: T)(using Quotes) = import quotes.reflect._ - Literal(Constant.Long(x)).asExpr.asInstanceOf[Expr[T]] + Literal(LongConstant(x)).asExpr.asInstanceOf[Expr[T]] } /** Default implemetation of `ToExpr[Float]` */ given FloatToExpr[T <: Float]: ToExpr[T] with { def apply(x: T)(using Quotes) = import quotes.reflect._ - Literal(Constant.Float(x)).asExpr.asInstanceOf[Expr[T]] + Literal(FloatConstant(x)).asExpr.asInstanceOf[Expr[T]] } /** Default implemetation of `ToExpr[Double]` */ given DoubleToExpr[T <: Double]: ToExpr[T] with { def apply(x: T)(using Quotes) = import quotes.reflect._ - Literal(Constant.Double(x)).asExpr.asInstanceOf[Expr[T]] + Literal(DoubleConstant(x)).asExpr.asInstanceOf[Expr[T]] } /** Default implemetation of `ToExpr[Char]` */ given CharToExpr[T <: Char]: ToExpr[T] with { def apply(x: T)(using Quotes) = import quotes.reflect._ - Literal(Constant.Char(x)).asExpr.asInstanceOf[Expr[T]] + Literal(CharConstant(x)).asExpr.asInstanceOf[Expr[T]] } /** Default implemetation of `ToExpr[String]` */ given StringToExpr[T <: String]: ToExpr[T] with { def apply(x: T)(using Quotes) = import quotes.reflect._ - Literal(Constant.String(x)).asExpr.asInstanceOf[Expr[T]] + Literal(StringConstant(x)).asExpr.asInstanceOf[Expr[T]] } /** Default implemetation of `ToExpr[Class[T]]` */ diff --git a/library/src/scala/quoted/Const.scala b/library/src/scala/quoted/Const.scala index 2cc40d4a9de6..7b65f5118a09 100644 --- a/library/src/scala/quoted/Const.scala +++ b/library/src/scala/quoted/Const.scala @@ -25,9 +25,7 @@ object Const { def rec(tree: Term): Option[T] = tree match { case Literal(c) => c match - case Constant.Null() => None - case Constant.Unit() => None - case Constant.ClassOf(_) => None + case NullConstant() | UnitConstant() | ClassOfConstant(_) => None case _ => Some(c.value.asInstanceOf[T]) case Block(Nil, e) => rec(e) case Typed(e, _) => rec(e) diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala index cd97c8d08a27..defdfe940bfb 100644 --- a/library/src/scala/quoted/Quotes.scala +++ b/library/src/scala/quoted/Quotes.scala @@ -189,8 +189,18 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => * * +- SourceFile * - * +- Constant - * + * +- Constant -+- BooleanConstant + * +- ByteConstant + * +- ShortConstant + * +- IntConstant + * +- LongConstant + * +- FloatConstant + * +- DoubleConstant + * +- CharConstant + * +- StringConstant + * +- UnitConstant + * +- NullConstant + * +- ClassOfConstant * +- Symbol * * +- Flags @@ -2732,166 +2742,228 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Constant value represented as the constant itself */ type Constant <: AnyRef - /** Constant value represented as the constant itself - * - * Usage: - * ``` - * Constant.Int(3) match - * case Constant.Int(n) => - * ``` - */ + /** Constant value represented as the constant itself */ val Constant: ConstantModule /** Constant value represented as the constant itself */ - trait ConstantModule { this: Constant.type => + trait ConstantModule { this: Constant.type => } - /** Constant Boolean value */ - val Boolean: BooleanModule + /** Makes extension methods on `Constant` available without any imports */ + given ConstantMethods: ConstantMethods - /** Methods of the module object `val Boolean` */ - trait BooleanModule { this: Boolean.type => - /** Create a constant Boolean value */ - def apply(x: Boolean): Constant - /** Match Boolean value constant and extract its value */ - def unapply(constant: Constant): Option[Boolean] - } + /** Extension methods of `Constant` */ + trait ConstantMethods { + extension (self: Constant) + /** Returns the value of the constant */ + def value: Any - /** Constant Byte value */ - val Byte: ByteModule + /** Shows the constant as a String */ + def show: String + end extension + } - /** Methods of the module object `val Byte` */ - trait ByteModule { this: Byte.type => - /** Create a constant Byte value */ - def apply(x: Byte): Constant - /** Match Byte value constant and extract its value */ - def unapply(constant: Constant): Option[Byte] - } + /** Constant Boolean value */ + type BooleanConstant <: Constant - /** Constant Short value */ - val Short: ShortModule + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `BooleanConstant` */ + given BooleanConstantTypeTest: TypeTest[Constant, BooleanConstant] - /** Methods of the module object `val Short` */ - trait ShortModule { this: Short.type => - /** Create a constant Short value */ - def apply(x: Short): Constant - /** Match Short value constant and extract its value */ - def unapply(constant: Constant): Option[Short] - } + /** Module object of `type BooleanConstant` */ + val BooleanConstant: BooleanConstantModule - /** Constant Int value */ - val Int: IntModule + /** Methods of the module object `val BooleanConstant` */ + trait BooleanConstantModule { this: BooleanConstant.type => + /** Create a constant Boolean value */ + def apply(x: Boolean): BooleanConstant + /** Match Boolean value constant and extract its value */ + def unapply(constant: BooleanConstant): Some[Boolean] + } - /** Methods of the module object `val Int` */ - trait IntModule { this: Int.type => - /** Create a constant Int value */ - def apply(x: Int): Constant - /** Match Int value constant and extract its value */ - def unapply(constant: Constant): Option[Int] - } + /** Constant Byte value */ + type ByteConstant <: Constant - /** Constant Long value */ - val Long: LongModule + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `ByteConstant` */ + given ByteConstantTypeTest: TypeTest[Constant, ByteConstant] - /** Methods of the module object `val Long` */ - trait LongModule { this: Long.type => - /** Create a constant Long value */ - def apply(x: Long): Constant - /** Match Long value constant and extract its value */ - def unapply(constant: Constant): Option[Long] - } + /** Module object of `type ByteConstant` */ + val ByteConstant: ByteConstantModule - /** Constant Float value */ - val Float: FloatModule + /** Methods of the module object `val ByteConstant` */ + trait ByteConstantModule { this: ByteConstant.type => + /** Create a constant Byte value */ + def apply(x: Byte): ByteConstant + /** Match Byte value constant and extract its value */ + def unapply(constant: ByteConstant): Some[Byte] + } - /** Methods of the module object `val Float` */ - trait FloatModule { this: Float.type => - /** Create a constant Float value */ - def apply(x: Float): Constant - /** Match Float value constant and extract its value */ - def unapply(constant: Constant): Option[Float] - } + /** Constant Short value */ + type ShortConstant <: Constant - /** Constant Double value */ - val Double: DoubleModule + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `ShortConstant` */ + given ShortConstantTypeTest: TypeTest[Constant, ShortConstant] - /** Methods of the module object `val Double` */ - trait DoubleModule { this: Double.type => - /** Create a constant Double value */ - def apply(x: Double): Constant - /** Match Double value constant and extract its value */ - def unapply(constant: Constant): Option[Double] - } + /** Module object of `type ShortConstant` */ + val ShortConstant: ShortConstantModule - /** Constant Char value */ - val Char: CharModule + /** Methods of the module object `val Short` */ + trait ShortConstantModule { this: ShortConstant.type => + /** Create a constant Short value */ + def apply(x: Short): ShortConstant + /** Match Short value constant and extract its value */ + def unapply(constant: ShortConstant): Some[Short] + } - /** Methods of the module object `val Char` */ - trait CharModule { this: Char.type => - /** Create a constant Char value */ - def apply(x: Char): Constant - /** Match Char value constant and extract its value */ - def unapply(constant: Constant): Option[Char] - } + /** Constant Int value */ + type IntConstant <: Constant - /** Constant String value */ - val String: StringModule + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `IntConstant` */ + given IntConstantTypeTest: TypeTest[Constant, IntConstant] - /** Methods of the module object `val String` */ - trait StringModule { this: String.type => - /** Create a constant String value */ - def apply(x: String): Constant - /** Match String value constant and extract its value */ - def unapply(constant: Constant): Option[String] - } + /** Module object of `type IntConstant` */ + val IntConstant: IntConstantModule - /** Constant Unit value */ - val Unit: UnitModule + /** Methods of the module object `val IntConstant` */ + trait IntConstantModule { this: IntConstant.type => + /** Create a constant Int value */ + def apply(x: Int): IntConstant + /** Match Int value constant and extract its value */ + def unapply(constant: IntConstant): Some[Int] + } - /** Methods of the module object `val Unit` */ - trait UnitModule { this: Unit.type => - /** Create a constant Unit value */ - def apply(): Constant - /** Match Unit value constant */ - def unapply(constant: Constant): Boolean - } + /** Constant Long value */ + type LongConstant <: Constant - /** Constant null value */ - val Null: NullModule + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `LongConstant` */ + given LongConstantTypeTest: TypeTest[Constant, LongConstant] - /** Methods of the module object `val Null` */ - trait NullModule { this: Null.type => - /** Create a constant null value */ - def apply(): Constant - /** Match null value constant */ - def unapply(constant: Constant): Boolean - } + /** Module object of `type LongConstant` */ + val LongConstant: LongConstantModule + + /** Methods of the module object `val LongConstant` */ + trait LongConstantModule { this: LongConstant.type => + /** Create a constant Long value */ + def apply(x: Long): LongConstant + /** Match Long value constant and extract its value */ + def unapply(constant: LongConstant): Some[Long] + } - /** Constant class value representing a `classOf[T]` */ - val ClassOf: ClassOfModule + /** Constant Float value */ + type FloatConstant <: Constant - /** Methods of the module object `val ClassOf` */ - trait ClassOfModule { this: ClassOf.type => - /** Create a constant class value representing `classOf[]` */ - def apply(tpe: TypeRepr): Constant - /** Match a class value constant representing `classOf[]` and extract its type */ - def unapply(constant: Constant): Option[TypeRepr] - } + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `FloatConstant` */ + given FloatConstantTypeTest: TypeTest[Constant, FloatConstant] + /** Module object of `type FloatConstant` */ + val FloatConstant: FloatConstantModule + + /** Methods of the module object `val FloatConstant` */ + trait FloatConstantModule { this: FloatConstant.type => + /** Create a constant Float value */ + def apply(x: Float): FloatConstant + /** Match Float value constant and extract its value */ + def unapply(constant: FloatConstant): Some[Float] } - /** Makes extension methods on `Constant` available without any imports */ - given ConstantMethods: ConstantMethods + /** Constant Double value */ + type DoubleConstant <: Constant - /** Extension methods of `Constant` */ - trait ConstantMethods { - extension (self: Constant) - /** Returns the value of the constant */ - def value: Any + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `DoubleConstant` */ + given DoubleConstantTypeTest: TypeTest[Constant, DoubleConstant] - /** Shows the constant as a String */ - def show: String + /** Module object of `type DoubleConstant` */ + val DoubleConstant: DoubleConstantModule - end extension + /** Methods of the module object `val DoubleConstant` */ + trait DoubleConstantModule { this: DoubleConstant.type => + /** Create a constant Double value */ + def apply(x: Double): DoubleConstant + /** Match Double value constant and extract its value */ + def unapply(constant: DoubleConstant): Some[Double] + } + + /** Constant Char value */ + type CharConstant <: Constant + + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `CharConstant` */ + given CharConstantTypeTest: TypeTest[Constant, CharConstant] + + /** Module object of `type CharConstant` */ + val CharConstant: CharConstantModule + + /** Methods of the module object `val CharConstant` */ + trait CharConstantModule { this: CharConstant.type => + /** Create a constant Char value */ + def apply(x: Char): CharConstant + /** Match Char value constant and extract its value */ + def unapply(constant: CharConstant): Some[Char] + } + + /** Constant String value */ + type StringConstant <: Constant + + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `StringConstant` */ + given StringConstantTypeTest: TypeTest[Constant, StringConstant] + + /** Module object of `type StringConstant` */ + val StringConstant: StringConstantModule + + /** Methods of the module object `val StringConstant` */ + trait StringConstantModule { this: StringConstant.type => + /** Create a constant String value */ + def apply(x: String): StringConstant + /** Match String value constant and extract its value */ + def unapply(constant: StringConstant): Some[String] + } + + /** Constant Unit value */ + type UnitConstant <: Constant + + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `UnitConstant` */ + given UnitConstantTypeTest: TypeTest[Constant, UnitConstant] + + /** Module object of `type UnitConstant` */ + val UnitConstant: UnitConstantModule + + /** Methods of the module object `val UnitConstant` */ + trait UnitConstantModule { this: UnitConstant.type => + /** Create a constant Unit value */ + def apply(): UnitConstant + /** Match Unit value constant */ + def unapply(constant: UnitConstant): true + } + + /** Constant null value */ + type NullConstant <: Constant + + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `NullConstant` */ + given NullConstantTypeTest: TypeTest[Constant, NullConstant] + + /** Module object of `type NullConstant` */ + val NullConstant: NullConstantModule + + /** Methods of the module object `val NullConstant` */ + trait NullConstantModule { this: NullConstant.type => + /** Create a constant null value */ + def apply(): NullConstant + /** Match null value constant */ + def unapply(constant: NullConstant): Boolean + } + + /** Constant class value representing a `classOf[T]` */ + type ClassOfConstant <: Constant + + /** `TypeTest` that allows testing at runtime in a pattern match if a `Constant` is a `ClassOfConstant` */ + given ClassOfConstantTypeTest: TypeTest[Constant, ClassOfConstant] + + /** Module object of `type ClassOfConstant` */ + val ClassOfConstant: ClassOfConstantModule + + /** Methods of the module object `val ClassOf` */ + trait ClassOfConstantModule { this: ClassOfConstant.type => + /** Create a constant class value representing `classOf[]` */ + def apply(tpe: TypeRepr): ClassOfConstant + /** Match a class value constant representing `classOf[]` and extract its type */ + def unapply(constant: ClassOfConstant): Option[TypeRepr] } ///////////////////// diff --git a/tests/pos-macros/tasty-constant-type/Macro_1.scala b/tests/pos-macros/tasty-constant-type/Macro_1.scala index 187567ff949f..b0b4d546548e 100644 --- a/tests/pos-macros/tasty-constant-type/Macro_1.scala +++ b/tests/pos-macros/tasty-constant-type/Macro_1.scala @@ -9,10 +9,10 @@ object Macro { def impl[A <: Int : Type, B <: Int : Type](using Quotes) : Expr[AddInt[A, B]] = { import quotes.reflect._ - val ConstantType(Constant.Int(v1)) = TypeRepr.of[A] - val ConstantType(Constant.Int(v2)) = TypeRepr.of[B] + val ConstantType(IntConstant(v1)) = TypeRepr.of[A] + val ConstantType(IntConstant(v2)) = TypeRepr.of[B] - Literal(Constant.Int(v1 + v2)).tpe.asType match + Literal(IntConstant(v1 + v2)).tpe.asType match case '[t] => '{ null: AddInt[A, B] { type Out = t } } } } diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-2.check b/tests/run-custom-args/Yretain-trees/tasty-definitions-2.check index 114221a5a4a5..bb713fb9d303 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-2.check +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-2.check @@ -1,3 +1,3 @@ -DefDef("foo", Nil, Nil, TypeIdent("Int"), Some(Apply(Select(Literal(Constant.Int(1)), "+"), List(Literal(Constant.Int(2)))))) -ValDef("bar", TypeIdent("Int"), Some(Apply(Select(Literal(Constant.Int(2)), "+"), List(Literal(Constant.Int(3)))))) +DefDef("foo", Nil, Nil, TypeIdent("Int"), Some(Apply(Select(Literal(IntConstant(1)), "+"), List(Literal(IntConstant(2)))))) +ValDef("bar", TypeIdent("Int"), Some(Apply(Select(Literal(IntConstant(2)), "+"), List(Literal(IntConstant(3)))))) Bind("x", Ident("_")) diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check index 335a80717346..92665686d040 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check @@ -1,2 +1,2 @@ -DefDef("foo", Nil, Nil, TypeIdent("Int"), Some(Apply(Select(Literal(Constant.Int(1)), "+"), List(Literal(Constant.Int(2)))))) -ValDef("bar", TypeIdent("Int"), Some(Apply(Select(Literal(Constant.Int(2)), "+"), List(Literal(Constant.Int(3)))))) +DefDef("foo", Nil, Nil, TypeIdent("Int"), Some(Apply(Select(Literal(IntConstant(1)), "+"), List(Literal(IntConstant(2)))))) +ValDef("bar", TypeIdent("Int"), Some(Apply(Select(Literal(IntConstant(2)), "+"), List(Literal(IntConstant(3)))))) diff --git a/tests/run-macros/exports.check b/tests/run-macros/exports.check index 5e124f8b8657..4f4fc1f0e360 100644 --- a/tests/run-macros/exports.check +++ b/tests/run-macros/exports.check @@ -11,6 +11,6 @@ reflection show: () } reflection show extractors: -Inlined(None, Nil, Block(List(ValDef("Observer", TypeIdent("Observer$"), Some(Apply(Select(New(TypeIdent("Observer$")), ""), Nil))), ClassDef("Observer$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Observer")), None)), List(Export(Ident("Messages"), List(SimpleSelector(count))), DefDef("count", Nil, Nil, Inferred(), Some(Select(Ident("Messages"), "count")))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ValDef("Observer", TypeIdent("Observer$"), Some(Apply(Select(New(TypeIdent("Observer$")), ""), Nil))), ClassDef("Observer$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Observer")), None)), List(Export(Ident("Messages"), List(SimpleSelector(count))), DefDef("count", Nil, Nil, Inferred(), Some(Select(Ident("Messages"), "count")))))), Literal(UnitConstant()))) visited exports with splice visited exports with splice inverted diff --git a/tests/run-macros/f-interpolation-1/FQuote_1.scala b/tests/run-macros/f-interpolation-1/FQuote_1.scala index 725d494c80d4..4d61240c982a 100644 --- a/tests/run-macros/f-interpolation-1/FQuote_1.scala +++ b/tests/run-macros/f-interpolation-1/FQuote_1.scala @@ -36,7 +36,7 @@ object FQuote { if isSCOpsConversion(conv) && isStringContextApply(fun) && values.forall(isStringConstant) => - values.collect { case Literal(Constant.String(value)) => value } + values.collect { case Literal(StringConstant(value)) => value } case tree => report.error(s"String literal expected, but ${tree.show(using Printer.TreeStructure)} found") return '{???} diff --git a/tests/run-macros/i5119.check b/tests/run-macros/i5119.check index 90c98e0a2c3b..25a27ca667e9 100644 --- a/tests/run-macros/i5119.check +++ b/tests/run-macros/i5119.check @@ -1,2 +1,2 @@ -Select(Typed(Apply(Select(New(TypeIdent("StringContextOps")), ""), List(Apply(Select(Select(Select(Ident("_root_"), "scala"), "StringContext"), "apply"), List(Typed(Repeated(List(Literal(Constant.String("Hello World ")), Literal(Constant.String("!"))), Inferred()), Inferred()))))), TypeIdent("StringContextOps")), "inline$sc") -Typed(Repeated(List(Literal(Constant.Int(1))), Inferred()), Inferred()) +Select(Typed(Apply(Select(New(TypeIdent("StringContextOps")), ""), List(Apply(Select(Select(Select(Ident("_root_"), "scala"), "StringContext"), "apply"), List(Typed(Repeated(List(Literal(StringConstant("Hello World ")), Literal(StringConstant("!"))), Inferred()), Inferred()))))), TypeIdent("StringContextOps")), "inline$sc") +Typed(Repeated(List(Literal(IntConstant(1))), Inferred()), Inferred()) diff --git a/tests/run-macros/i5119b.check b/tests/run-macros/i5119b.check index 3e1f5cde7707..7cbf3d224d6b 100644 --- a/tests/run-macros/i5119b.check +++ b/tests/run-macros/i5119b.check @@ -1,4 +1,4 @@ -Apply(Ident("foo"), List(Literal(Constant.Int(1)))) -Apply(Ident("foo"), List(Literal(Constant.Int(2)))) -Apply(Ident("foo"), List(Literal(Constant.Int(4)))) -Apply(Ident("foo"), List(Literal(Constant.Int(3)))) +Apply(Ident("foo"), List(Literal(IntConstant(1)))) +Apply(Ident("foo"), List(Literal(IntConstant(2)))) +Apply(Ident("foo"), List(Literal(IntConstant(4)))) +Apply(Ident("foo"), List(Literal(IntConstant(3)))) diff --git a/tests/run-macros/i6988/FirstArg_1.scala b/tests/run-macros/i6988/FirstArg_1.scala index 56a286dcbf82..a2a44c507bad 100644 --- a/tests/run-macros/i6988/FirstArg_1.scala +++ b/tests/run-macros/i6988/FirstArg_1.scala @@ -23,7 +23,7 @@ object Macros { else enclosingParamList(owner.owner) def literal(value: String): Expr[String] = - Literal(Constant.String(value)).asExpr.asInstanceOf[Expr[String]] + Literal(StringConstant(value)).asExpr.asInstanceOf[Expr[String]] val paramss = enclosingParamList(Symbol.spliceOwner) val firstArg = paramss.flatten.head val ref = Select.unique(This(enclosingClass()), firstArg.name) diff --git a/tests/run-macros/i9812b/Macro_1.scala b/tests/run-macros/i9812b/Macro_1.scala index 700edb1770d4..ed1873195323 100644 --- a/tests/run-macros/i9812b/Macro_1.scala +++ b/tests/run-macros/i9812b/Macro_1.scala @@ -29,7 +29,7 @@ case object NIL extends Lst[Nothing] given IntLiftable[T <: Int]: Liftable[T] with def toExpr(x: T): Quotes ?=> Expr[T] = qctx ?=> { import quotes.reflect._ - Literal(Constant.Int(x)).asExpr.asInstanceOf[Expr[T]] + Literal(IntConstant(x)).asExpr.asInstanceOf[Expr[T]] } given LiftLst[T: Type: Liftable](using ev1: => Liftable[CONS[T]], ev2: => Liftable[NIL.type]): Liftable[Lst[T]] with diff --git a/tests/run-macros/refined-selectable-macro/Macro_1.scala b/tests/run-macros/refined-selectable-macro/Macro_1.scala index fc518d82fcde..9f4dd83fc1f0 100644 --- a/tests/run-macros/refined-selectable-macro/Macro_1.scala +++ b/tests/run-macros/refined-selectable-macro/Macro_1.scala @@ -58,7 +58,7 @@ object Macro { def extractTuple(tpe: TypeRepr, seen: Set[String]): (Set[String], (String, TypeRepr)) = { tpe match { // Tuple2(S, T) where S must be a constant string type - case AppliedType(parent, ConstantType(Constant.String(name)) :: (info: TypeRepr) :: Nil) if (parent.typeSymbol == defn.TupleClass(2)) => + case AppliedType(parent, ConstantType(StringConstant(name)) :: (info: TypeRepr) :: Nil) if (parent.typeSymbol == defn.TupleClass(2)) => if seen(name) then report.error(s"Repeated record name: $name", s) (seen + name, (name, info)) diff --git a/tests/run-macros/tasty-argument-tree-1.check b/tests/run-macros/tasty-argument-tree-1.check index b813a59e5244..f2214edff74e 100644 --- a/tests/run-macros/tasty-argument-tree-1.check +++ b/tests/run-macros/tasty-argument-tree-1.check @@ -1,15 +1,15 @@ -tree: Inlined(None, Nil, Literal(Constant.Int(3))) -tree deref. vals: Literal(Constant.Int(3)) +tree: Inlined(None, Nil, Literal(IntConstant(3))) +tree deref. vals: Literal(IntConstant(3)) tree: Inlined(None, Nil, Ident("v")) -tree deref. vals: Literal(Constant.Int(1)) +tree deref. vals: Literal(IntConstant(1)) tree: Inlined(None, Nil, Ident("x$proxy1")) -tree deref. vals: Literal(Constant.Int(2)) +tree deref. vals: Literal(IntConstant(2)) tree: Inlined(None, Nil, Ident("l")) -tree deref. vals: Literal(Constant.Int(3)) +tree deref. vals: Literal(IntConstant(3)) tree: Inlined(None, Nil, Ident("a")) tree deref. vals: Ident("a") @@ -21,22 +21,22 @@ tree: Inlined(None, Nil, Ident("x$proxy3")) tree deref. vals: Apply(Ident("d2"), Nil) tree: Inlined(None, Nil, Ident("x$proxy4")) -tree deref. vals: Apply(Ident("d3"), List(Literal(Constant.Int(3)))) +tree deref. vals: Apply(Ident("d3"), List(Literal(IntConstant(3)))) tree: Inlined(None, Nil, Ident("x$proxy5")) tree deref. vals: TypeApply(Ident("d4"), List(TypeIdent("Int"))) tree: Inlined(None, Nil, Ident("vv")) -tree deref. vals: Literal(Constant.Int(1)) +tree deref. vals: Literal(IntConstant(1)) tree: Inlined(None, Nil, Ident("x$proxy6")) -tree deref. vals: Literal(Constant.Int(1)) +tree deref. vals: Literal(IntConstant(1)) tree: Inlined(None, Nil, Ident("vd")) -tree deref. vals: Literal(Constant.Int(2)) +tree deref. vals: Literal(IntConstant(2)) tree: Inlined(None, Nil, Ident("x$proxy7")) -tree deref. vals: Literal(Constant.Int(2)) +tree deref. vals: Literal(IntConstant(2)) tree: Inlined(None, Nil, Ident("x$proxy8")) -tree deref. vals: Apply(TypeApply(Select(Ident("Tuple2"), "apply"), List(Inferred(), Inferred())), List(Literal(Constant.Int(1)), Literal(Constant.Int(2)))) +tree deref. vals: Apply(TypeApply(Select(Ident("Tuple2"), "apply"), List(Inferred(), Inferred())), List(Literal(IntConstant(1)), Literal(IntConstant(2)))) diff --git a/tests/run-macros/tasty-construct-types/Macro_1.scala b/tests/run-macros/tasty-construct-types/Macro_1.scala index f883a6e2ba8b..41ca8a3c78df 100644 --- a/tests/run-macros/tasty-construct-types/Macro_1.scala +++ b/tests/run-macros/tasty-construct-types/Macro_1.scala @@ -13,9 +13,9 @@ object Macros { def theTestBlockImpl(using qctx : Quotes) : Expr[Unit] = { import quotes.reflect._ - val x1T = ConstantType(Constant.Int(1)) - val x2T = OrType(ConstantType(Constant.Int(1)), ConstantType(Constant.Int(2))) - val x3T = AndType(ConstantType(Constant.Int(3)), TypeRepr.of[Any]) + val x1T = ConstantType(IntConstant(1)) + val x2T = OrType(ConstantType(IntConstant(1)), ConstantType(IntConstant(2))) + val x3T = AndType(ConstantType(IntConstant(3)), TypeRepr.of[Any]) val x4T = TypeLambda( List("A","B"), @@ -27,7 +27,7 @@ object Macros { "T", TypeBounds(TypeRepr.of[Int], TypeRepr.of[Int])) val x6T = TypeRepr.of[List].appliedTo(List(TypeRepr.of[Int])) - val x7T = AnnotatedType(ConstantType(Constant.Int(7)), '{ new TestAnnotation }.asTerm) + val x7T = AnnotatedType(ConstantType(IntConstant(7)), '{ new TestAnnotation }.asTerm) val x8T = MatchType( TypeRepr.of[Int], diff --git a/tests/run-macros/tasty-create-method-symbol/Macro_1.scala b/tests/run-macros/tasty-create-method-symbol/Macro_1.scala index eec0fa7147d2..07345177c562 100644 --- a/tests/run-macros/tasty-create-method-symbol/Macro_1.scala +++ b/tests/run-macros/tasty-create-method-symbol/Macro_1.scala @@ -23,7 +23,7 @@ object Macros { Some('{ ${ a.asExpr.asInstanceOf[Expr[Int]] } - ${ b.asExpr.asInstanceOf[Expr[Int]] } }.asTerm) } }), - '{ assert(${ Apply(Ref(sym1), List(Literal(Constant.Int(2)), Literal(Constant.Int(3)))).asExpr.asInstanceOf[Expr[Int]] } == -1) }.asTerm) + '{ assert(${ Apply(Ref(sym1), List(Literal(IntConstant(2)), Literal(IntConstant(3)))).asExpr.asInstanceOf[Expr[Int]] } == -1) }.asTerm) // test for no argument list (no Apply node) val sym2 : Symbol = Symbol.newMethod( @@ -36,7 +36,7 @@ object Macros { DefDef(sym2, { case List() => { case List() => - Some(Literal(Constant.Int(2))) + Some(Literal(IntConstant(2))) } }), '{ assert(${ Ref(sym2).asExpr.asInstanceOf[Expr[Int]] } == 2) }.asTerm) @@ -59,7 +59,7 @@ object Macros { Some(a) } }), - '{ assert(${ Apply(Apply(Ref(sym3), List(Literal(Constant.Int(3)))), List(Literal(Constant.Int(3)))).asExpr.asInstanceOf[Expr[Int]] } == 3) }.asTerm) + '{ assert(${ Apply(Apply(Ref(sym3), List(Literal(IntConstant(3)))), List(Literal(IntConstant(3)))).asExpr.asInstanceOf[Expr[Int]] } == 3) }.asTerm) // test for recursive references val sym4 : Symbol = Symbol.newMethod( @@ -81,7 +81,7 @@ object Macros { }.asTerm) } }), - '{ assert(${ Apply(Ref(sym4), List(Literal(Constant.Int(4)))).asExpr.asInstanceOf[Expr[Int]] } == 0) }.asTerm) + '{ assert(${ Apply(Ref(sym4), List(Literal(IntConstant(4)))).asExpr.asInstanceOf[Expr[Int]] } == 0) }.asTerm) // test for nested functions (one symbol is the other's parent, and we use a Closure) val sym5 : Symbol = Symbol.newMethod( @@ -115,7 +115,7 @@ object Macros { } } }), - '{ assert(${ Apply(Ref(sym5), List(Literal(Constant.Int(5)))).asExpr.asInstanceOf[Expr[Int=>Int]] }(4) == 1) }.asTerm) + '{ assert(${ Apply(Ref(sym5), List(Literal(IntConstant(5)))).asExpr.asInstanceOf[Expr[Int=>Int]] }(4) == 1) }.asTerm) // test mutually recursive definitions val sym6_1 : Symbol = Symbol.newMethod( @@ -162,7 +162,7 @@ object Macros { } }), - '{ assert(${ Apply(Ref(sym6_2), List(Literal(Constant.Int(6)))).asExpr.asInstanceOf[Expr[Int]] } == 0) }.asTerm) + '{ assert(${ Apply(Ref(sym6_2), List(Literal(IntConstant(6)))).asExpr.asInstanceOf[Expr[Int]] } == 0) }.asTerm) // test polymorphic methods by synthesizing an identity method val sym7 : Symbol = Symbol.newMethod( @@ -182,7 +182,7 @@ object Macros { Some(Typed(x, Inferred(t))) } }), - '{ assert(${ Apply(TypeApply(Ref(sym7), List(Inferred(TypeRepr.of[Int]))), List(Literal(Constant.Int(7)))).asExpr.asInstanceOf[Expr[Int]] } == 7) }.asTerm) + '{ assert(${ Apply(TypeApply(Ref(sym7), List(Inferred(TypeRepr.of[Int]))), List(Literal(IntConstant(7)))).asExpr.asInstanceOf[Expr[Int]] } == 7) }.asTerm) Block( sym1Statements ++ @@ -193,7 +193,7 @@ object Macros { sym6Statements ++ sym7Statements ++ List('{ println("Ok") }.asTerm), - Literal(Constant.Unit())).asExpr.asInstanceOf[Expr[Unit]] + Literal(UnitConstant())).asExpr.asInstanceOf[Expr[Unit]] } } diff --git a/tests/run-macros/tasty-eval/quoted_1.scala b/tests/run-macros/tasty-eval/quoted_1.scala index a6872ae6393c..b8af0ac99d63 100644 --- a/tests/run-macros/tasty-eval/quoted_1.scala +++ b/tests/run-macros/tasty-eval/quoted_1.scala @@ -24,10 +24,10 @@ object Macros { pre.termSymbol.tree match case t: ValDef => t.tpt.tpe match { - case ConstantType(Constant.Int(i)) => Some(i) + case ConstantType(IntConstant(i)) => Some(i) case _ => None } - case ConstantType(Constant.Int(i)) => Some(i) + case ConstantType(IntConstant(i)) => Some(i) case _ => None } } diff --git a/tests/run-macros/tasty-extractors-1.check b/tests/run-macros/tasty-extractors-1.check index 2c11ae106d01..7d8d642dad85 100644 --- a/tests/run-macros/tasty-extractors-1.check +++ b/tests/run-macros/tasty-extractors-1.check @@ -1,120 +1,120 @@ -Inlined(None, Nil, Literal(Constant.Boolean(true))) -ConstantType(Constant.Boolean(true)) +Inlined(None, Nil, Literal(BooleanConstant(true))) +ConstantType(BooleanConstant(true)) -Inlined(None, Nil, Literal(Constant.Int(1))) -ConstantType(Constant.Int(1)) +Inlined(None, Nil, Literal(IntConstant(1))) +ConstantType(IntConstant(1)) -Inlined(None, Nil, Literal(Constant.Long(2L))) -ConstantType(Constant.Long(2L)) +Inlined(None, Nil, Literal(LongConstant(2L))) +ConstantType(LongConstant(2L)) -Inlined(None, Nil, Literal(Constant.Float(2.1f))) -ConstantType(Constant.Float(2.1f)) +Inlined(None, Nil, Literal(FloatConstant(2.1f))) +ConstantType(FloatConstant(2.1f)) -Inlined(None, Nil, Literal(Constant.Double(2.2d))) -ConstantType(Constant.Double(2.2d)) +Inlined(None, Nil, Literal(DoubleConstant(2.2d))) +ConstantType(DoubleConstant(2.2d)) -Inlined(None, Nil, Literal(Constant.String("abc"))) -ConstantType(Constant.String("abc")) +Inlined(None, Nil, Literal(StringConstant("abc"))) +ConstantType(StringConstant("abc")) -Inlined(None, Nil, Apply(Ident("println"), List(Literal(Constant.String("abc"))))) +Inlined(None, Nil, Apply(Ident("println"), List(Literal(StringConstant("abc"))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Typed(Literal(Constant.Int(8)), TypeIdent("Int"))) +Inlined(None, Nil, Typed(Literal(IntConstant(8)), TypeIdent("Int"))) TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "")), "scala"), "Int") -Inlined(None, Nil, Typed(Literal(Constant.Byte(8)), TypeIdent("Byte"))) +Inlined(None, Nil, Typed(Literal(ByteConstant(8)), TypeIdent("Byte"))) TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "")), "scala"), "Byte") -Inlined(None, Nil, Typed(Literal(Constant.Short(8)), TypeIdent("Short"))) +Inlined(None, Nil, Typed(Literal(ShortConstant(8)), TypeIdent("Short"))) TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "")), "scala"), "Short") -Inlined(None, Nil, Literal(Constant.Char('a'))) -ConstantType(Constant.Char('a')) +Inlined(None, Nil, Literal(CharConstant('a'))) +ConstantType(CharConstant('a')) -Inlined(None, Nil, Block(List(Literal(Constant.Int(1)), Literal(Constant.Int(2))), Literal(Constant.Int(3)))) -ConstantType(Constant.Int(3)) +Inlined(None, Nil, Block(List(Literal(IntConstant(1)), Literal(IntConstant(2))), Literal(IntConstant(3)))) +ConstantType(IntConstant(3)) -Inlined(None, Nil, If(Typed(Literal(Constant.Boolean(true)), TypeIdent("Boolean")), Literal(Constant.Int(1)), Literal(Constant.Int(2)))) -OrType(ConstantType(Constant.Int(1)), ConstantType(Constant.Int(2))) +Inlined(None, Nil, If(Typed(Literal(BooleanConstant(true)), TypeIdent("Boolean")), Literal(IntConstant(1)), Literal(IntConstant(2)))) +OrType(ConstantType(IntConstant(1)), ConstantType(IntConstant(2))) -Inlined(None, Nil, Match(Literal(Constant.String("a")), List(CaseDef(Literal(Constant.String("a")), None, Block(Nil, Literal(Constant.Unit())))))) +Inlined(None, Nil, Match(Literal(StringConstant("a")), List(CaseDef(Literal(StringConstant("a")), None, Block(Nil, Literal(UnitConstant())))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Match(Literal(Constant.String("b")), List(CaseDef(Bind("n", Ident("_")), None, Block(Nil, Literal(Constant.Unit())))))) +Inlined(None, Nil, Match(Literal(StringConstant("b")), List(CaseDef(Bind("n", Ident("_")), None, Block(Nil, Literal(UnitConstant())))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Match(Literal(Constant.String("c")), List(CaseDef(Bind("n", Typed(Ident("_"), TypeIdent("String"))), None, Block(Nil, Literal(Constant.Unit())))))) +Inlined(None, Nil, Match(Literal(StringConstant("c")), List(CaseDef(Bind("n", Typed(Ident("_"), TypeIdent("String"))), None, Block(Nil, Literal(UnitConstant())))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Match(Literal(Constant.String("e")), List(CaseDef(Ident("_"), None, Block(Nil, Literal(Constant.Unit())))))) +Inlined(None, Nil, Match(Literal(StringConstant("e")), List(CaseDef(Ident("_"), None, Block(Nil, Literal(UnitConstant())))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Match(Literal(Constant.String("f")), List(CaseDef(Typed(Ident("_"), TypeIdent("String")), None, Block(Nil, Literal(Constant.Unit())))))) +Inlined(None, Nil, Match(Literal(StringConstant("f")), List(CaseDef(Typed(Ident("_"), TypeIdent("String")), None, Block(Nil, Literal(UnitConstant())))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Match(Typed(Literal(Constant.String("g")), TypeIdent("Any")), List(CaseDef(Alternative(List(Typed(Ident("_"), TypeIdent("String")), Typed(Ident("_"), TypeIdent("Int")))), None, Block(Nil, Literal(Constant.Unit())))))) +Inlined(None, Nil, Match(Typed(Literal(StringConstant("g")), TypeIdent("Any")), List(CaseDef(Alternative(List(Typed(Ident("_"), TypeIdent("String")), Typed(Ident("_"), TypeIdent("Int")))), None, Block(Nil, Literal(UnitConstant())))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Match(Literal(Constant.String("h")), List(CaseDef(Ident("_"), Some(Literal(Constant.Boolean(false))), Block(Nil, Literal(Constant.Unit())))))) +Inlined(None, Nil, Match(Literal(StringConstant("h")), List(CaseDef(Ident("_"), Some(Literal(BooleanConstant(false))), Block(Nil, Literal(UnitConstant())))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ValDef("a", Inferred(), Some(Literal(Constant.String("o"))))), Match(Literal(Constant.String("i")), List(CaseDef(Bind("a", Ident("_")), None, Block(Nil, Literal(Constant.Unit()))))))) +Inlined(None, Nil, Block(List(ValDef("a", Inferred(), Some(Literal(StringConstant("o"))))), Match(Literal(StringConstant("i")), List(CaseDef(Bind("a", Ident("_")), None, Block(Nil, Literal(UnitConstant()))))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Match(Ident("Nil"), List(CaseDef(Unapply(TypeApply(Select(Ident("List"), "unapplySeq"), List(Inferred())), Nil, List(Bind("a", Ident("_")), Bind("b", Ident("_")), Bind("c", Ident("_")))), None, Block(Nil, Literal(Constant.Unit())))))) +Inlined(None, Nil, Match(Ident("Nil"), List(CaseDef(Unapply(TypeApply(Select(Ident("List"), "unapplySeq"), List(Inferred())), Nil, List(Bind("a", Ident("_")), Bind("b", Ident("_")), Bind("c", Ident("_")))), None, Block(Nil, Literal(UnitConstant())))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Try(Literal(Constant.Int(1)), List(CaseDef(Ident("_"), None, Block(Nil, Literal(Constant.Unit())))), None)) -OrType(ConstantType(Constant.Int(1)), TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit")) +Inlined(None, Nil, Try(Literal(IntConstant(1)), List(CaseDef(Ident("_"), None, Block(Nil, Literal(UnitConstant())))), None)) +OrType(ConstantType(IntConstant(1)), TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit")) -Inlined(None, Nil, Try(Literal(Constant.Int(2)), Nil, Some(Literal(Constant.Unit())))) -ConstantType(Constant.Int(2)) +Inlined(None, Nil, Try(Literal(IntConstant(2)), Nil, Some(Literal(UnitConstant())))) +ConstantType(IntConstant(2)) -Inlined(None, Nil, Try(Literal(Constant.Int(3)), List(CaseDef(Ident("_"), None, Block(Nil, Literal(Constant.Unit())))), Some(Literal(Constant.Unit())))) -OrType(ConstantType(Constant.Int(3)), TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit")) +Inlined(None, Nil, Try(Literal(IntConstant(3)), List(CaseDef(Ident("_"), None, Block(Nil, Literal(UnitConstant())))), Some(Literal(UnitConstant())))) +OrType(ConstantType(IntConstant(3)), TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit")) -Inlined(None, Nil, Apply(Select(Literal(Constant.String("a")), "=="), List(Literal(Constant.String("b"))))) +Inlined(None, Nil, Apply(Select(Literal(StringConstant("a")), "=="), List(Literal(StringConstant("b"))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Boolean") Inlined(None, Nil, Apply(Select(New(TypeIdent("Object")), ""), Nil)) TypeRef(ThisType(TypeRef(NoPrefix(), "lang")), "Object") -Inlined(None, Nil, Apply(Select(Ident("Int"), "box"), List(NamedArg("x", Literal(Constant.Int(9)))))) +Inlined(None, Nil, Apply(Select(Ident("Int"), "box"), List(NamedArg("x", Literal(IntConstant(9)))))) TypeRef(ThisType(TypeRef(NoPrefix(), "lang")), "Integer") Inlined(None, Nil, Apply(TypeApply(Select(Ident("Ordering"), "apply"), List(TypeIdent("Int"))), List(Ident("Int")))) AppliedType(TypeRef(ThisType(TypeRef(NoPrefix(), "math")), "Ordering"), List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "")), "scala"), "Int"))) -Inlined(None, Nil, Block(List(ValDef("a", TypeIdent("Int"), Some(Literal(Constant.Int(3))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ValDef("a", TypeIdent("Int"), Some(Literal(IntConstant(3))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ValDef("b", TypeIdent("Int"), Some(Literal(Constant.Int(3))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ValDef("b", TypeIdent("Int"), Some(Literal(IntConstant(3))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f1", Nil, Nil, TypeIdent("Int"), Some(Literal(Constant.Int(3))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(DefDef("f1", Nil, Nil, TypeIdent("Int"), Some(Literal(IntConstant(3))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f2", Nil, Nil, TypeIdent("Int"), Some(Return(Literal(Constant.Int(4)), IsDefDefSymbol())))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(DefDef("f2", Nil, Nil, TypeIdent("Int"), Some(Return(Literal(IntConstant(4)), IsDefDefSymbol())))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f3", Nil, List(List(ValDef("i", TypeIdent("Int"), None))), TypeIdent("Int"), Some(Ident("i")))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(DefDef("f3", Nil, List(List(ValDef("i", TypeIdent("Int"), None))), TypeIdent("Int"), Some(Ident("i")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f4", Nil, List(List(ValDef("i", TypeIdent("Int"), None)), List(ValDef("j", TypeIdent("Int"), None))), TypeIdent("Int"), Some(Apply(Select(Ident("i"), "+"), List(Ident("j")))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(DefDef("f4", Nil, List(List(ValDef("i", TypeIdent("Int"), None)), List(ValDef("j", TypeIdent("Int"), None))), TypeIdent("Int"), Some(Apply(Select(Ident("i"), "+"), List(Ident("j")))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f5", Nil, List(List(ValDef("i", TypeIdent("Int"), None))), TypeIdent("Int"), Some(Ident("i"))), DefDef("f5$default$1", Nil, Nil, Inferred(), Some(Literal(Constant.Int(9))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(DefDef("f5", Nil, List(List(ValDef("i", TypeIdent("Int"), None))), TypeIdent("Int"), Some(Ident("i"))), DefDef("f5$default$1", Nil, Nil, Inferred(), Some(Literal(IntConstant(9))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f6", List(TypeDef("T", TypeBoundsTree(Inferred(), Inferred()))), List(List(ValDef("x", TypeIdent("T"), None))), TypeIdent("T"), Some(Ident("x")))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(DefDef("f6", List(TypeDef("T", TypeBoundsTree(Inferred(), Inferred()))), List(List(ValDef("x", TypeIdent("T"), None))), TypeIdent("T"), Some(Ident("x")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f7", List(TypeDef("T", TypeBoundsTree(Inferred(), Inferred()))), List(List(ValDef("x", TypeIdent("T"), None))), Singleton(Ident("x")), Some(Ident("x")))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(DefDef("f7", List(TypeDef("T", TypeBoundsTree(Inferred(), Inferred()))), List(List(ValDef("x", TypeIdent("T"), None))), Singleton(Ident("x")), Some(Ident("x")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f8", Nil, List(List(ValDef("i", Annotated(Applied(Inferred(), List(TypeIdent("Int"))), Apply(Select(New(Inferred()), ""), Nil)), None))), TypeIdent("Int"), Some(Literal(Constant.Int(9))))), Apply(Ident("f8"), List(Typed(Repeated(List(Literal(Constant.Int(1)), Literal(Constant.Int(2)), Literal(Constant.Int(3))), Inferred()), Inferred()))))) +Inlined(None, Nil, Block(List(DefDef("f8", Nil, List(List(ValDef("i", Annotated(Applied(Inferred(), List(TypeIdent("Int"))), Apply(Select(New(Inferred()), ""), Nil)), None))), TypeIdent("Int"), Some(Literal(IntConstant(9))))), Apply(Ident("f8"), List(Typed(Repeated(List(Literal(IntConstant(1)), Literal(IntConstant(2)), Literal(IntConstant(3))), Inferred()), Inferred()))))) TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "")), "scala"), "Int") -Inlined(None, Nil, Block(List(DefDef("f9", Nil, List(List(ValDef("i", ByName(TypeIdent("Int")), None))), TypeIdent("Int"), Some(Ident("i")))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(DefDef("f9", Nil, List(List(ValDef("i", ByName(TypeIdent("Int")), None))), TypeIdent("Int"), Some(Ident("i")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") diff --git a/tests/run-macros/tasty-extractors-2.check b/tests/run-macros/tasty-extractors-2.check index a4301fba7cb8..6a8173dd5571 100644 --- a/tests/run-macros/tasty-extractors-2.check +++ b/tests/run-macros/tasty-extractors-2.check @@ -1,4 +1,4 @@ -Inlined(None, Nil, Block(List(ValDef("x", Inferred(), Some(Literal(Constant.Int(1))))), Assign(Ident("x"), Literal(Constant.Int(2))))) +Inlined(None, Nil, Block(List(ValDef("x", Inferred(), Some(Literal(IntConstant(1))))), Assign(Ident("x"), Literal(IntConstant(2))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") Inlined(None, Nil, Block(List(DefDef("$anonfun", Nil, List(List(ValDef("x", TypeIdent("Int"), None))), Inferred(), Some(Ident("x")))), Closure(Ident("$anonfun"), None))) @@ -7,10 +7,10 @@ AppliedType(TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Function1"), List(T Inlined(None, Nil, Ident("???")) TermRef(TermRef(ThisType(TypeRef(NoPrefix(), "scala")), "Predef"), "???") -Inlined(None, Nil, Literal(Constant.Int(1))) -ConstantType(Constant.Int(1)) +Inlined(None, Nil, Literal(IntConstant(1))) +ConstantType(IntConstant(1)) -Inlined(None, Nil, Typed(Literal(Constant.Int(1)), TypeIdent("Int"))) +Inlined(None, Nil, Typed(Literal(IntConstant(1)), TypeIdent("Int"))) TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "")), "scala"), "Int") Inlined(None, Nil, Typed(Ident("Nil"), Applied(TypeIdent("List"), List(TypeIdent("Int"))))) @@ -19,87 +19,87 @@ AppliedType(TypeRef(ThisType(TypeRef(NoPrefix(), "immutable")), "List"), List(Ty Inlined(None, Nil, Typed(Apply(Select(New(TypeIdent("Baz")), ""), Nil), Applied(TypeIdent("&"), List(TypeIdent("Foo"), TypeIdent("Bar"))))) AndType(TypeRef(ThisType(TypeRef(NoPrefix(), "")), "Foo"), TypeRef(ThisType(TypeRef(NoPrefix(), "")), "Bar")) -Inlined(None, Nil, Typed(Literal(Constant.Int(1)), Applied(TypeIdent("|"), List(TypeIdent("Int"), TypeIdent("String"))))) +Inlined(None, Nil, Typed(Literal(IntConstant(1)), Applied(TypeIdent("|"), List(TypeIdent("Int"), TypeIdent("String"))))) OrType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "")), "scala"), "Int"), TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "scala")), "Predef"), "String")) -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, Nil)), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, Nil)), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ValDef("Foo", TypeIdent("Foo$"), Some(Apply(Select(New(TypeIdent("Foo$")), ""), Nil))), ClassDef("Foo$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo")), None)), Nil)), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ValDef("Foo", TypeIdent("Foo$"), Some(Apply(Select(New(TypeIdent("Foo$")), ""), Nil))), ClassDef("Foo$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo")), None)), Nil)), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(TypeDef("Foo", TypeBoundsTree(Inferred(), Inferred()))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(TypeDef("Foo", TypeBoundsTree(Inferred(), Inferred()))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(TypeDef("Foo", TypeIdent("Int"))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(TypeDef("Foo", TypeIdent("Int"))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(TypeDef("Foo", TypeBoundsTree(TypeIdent("Null"), TypeIdent("Object")))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(TypeDef("Foo", TypeBoundsTree(TypeIdent("Null"), TypeIdent("Object")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(Constant.Int(0)))), DefDef("a_=", Nil, List(List(ValDef("x$1", Inferred(), None))), Inferred(), Some(Literal(Constant.Unit())))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(0)))), DefDef("a_=", Nil, List(List(ValDef("x$1", Inferred(), None))), Inferred(), Some(Literal(UnitConstant())))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, Inferred(), Some(Literal(Constant.Int(0))))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, Inferred(), Some(Literal(IntConstant(0))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, Inferred(), Some(Literal(Constant.Int(0))))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, Inferred(), Some(Literal(IntConstant(0))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, Inferred(), Some(Literal(Constant.Int(0))))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, Inferred(), Some(Literal(IntConstant(0))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil), TypeSelect(Select(Ident("_root_"), "scala"), "Product"), TypeSelect(Select(Ident("_root_"), "scala"), "Serializable")), Nil, None, List(DefDef("copy", Nil, List(Nil), Inferred(), Some(Apply(Select(New(Inferred()), ""), Nil))))), ValDef("Foo", TypeIdent("Foo$"), Some(Apply(Select(New(TypeIdent("Foo$")), ""), Nil))), ClassDef("Foo$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo")), None)), List(DefDef("apply", Nil, List(Nil), Inferred(), Some(Apply(Select(New(Inferred()), ""), Nil))), DefDef("unapply", Nil, List(List(ValDef("x$1", Inferred(), None))), Singleton(Literal(Constant.Boolean(true))), Some(Literal(Constant.Boolean(true)))), DefDef("toString", Nil, Nil, Inferred(), Some(Literal(Constant.String("Foo"))))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil), TypeSelect(Select(Ident("_root_"), "scala"), "Product"), TypeSelect(Select(Ident("_root_"), "scala"), "Serializable")), Nil, None, List(DefDef("copy", Nil, List(Nil), Inferred(), Some(Apply(Select(New(Inferred()), ""), Nil))))), ValDef("Foo", TypeIdent("Foo$"), Some(Apply(Select(New(TypeIdent("Foo$")), ""), Nil))), ClassDef("Foo$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo")), None)), List(DefDef("apply", Nil, List(Nil), Inferred(), Some(Apply(Select(New(Inferred()), ""), Nil))), DefDef("unapply", Nil, List(List(ValDef("x$1", Inferred(), None))), Singleton(Literal(BooleanConstant(true))), Some(Literal(BooleanConstant(true)))), DefDef("toString", Nil, Nil, Inferred(), Some(Literal(StringConstant("Foo"))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo1", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None)))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo1", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None)))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo2", DefDef("", Nil, List(List(ValDef("b", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("b", Inferred(), None)))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo2", DefDef("", Nil, List(List(ValDef("b", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("b", Inferred(), None)))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo3", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None))), ValDef("Foo3", TypeIdent("Foo3$"), Some(Apply(Select(New(TypeIdent("Foo3$")), ""), Nil))), ClassDef("Foo3$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo3")), None)), List(DefDef("$lessinit$greater$default$1", Nil, Nil, Inferred(), Some(Literal(Constant.Int(5))))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo3", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None))), ValDef("Foo3", TypeIdent("Foo3$"), Some(Apply(Select(New(TypeIdent("Foo3$")), ""), Nil))), ClassDef("Foo3$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo3")), None)), List(DefDef("$lessinit$greater$default$1", Nil, Nil, Inferred(), Some(Literal(IntConstant(5))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo4", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None)), List(ValDef("b", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None)))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo4", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None)), List(ValDef("b", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None)))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo5", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None)), List(ValDef("b", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None))), ValDef("Foo5", TypeIdent("Foo5$"), Some(Apply(Select(New(TypeIdent("Foo5$")), ""), Nil))), ClassDef("Foo5$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo5")), None)), List(DefDef("$lessinit$greater$default$2", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), Some(Ident("a")))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo5", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None)), List(ValDef("b", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None))), ValDef("Foo5", TypeIdent("Foo5$"), Some(Apply(Select(New(TypeIdent("Foo5$")), ""), Nil))), ClassDef("Foo5$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo5")), None)), List(DefDef("$lessinit$greater$default$2", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), Some(Ident("a")))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo6", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None)), List(ValDef("b", Singleton(Ident("a")), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None)))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo6", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None)), List(ValDef("b", Singleton(Ident("a")), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None)))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo7", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), DefDef("", Nil, List(Nil), Inferred(), Some(Block(List(Apply(Select(This(Some("Foo7")), ""), List(Literal(Constant.Int(6))))), Literal(Constant.Unit()))))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo7", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), DefDef("", Nil, List(Nil), Inferred(), Some(Block(List(Apply(Select(This(Some("Foo7")), ""), List(Literal(IntConstant(6))))), Literal(UnitConstant()))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo8", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(Apply(Ident("println"), List(Literal(Constant.Int(0))))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo8", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(Apply(Ident("println"), List(Literal(IntConstant(0))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo10", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(Constant.Int(9))))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo10", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(9))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo11", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(Constant.Int(10)))), DefDef("a_=", Nil, List(List(ValDef("x$1", Inferred(), None))), Inferred(), Some(Literal(Constant.Unit())))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo11", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(10)))), DefDef("a_=", Nil, List(List(ValDef("x$1", Inferred(), None))), Inferred(), Some(Literal(UnitConstant())))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo12", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(Constant.Int(11))))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo12", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(11))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, Nil), ClassDef("Bar", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(TypeIdent("Foo")), ""), Nil)), Nil, None, Nil)), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, Nil), ClassDef("Bar", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(TypeIdent("Foo")), ""), Nil)), Nil, None, Nil)), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo2", DefDef("", Nil, List(Nil), Inferred(), None), List(Inferred()), Nil, None, Nil), ClassDef("Bar", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil), TypeIdent("Foo2")), Nil, None, Nil)), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo2", DefDef("", Nil, List(Nil), Inferred(), None), List(Inferred()), Nil, None, Nil), ClassDef("Bar", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil), TypeIdent("Foo2")), Nil, None, Nil)), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(List(ValDef("i", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("i", Inferred(), None))), ClassDef("Bar", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(TypeIdent("Foo")), ""), List(Literal(Constant.Int(1))))), Nil, None, Nil)), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(List(ValDef("i", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("i", Inferred(), None))), ClassDef("Bar", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(TypeIdent("Foo")), ""), List(Literal(IntConstant(1))))), Nil, None, Nil)), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(TypeDef("X", TypeIdent("Int")))), DefDef("f", Nil, List(List(ValDef("a", TypeIdent("Foo"), None))), TypeSelect(Ident("a"), "X"), Some(Ident("???")))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(TypeDef("X", TypeIdent("Int")))), DefDef("f", Nil, List(List(ValDef("a", TypeIdent("Foo"), None))), TypeSelect(Ident("a"), "X"), Some(Ident("???")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(TypeDef("X", TypeBoundsTree(Inferred(), Inferred())))), DefDef("f", Nil, List(List(ValDef("a", Refined(TypeIdent("Foo"), List(TypeDef("X", TypeIdent("Int")))), None))), TypeSelect(Ident("a"), "X"), Some(Ident("???")))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(TypeDef("X", TypeBoundsTree(Inferred(), Inferred())))), DefDef("f", Nil, List(List(ValDef("a", Refined(TypeIdent("Foo"), List(TypeDef("X", TypeIdent("Int")))), None))), TypeSelect(Ident("a"), "X"), Some(Ident("???")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ValDef("lambda", Applied(Inferred(), List(TypeIdent("Int"), TypeIdent("Int"))), Some(Block(List(DefDef("$anonfun", Nil, List(List(ValDef("x", Inferred(), None))), Inferred(), Some(Ident("x")))), Closure(Ident("$anonfun"), None))))), Literal(Constant.Unit()))) +Inlined(None, Nil, Block(List(ValDef("lambda", Applied(Inferred(), List(TypeIdent("Int"), TypeIdent("Int"))), Some(Block(List(DefDef("$anonfun", Nil, List(List(ValDef("x", Inferred(), None))), Inferred(), Some(Ident("x")))), Closure(Ident("$anonfun"), None))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") diff --git a/tests/run-macros/tasty-indexed-map/quoted_1.scala b/tests/run-macros/tasty-indexed-map/quoted_1.scala index 64e7472c3a7e..999d56f7f95e 100644 --- a/tests/run-macros/tasty-indexed-map/quoted_1.scala +++ b/tests/run-macros/tasty-indexed-map/quoted_1.scala @@ -28,7 +28,7 @@ object Index { import quotes.reflect._ def name(tp: TypeRepr): String = tp match { - case ConstantType(Constant.String(str)) => str + case ConstantType(StringConstant(str)) => str } def names(tp: TypeRepr): List[String] = tp match { diff --git a/tests/run-macros/tasty-interpolation-1/Macro.scala b/tests/run-macros/tasty-interpolation-1/Macro.scala index 349983a4c629..56e1e588bf64 100644 --- a/tests/run-macros/tasty-interpolation-1/Macro.scala +++ b/tests/run-macros/tasty-interpolation-1/Macro.scala @@ -59,7 +59,7 @@ abstract class MacroStringInterpolator[T] { strCtxExpr.asTerm.underlyingArgument match { case Select(Typed(Apply(_, List(Apply(_, List(Typed(Repeated(strCtxArgTrees, _), Inferred()))))), _), _) => val strCtxArgs = strCtxArgTrees.map { - case Literal(Constant.String(str)) => str + case Literal(StringConstant(str)) => str case tree => throw new NotStaticlyKnownError("Expected statically known StringContext", tree.asExpr) } StringContext(strCtxArgs: _*) diff --git a/tests/run-macros/tasty-macro-const/quoted_1.scala b/tests/run-macros/tasty-macro-const/quoted_1.scala index 0346248be16c..6f33602e4a48 100644 --- a/tests/run-macros/tasty-macro-const/quoted_1.scala +++ b/tests/run-macros/tasty-macro-const/quoted_1.scala @@ -8,7 +8,7 @@ object Macros { import quotes.reflect._ val xTree: Term = x.asTerm xTree match { - case Inlined(_, _, Literal(Constant.Int(n))) => + case Inlined(_, _, Literal(IntConstant(n))) => if (n <= 0) { report.error("Parameter must be natural number") '{0} diff --git a/tests/run-macros/tasty-overload-secondargs/Macro_1.scala b/tests/run-macros/tasty-overload-secondargs/Macro_1.scala index 8a5f805d1f0f..91c74945c92b 100644 --- a/tests/run-macros/tasty-overload-secondargs/Macro_1.scala +++ b/tests/run-macros/tasty-overload-secondargs/Macro_1.scala @@ -27,7 +27,7 @@ object Macro: val returnType = TypeRepr.of[(S) => ?] val firstPart = Select.overloaded(fun,"andThen", List(TypeIdent(defn.IntClass).tpe, TypeIdent(defn.IntClass).tpe), - List(Literal(Constant.Int(1))), + List(Literal(IntConstant(1))), TypeRepr.of[(S) => R] ) val r = Apply(firstPart,List(x.asTerm)) diff --git a/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala index d72697054e49..9a359bcfc661 100644 --- a/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala @@ -46,7 +46,7 @@ object XmlQuote { if isSCOpsConversion(conv) && isStringContextApply(fun) && values.forall(isStringConstant) => - values.collect { case Literal(Constant.String(value)) => value } + values.collect { case Literal(StringConstant(value)) => value } case tree => report.error(s"String literal expected, but ${tree.show(using Printer.TreeStructure)} found") return '{ ??? } diff --git a/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala index aa62800bdabd..47bb2b079548 100644 --- a/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala @@ -41,7 +41,7 @@ object XmlQuote { ctx1 match { case Apply(fun, List(Typed(Repeated(values, _), _))) if isStringContextApply(fun) => values.iterator.map { - case Literal(Constant.String(value)) => value + case Literal(StringConstant(value)) => value case _ => report.error("Expected statically known String") return '{???}