diff --git a/community-build/community-projects/PPrint b/community-build/community-projects/PPrint index 73353ed34649..4a135e4ad5ef 160000 --- a/community-build/community-projects/PPrint +++ b/community-build/community-projects/PPrint @@ -1 +1 @@ -Subproject commit 73353ed34649c24ed9c82da768c0391edc4faab6 +Subproject commit 4a135e4ad5ef5c3e9e2178f2b073db6ee2c6df13 diff --git a/community-build/community-projects/dotty-cps-async b/community-build/community-projects/dotty-cps-async index 5c05911ede2b..85c118605802 160000 --- a/community-build/community-projects/dotty-cps-async +++ b/community-build/community-projects/dotty-cps-async @@ -1 +1 @@ -Subproject commit 5c05911ede2beb05424b8008b43dd0ead4ee2a14 +Subproject commit 85c118605802eef925b1f56722eba29ecf5ae320 diff --git a/community-build/community-projects/munit b/community-build/community-projects/munit index daa6fc0959d6..1e90e9707e02 160000 --- a/community-build/community-projects/munit +++ b/community-build/community-projects/munit @@ -1 +1 @@ -Subproject commit daa6fc0959d64abcbff095290ba87e816557fe07 +Subproject commit 1e90e9707e02c41049489849dd0e002d48d4b498 diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index 0fbb5bf00de5..2b874f7aaaab 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit 0fbb5bf00de5af7cb63ae98987baff48bfd0c673 +Subproject commit 2b874f7aaaab4c567b12aa231ae104545ebf9e05 diff --git a/community-build/community-projects/shapeless b/community-build/community-projects/shapeless index dcf630b34913..3c11fae956e5 160000 --- a/community-build/community-projects/shapeless +++ b/community-build/community-projects/shapeless @@ -1 +1 @@ -Subproject commit dcf630b349135d189d5fa0b124911b917ee1d754 +Subproject commit 3c11fae956e5f12e2a69e4cdbf3b278b38bb689f diff --git a/community-build/community-projects/upickle b/community-build/community-projects/upickle index e425399f42eb..6016ebbf4990 160000 --- a/community-build/community-projects/upickle +++ b/community-build/community-projects/upickle @@ -1 +1 @@ -Subproject commit e425399f42eb505db92044053687c322bb5cfe5f +Subproject commit 6016ebbf49908409cb536edc3b2ed1f214fb6657 diff --git a/community-build/community-projects/utest b/community-build/community-projects/utest index 5a539e41507a..ce64e038ee8a 160000 --- a/community-build/community-projects/utest +++ b/community-build/community-projects/utest @@ -1 +1 @@ -Subproject commit 5a539e41507a93d9255f1954bde78edd1cd7561f +Subproject commit ce64e038ee8af4551a8b22ee9cec5d510be4ef67 diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index 5b7836580ed0..a53730def9dc 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit 5b7836580ed0473bf6a91360a76e306a3e7b0b96 +Subproject commit a53730def9dce4d44166f317b7cdcefb851644b3 diff --git a/community-build/sbt-scalajs-sbt b/community-build/sbt-scalajs-sbt new file mode 100644 index 000000000000..1a1034041a18 --- /dev/null +++ b/community-build/sbt-scalajs-sbt @@ -0,0 +1 @@ +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0") diff --git a/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala b/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala index 5bae0f258e30..6cd9bf41b6fd 100644 --- a/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala +++ b/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala @@ -88,6 +88,7 @@ class CommunityBuildTest: // @Test def dottyCpsAsync = projects.dottyCpsAsync.run() @Test def effpi = projects.effpi.run() @Test def endpoints4s = projects.endpoints4s.run() + @Test def fansi = projects.fansi.run() @Test def fastparse = projects.fastparse.run() @Test def geny = projects.geny.run() @Test def intent = projects.intent.run() @@ -95,6 +96,8 @@ class CommunityBuildTest: @Test def munit = projects.munit.run() @Test def oslib = projects.oslib.run() // @Test def oslibWatch = projects.oslibWatch.run() + @Test def pprint = projects.pprint.run() + @Test def requests = projects.requests.run() @Test def scalacheck = projects.scalacheck.run() @Test def scalap = projects.scalap.run() @Test def scalaParserCombinators = projects.scalaParserCombinators.run() @@ -114,9 +117,6 @@ class CommunityBuildTest: @Test def ujson = projects.ujson.run() @Test def upickle = projects.upickle.run() @Test def utest = projects.utest.run() - @Test def fansi = projects.fansi.run() - @Test def pprint = projects.pprint.run() - @Test def requests = projects.requests.run() @Test def xmlInterpolator = projects.xmlInterpolator.run() @Test def zio = projects.zio.run() end CommunityBuildTest diff --git a/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala b/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala index 60a946269d74..c8543f822688 100644 --- a/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala +++ b/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala @@ -214,7 +214,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end DefDefTypeTest object DefDef extends DefDefModule: - def apply(symbol: Symbol, rhsFn: List[Type] => List[List[Term]] => Option[Term]): DefDef = + def apply(symbol: Symbol, rhsFn: List[TypeRepr] => List[List[Term]] => Option[Term]): DefDef = withDefaultPos(tpd.polyDefDef(symbol.asTerm, tparams => vparamss => rhsFn(tparams)(vparamss).getOrElse(tpd.EmptyTree))) def copy(original: Tree)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term]): DefDef = tpd.cpy.DefDef(original)(name.toTermName, typeParams, paramss, tpt, rhs.getOrElse(tpd.EmptyTree)) @@ -319,7 +319,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: if self.isExpr then Some(new scala.internal.quoted.Expr(self, QuoteContextImpl.this.hashCode)) else None - def tpe: Type = self.tpe + def tpe: TypeRepr = self.tpe def underlyingArgument: Term = new tpd.TreeOps(self).underlyingArgument def underlying: Term = new tpd.TreeOps(self).underlying def etaExpand: Term = self.tpe.widen match { @@ -344,9 +344,9 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: argss.foldLeft(self: Term)(Apply(_, _)) def appliedToNone: Apply = self.appliedToArgs(Nil) - def appliedToType(targ: Type): Term = + def appliedToType(targ: TypeRepr): Term = self.appliedToTypes(targ :: Nil) - def appliedToTypes(targs: List[Type]): Term = + def appliedToTypes(targs: List[TypeRepr]): Term = self.appliedToTypeTrees(targs map (Inferred(_))) def appliedToTypeTrees(targs: List[TypeTree]): Term = if (targs.isEmpty) self else TypeApply(self, targs) @@ -412,10 +412,10 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: val denot = qualifier.tpe.member(name.toTermName) assert(!denot.isOverloaded, s"The symbol `$name` is overloaded. The method Select.unique can only be used for non-overloaded symbols.") withDefaultPos(tpd.Select(qualifier, name.toTermName)) - def overloaded(qualifier: Term, name: String, targs: List[Type], args: List[Term]): Apply = + def overloaded(qualifier: Term, name: String, targs: List[TypeRepr], args: List[Term]): Apply = withDefaultPos(tpd.applyOverloaded(qualifier, name.toTermName, args, targs, Types.WildcardType).asInstanceOf[Apply]) - - def overloaded(qualifier: Term, name: String, targs: List[Type], args: List[Term], returnType: Type): Apply = + + def overloaded(qualifier: Term, name: String, targs: List[TypeRepr], args: List[Term], returnType: TypeRepr): Apply = withDefaultPos(tpd.applyOverloaded(qualifier, name.toTermName, args, targs, returnType).asInstanceOf[Apply]) def copy(original: Tree)(qualifier: Term, name: String): Select = tpd.cpy.Select(original)(qualifier, name.toTermName) @@ -724,18 +724,18 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end ClosureTypeTest object Closure extends ClosureModule: - def apply(meth: Term, tpe: Option[Type]): Closure = + def apply(meth: Term, tpe: Option[TypeRepr]): Closure = withDefaultPos(tpd.Closure(Nil, meth, tpe.map(tpd.TypeTree(_)).getOrElse(tpd.EmptyTree))) - def copy(original: Tree)(meth: Tree, tpe: Option[Type]): Closure = + def copy(original: Tree)(meth: Tree, tpe: Option[TypeRepr]): Closure = tpd.cpy.Closure(original)(Nil, meth, tpe.map(tpd.TypeTree(_)).getOrElse(tpd.EmptyTree)) - def unapply(x: Closure): Option[(Term, Option[Type])] = + def unapply(x: Closure): Option[(Term, Option[TypeRepr])] = Some((x.meth, x.tpeOpt)) end Closure object ClosureMethodsImpl extends ClosureMethods: extension (self: Closure): def meth: Term = self.meth - def tpeOpt: Option[Type] = optional(self.tpt).map(_.tpe) + def tpeOpt: Option[TypeRepr] = optional(self.tpt).map(_.tpe) end extension end ClosureMethodsImpl @@ -997,7 +997,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: object TypeTreeMethodsImpl extends TypeTreeMethods: extension (self: TypeTree): - def tpe: Type = self.tpe.stripTypeVar + def tpe: TypeRepr = self.tpe.stripTypeVar end extension end TypeTreeMethodsImpl @@ -1011,7 +1011,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end InferredTypeTest object Inferred extends InferredModule: - def apply(tpe: Type): Inferred = + def apply(tpe: TypeRepr): Inferred = withDefaultPos(tpd.TypeTree(tpe)) def unapply(x: Inferred): Boolean = true end Inferred @@ -1353,7 +1353,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: object WildcardTypeTreeMethodsImpl extends WildcardTypeTreeMethods: extension (self: WildcardTypeTree): - def tpe: Type = self.tpe.stripTypeVar + def tpe: TypeRepr = self.tpe.stripTypeVar end extension end WildcardTypeTreeMethodsImpl @@ -1557,12 +1557,12 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end extension end OmitSelectorMethodsImpl - type Type = dotc.core.Types.Type + type TypeRepr = dotc.core.Types.Type - object Type extends TypeModule: - def of[T <: AnyKind](using qtype: scala.quoted.Type[T]): Type = + object TypeRepr extends TypeModule: + def of[T <: AnyKind](using qtype: scala.quoted.Type[T]): TypeRepr = qtype.asInstanceOf[scala.internal.quoted.Type[TypeTree]].typeTree.tpe - def typeConstructorOf(clazz: Class[?]): Type = + def typeConstructorOf(clazz: Class[?]): TypeRepr = if (clazz.isPrimitive) if (clazz == classOf[Boolean]) dotc.core.Symbols.defn.BooleanType else if (clazz == classOf[Byte]) dotc.core.Symbols.defn.ByteType @@ -1582,10 +1582,10 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: else enclosing.classSymbol.companionModule.termRef.select(name) else dotc.core.Symbols.getClassIfDefined(clazz.getCanonicalName).typeRef - end Type + end TypeRepr object TypeMethodsImpl extends TypeMethods: - extension (self: Type): + extension (self: TypeRepr): def showExtractors: String = new ExtractorsPrinter[reflect.type](reflect).showType(self) @@ -1598,22 +1598,22 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: def seal: scala.quoted.Type[_] = new scala.internal.quoted.Type(Inferred(self), QuoteContextImpl.this.hashCode) - def =:=(that: Type): Boolean = self =:= that - def <:<(that: Type): Boolean = self <:< that - def widen: Type = self.widen - def widenTermRefExpr: Type = self.widenTermRefExpr - def dealias: Type = self.dealias - def simplified: Type = self.simplified + def =:=(that: TypeRepr): Boolean = self =:= that + def <:<(that: TypeRepr): Boolean = self <:< that + def widen: TypeRepr = self.widen + def widenTermRefExpr: TypeRepr = self.widenTermRefExpr + def dealias: TypeRepr = self.dealias + def simplified: TypeRepr = self.simplified def classSymbol: Option[Symbol] = if self.classSymbol.exists then Some(self.classSymbol.asClass) else None def typeSymbol: Symbol = self.typeSymbol def termSymbol: Symbol = self.termSymbol def isSingleton: Boolean = self.isSingleton - def memberType(member: Symbol): Type = + def memberType(member: Symbol): TypeRepr = member.info.asSeenFrom(self, member.owner) def baseClasses: List[Symbol] = self.baseClasses - def baseType(cls: Symbol): Type = self.baseType(cls) + def baseType(cls: Symbol): TypeRepr = self.baseType(cls) def derivesFrom(cls: Symbol): Boolean = self.derivesFrom(cls) def isFunctionType: Boolean = dotc.core.Symbols.defn.isFunctionType(self) @@ -1625,17 +1625,17 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: val tpNoRefinement = self.dropDependentRefinement tpNoRefinement != self && dotc.core.Symbols.defn.isNonRefinedFunction(tpNoRefinement) - def select(sym: Symbol): Type = self.select(sym) - def appliedTo(targ: Type): Type = + def select(sym: Symbol): TypeRepr = self.select(sym) + def appliedTo(targ: TypeRepr): TypeRepr = dotc.core.Types.decorateTypeApplications(self).appliedTo(targ) - def appliedTo(targs: List[Type]): Type = + def appliedTo(targs: List[TypeRepr]): TypeRepr = dotc.core.Types.decorateTypeApplications(self).appliedTo(targs) end extension end TypeMethodsImpl type ConstantType = dotc.core.Types.ConstantType - object ConstantTypeTypeTest extends TypeTest[Type, ConstantType]: + object ConstantTypeTypeTest extends TypeTest[TypeRepr, ConstantType]: def runtimeClass: Class[?] = classOf[ConstantType] override def unapply(x: Any): Option[ConstantType] = x match case tpe: Types.ConstantType => Some(tpe) @@ -1653,7 +1653,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: type TermRef = dotc.core.Types.NamedType - object TermRefTypeTest extends TypeTest[Type, TermRef]: + object TermRefTypeTest extends TypeTest[TypeRepr, TermRef]: def runtimeClass: Class[?] = classOf[TermRef] override def unapply(x: Any): Option[TermRef] = x match case tp: Types.TermRef => Some(tp) @@ -1661,22 +1661,22 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end TermRefTypeTest object TermRef extends TermRefModule: - def apply(qual: Type, name: String): TermRef = + def apply(qual: TypeRepr, name: String): TermRef = Types.TermRef(qual, name.toTermName) - def unapply(x: TermRef): Option[(Type, String)] = + def unapply(x: TermRef): Option[(TypeRepr, String)] = Some((x.prefix, x.name.toString)) end TermRef object TermRefMethodsImpl extends TermRefMethods: extension (self: TermRef): - def qualifier: Type = self.prefix + def qualifier: TypeRepr = self.prefix def name: String = self.name.toString end extension end TermRefMethodsImpl type TypeRef = dotc.core.Types.NamedType - object TypeRefTypeTest extends TypeTest[Type, TypeRef]: + object TypeRefTypeTest extends TypeTest[TypeRepr, TypeRef]: def runtimeClass: Class[?] = classOf[TypeRef] override def unapply(x: Any): Option[TypeRef] = x match case tp: Types.TypeRef => Some(tp) @@ -1684,22 +1684,22 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end TypeRefTypeTest object TypeRef extends TypeRefModule: - def unapply(x: TypeRef): Option[(Type, String)] = + def unapply(x: TypeRef): Option[(TypeRepr, String)] = Some((x.prefix, x.name.toString)) end TypeRef object TypeRefMethodsImpl extends TypeRefMethods: extension (self: TypeRef): - def qualifier: Type = self.prefix + def qualifier: TypeRepr = self.prefix def name: String = self.name.toString def isOpaqueAlias: Boolean = self.symbol.isOpaqueAlias - def translucentSuperType: Type = self.translucentSuperType + def translucentSuperType: TypeRepr = self.translucentSuperType end extension end TypeRefMethodsImpl type SuperType = dotc.core.Types.SuperType - object SuperTypeTypeTest extends TypeTest[Type, SuperType]: + object SuperTypeTypeTest extends TypeTest[TypeRepr, SuperType]: def runtimeClass: Class[?] = classOf[SuperType] override def unapply(x: Any): Option[SuperType] = x match case tpe: Types.SuperType => Some(tpe) @@ -1707,22 +1707,22 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end SuperTypeTypeTest object SuperType extends SuperTypeModule: - def apply(thistpe: Type, supertpe: Type): SuperType = + def apply(thistpe: TypeRepr, supertpe: TypeRepr): SuperType = Types.SuperType(thistpe, supertpe) - def unapply(x: SuperType): Option[(Type, Type)] = + def unapply(x: SuperType): Option[(TypeRepr, TypeRepr)] = Some((x.thistpe, x.supertpe)) end SuperType object SuperTypeMethodsImpl extends SuperTypeMethods: extension (self: SuperType): - def thistpe: Type = self.thistpe - def supertpe: Type = self.thistpe + def thistpe: TypeRepr = self.thistpe + def supertpe: TypeRepr = self.thistpe end extension end SuperTypeMethodsImpl type Refinement = dotc.core.Types.RefinedType - object RefinementTypeTest extends TypeTest[Type, Refinement]: + object RefinementTypeTest extends TypeTest[TypeRepr, Refinement]: def runtimeClass: Class[?] = classOf[Refinement] override def unapply(x: Any): Option[Refinement] = x match case tpe: Types.RefinedType => Some(tpe) @@ -1730,27 +1730,27 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end RefinementTypeTest object Refinement extends RefinementModule: - def apply(parent: Type, name: String, info: Type): Refinement = + def apply(parent: TypeRepr, name: String, info: TypeRepr): Refinement = val name1 = info match case _: TypeBounds => name.toTypeName case _ => name.toTermName Types.RefinedType(parent, name1, info) - def unapply(x: Refinement): Option[(Type, String, Type)] = + def unapply(x: Refinement): Option[(TypeRepr, String, TypeRepr)] = Some((x.parent, x.name, x.info)) end Refinement object RefinementMethodsImpl extends RefinementMethods: extension (self: Refinement): - def parent: Type = self.parent + def parent: TypeRepr = self.parent def name: String = self.refinedName.toString - def info: Type = self.refinedInfo + def info: TypeRepr = self.refinedInfo end extension end RefinementMethodsImpl type AppliedType = dotc.core.Types.AppliedType - object AppliedTypeTypeTest extends TypeTest[Type, AppliedType]: + object AppliedTypeTypeTest extends TypeTest[TypeRepr, AppliedType]: def runtimeClass: Class[?] = classOf[AppliedType] override def unapply(x: Any): Option[AppliedType] = x match case tpe: Types.AppliedType => Some(tpe) @@ -1758,20 +1758,20 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end AppliedTypeTypeTest object AppliedType extends AppliedTypeModule: - def unapply(x: AppliedType): Option[(Type, List[Type])] = + def unapply(x: AppliedType): Option[(TypeRepr, List[TypeRepr])] = Some((x.tycon, x.args)) end AppliedType object AppliedTypeMethodsImpl extends AppliedTypeMethods: extension (self: AppliedType): - def tycon: Type = self.tycon - def args: List[Type] = self.args + def tycon: TypeRepr = self.tycon + def args: List[TypeRepr] = self.args end extension end AppliedTypeMethodsImpl type AnnotatedType = dotc.core.Types.AnnotatedType - object AnnotatedTypeTypeTest extends TypeTest[Type, AnnotatedType]: + object AnnotatedTypeTypeTest extends TypeTest[TypeRepr, AnnotatedType]: def runtimeClass: Class[?] = classOf[AnnotatedType] override def unapply(x: Any): Option[AnnotatedType] = x match case tpe: Types.AnnotatedType => Some(tpe) @@ -1779,22 +1779,22 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end AnnotatedTypeTypeTest object AnnotatedType extends AnnotatedTypeModule: - def apply(underlying: Type, annot: Term): AnnotatedType = + def apply(underlying: TypeRepr, annot: Term): AnnotatedType = Types.AnnotatedType(underlying, Annotations.Annotation(annot)) - def unapply(x: AnnotatedType): Option[(Type, Term)] = + def unapply(x: AnnotatedType): Option[(TypeRepr, Term)] = Some((x.underlying.stripTypeVar, x.annot.tree)) end AnnotatedType object AnnotatedTypeMethodsImpl extends AnnotatedTypeMethods: extension (self: AnnotatedType): - def underlying: Type = self.underlying.stripTypeVar + def underlying: TypeRepr = self.underlying.stripTypeVar def annot: Term = self.annot.tree end extension end AnnotatedTypeMethodsImpl type AndType = dotc.core.Types.AndType - object AndTypeTypeTest extends TypeTest[Type, AndType]: + object AndTypeTypeTest extends TypeTest[TypeRepr, AndType]: def runtimeClass: Class[?] = classOf[AndType] override def unapply(x: Any): Option[AndType] = x match case tpe: Types.AndType => Some(tpe) @@ -1802,20 +1802,20 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end AndTypeTypeTest object AndType extends AndTypeModule: - def apply(lhs: Type, rhs: Type): AndType = Types.AndType(lhs, rhs) - def unapply(x: AndType): Option[(Type, Type)] = Some((x.left, x.right)) + def apply(lhs: TypeRepr, rhs: TypeRepr): AndType = Types.AndType(lhs, rhs) + def unapply(x: AndType): Option[(TypeRepr, TypeRepr)] = Some((x.left, x.right)) end AndType object AndTypeMethodsImpl extends AndTypeMethods: extension (self: AndType): - def left: Type = self.tp1.stripTypeVar - def right: Type = self.tp2.stripTypeVar + def left: TypeRepr = self.tp1.stripTypeVar + def right: TypeRepr = self.tp2.stripTypeVar end extension end AndTypeMethodsImpl type OrType = dotc.core.Types.OrType - object OrTypeTypeTest extends TypeTest[Type, OrType]: + object OrTypeTypeTest extends TypeTest[TypeRepr, OrType]: def runtimeClass: Class[?] = classOf[OrType] override def unapply(x: Any): Option[OrType] = x match case tpe: Types.OrType => Some(tpe) @@ -1823,20 +1823,20 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end OrTypeTypeTest object OrType extends OrTypeModule: - def apply(lhs: Type, rhs: Type): OrType = Types.OrType(lhs, rhs) - def unapply(x: OrType): Option[(Type, Type)] = Some((x.left, x.right)) + def apply(lhs: TypeRepr, rhs: TypeRepr): OrType = Types.OrType(lhs, rhs) + def unapply(x: OrType): Option[(TypeRepr, TypeRepr)] = Some((x.left, x.right)) end OrType object OrTypeMethodsImpl extends OrTypeMethods: extension (self: OrType): - def left: Type = self.tp1.stripTypeVar - def right: Type = self.tp2.stripTypeVar + def left: TypeRepr = self.tp1.stripTypeVar + def right: TypeRepr = self.tp2.stripTypeVar end extension end OrTypeMethodsImpl type MatchType = dotc.core.Types.MatchType - object MatchTypeTypeTest extends TypeTest[Type, MatchType]: + object MatchTypeTypeTest extends TypeTest[TypeRepr, MatchType]: def runtimeClass: Class[?] = classOf[MatchType] override def unapply(x: Any): Option[MatchType] = x match case tpe: Types.MatchType => Some(tpe) @@ -1844,23 +1844,23 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end MatchTypeTypeTest object MatchType extends MatchTypeModule: - def apply(bound: Type, scrutinee: Type, cases: List[Type]): MatchType = + def apply(bound: TypeRepr, scrutinee: TypeRepr, cases: List[TypeRepr]): MatchType = Types.MatchType(bound, scrutinee, cases) - def unapply(x: MatchType): Option[(Type, Type, List[Type])] = + def unapply(x: MatchType): Option[(TypeRepr, TypeRepr, List[TypeRepr])] = Some((x.bound, x.scrutinee, x.cases)) end MatchType object MatchTypeMethodsImpl extends MatchTypeMethods: extension (self: MatchType): - def bound: Type = self.bound - def scrutinee: Type = self.scrutinee - def cases: List[Type] = self.cases + def bound: TypeRepr = self.bound + def scrutinee: TypeRepr = self.scrutinee + def cases: List[TypeRepr] = self.cases end extension end MatchTypeMethodsImpl type ByNameType = dotc.core.Types.ExprType - object ByNameTypeTypeTest extends TypeTest[Type, ByNameType]: + object ByNameTypeTypeTest extends TypeTest[TypeRepr, ByNameType]: def runtimeClass: Class[?] = classOf[ByNameType] override def unapply(x: Any): Option[ByNameType] = x match case tpe: Types.ExprType => Some(tpe) @@ -1868,19 +1868,19 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end ByNameTypeTypeTest object ByNameType extends ByNameTypeModule: - def apply(underlying: Type): Type = Types.ExprType(underlying) - def unapply(x: ByNameType): Option[Type] = Some(x.underlying) + def apply(underlying: TypeRepr): TypeRepr = Types.ExprType(underlying) + def unapply(x: ByNameType): Option[TypeRepr] = Some(x.underlying) end ByNameType object ByNameTypeMethodsImpl extends ByNameTypeMethods: extension (self: ByNameType): - def underlying: Type = self.resType.stripTypeVar + def underlying: TypeRepr = self.resType.stripTypeVar end extension end ByNameTypeMethodsImpl type ParamRef = dotc.core.Types.ParamRef - object ParamRefTypeTest extends TypeTest[Type, ParamRef]: + object ParamRefTypeTest extends TypeTest[TypeRepr, ParamRef]: def runtimeClass: Class[?] = classOf[ParamRef] override def unapply(x: Any): Option[ParamRef] = x match case tpe: Types.TypeParamRef => Some(tpe) @@ -1902,7 +1902,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: type ThisType = dotc.core.Types.ThisType - object ThisTypeTypeTest extends TypeTest[Type, ThisType]: + object ThisTypeTypeTest extends TypeTest[TypeRepr, ThisType]: def runtimeClass: Class[?] = classOf[ThisType] override def unapply(x: Any): Option[ThisType] = x match case tpe: Types.ThisType => Some(tpe) @@ -1910,18 +1910,18 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end ThisTypeTypeTest object ThisType extends ThisTypeModule: - def unapply(x: ThisType): Option[Type] = Some(x.tref) + def unapply(x: ThisType): Option[TypeRepr] = Some(x.tref) end ThisType object ThisTypeMethodsImpl extends ThisTypeMethods: extension (self: ThisType): - def tref: Type = self.tref + def tref: TypeRepr = self.tref end extension end ThisTypeMethodsImpl type RecursiveThis = dotc.core.Types.RecThis - object RecursiveThisTypeTest extends TypeTest[Type, RecursiveThis]: + object RecursiveThisTypeTest extends TypeTest[TypeRepr, RecursiveThis]: def runtimeClass: Class[?] = classOf[RecursiveThis] override def unapply(x: Any): Option[RecursiveThis] = x match case tpe: Types.RecThis => Some(tpe) @@ -1941,7 +1941,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: type RecursiveType = dotc.core.Types.RecType - object RecursiveTypeTypeTest extends TypeTest[Type, RecursiveType]: + object RecursiveTypeTypeTest extends TypeTest[TypeRepr, RecursiveType]: def runtimeClass: Class[?] = classOf[RecursiveType] override def unapply(x: Any): Option[RecursiveType] = x match case tpe: Types.RecType => Some(tpe) @@ -1949,14 +1949,14 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end RecursiveTypeTypeTest object RecursiveType extends RecursiveTypeModule: - def apply(parentExp: RecursiveType => Type): RecursiveType = + def apply(parentExp: RecursiveType => TypeRepr): RecursiveType = Types.RecType(parentExp) - def unapply(x: RecursiveType): Option[Type] = Some(x.underlying) + def unapply(x: RecursiveType): Option[TypeRepr] = Some(x.underlying) end RecursiveType object RecursiveTypeMethodsImpl extends RecursiveTypeMethods: extension (self: RecursiveType): - def underlying: Type = self.underlying.stripTypeVar + def underlying: TypeRepr = self.underlying.stripTypeVar def recThis: RecursiveThis = self.recThis end extension end RecursiveTypeMethodsImpl @@ -1965,7 +1965,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: type MethodType = dotc.core.Types.MethodType - object MethodTypeTypeTest extends TypeTest[Type, MethodType]: + object MethodTypeTypeTest extends TypeTest[TypeRepr, MethodType]: def runtimeClass: Class[?] = classOf[MethodType] override def unapply(x: Any): Option[MethodType] = x match case tpe: Types.MethodType => Some(tpe) @@ -1973,9 +1973,9 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end MethodTypeTypeTest object MethodType extends MethodTypeModule: - def apply(paramNames: List[String])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type): MethodType = + def apply(paramNames: List[String])(paramInfosExp: MethodType => List[TypeRepr], resultTypeExp: MethodType => TypeRepr): MethodType = Types.MethodType(paramNames.map(_.toTermName))(paramInfosExp, resultTypeExp) - def unapply(x: MethodType): Option[(List[String], List[Type], Type)] = + def unapply(x: MethodType): Option[(List[String], List[TypeRepr], TypeRepr)] = Some((x.paramNames.map(_.toString), x.paramTypes, x.resType)) end MethodType @@ -1983,16 +1983,16 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: extension (self: MethodType): def isErased: Boolean = self.isErasedMethod def isImplicit: Boolean = self.isImplicitMethod - def param(idx: Int): Type = self.newParamRef(idx) + def param(idx: Int): TypeRepr = self.newParamRef(idx) def paramNames: List[String] = self.paramNames.map(_.toString) - def paramTypes: List[Type] = self.paramInfos - def resType: Type = self.resType + def paramTypes: List[TypeRepr] = self.paramInfos + def resType: TypeRepr = self.resType end extension end MethodTypeMethodsImpl type PolyType = dotc.core.Types.PolyType - object PolyTypeTypeTest extends TypeTest[Type, PolyType]: + object PolyTypeTypeTest extends TypeTest[TypeRepr, PolyType]: def runtimeClass: Class[?] = classOf[PolyType] override def unapply(x: Any): Option[PolyType] = x match case tpe: Types.PolyType => Some(tpe) @@ -2000,24 +2000,24 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end PolyTypeTypeTest object PolyType extends PolyTypeModule: - def apply(paramNames: List[String])(paramBoundsExp: PolyType => List[TypeBounds], resultTypeExp: PolyType => Type): PolyType = + def apply(paramNames: List[String])(paramBoundsExp: PolyType => List[TypeBounds], resultTypeExp: PolyType => TypeRepr): PolyType = Types.PolyType(paramNames.map(_.toTypeName))(paramBoundsExp, resultTypeExp) - def unapply(x: PolyType): Option[(List[String], List[TypeBounds], Type)] = + def unapply(x: PolyType): Option[(List[String], List[TypeBounds], TypeRepr)] = Some((x.paramNames.map(_.toString), x.paramBounds, x.resType)) end PolyType object PolyTypeMethodsImpl extends PolyTypeMethods: extension (self: PolyType): - def param(idx: Int): Type = self.newParamRef(idx) + def param(idx: Int): TypeRepr = self.newParamRef(idx) def paramNames: List[String] = self.paramNames.map(_.toString) def paramBounds: List[TypeBounds] = self.paramInfos - def resType: Type = self.resType + def resType: TypeRepr = self.resType end extension end PolyTypeMethodsImpl type TypeLambda = dotc.core.Types.TypeLambda - object TypeLambdaTypeTest extends TypeTest[Type, TypeLambda]: + object TypeLambdaTypeTest extends TypeTest[TypeRepr, TypeLambda]: def runtimeClass: Class[?] = classOf[TypeLambda] override def unapply(x: Any): Option[TypeLambda] = x match case tpe: Types.TypeLambda => Some(tpe) @@ -2025,9 +2025,9 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end TypeLambdaTypeTest object TypeLambda extends TypeLambdaModule: - def apply(paramNames: List[String], boundsFn: TypeLambda => List[TypeBounds], bodyFn: TypeLambda => Type): TypeLambda = + def apply(paramNames: List[String], boundsFn: TypeLambda => List[TypeBounds], bodyFn: TypeLambda => TypeRepr): TypeLambda = Types.HKTypeLambda(paramNames.map(_.toTypeName))(boundsFn, bodyFn) - def unapply(x: TypeLambda): Option[(List[String], List[TypeBounds], Type)] = + def unapply(x: TypeLambda): Option[(List[String], List[TypeBounds], TypeRepr)] = Some((x.paramNames.map(_.toString), x.paramBounds, x.resType)) end TypeLambda @@ -2035,14 +2035,14 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: extension (self: TypeLambda): def paramNames: List[String] = self.paramNames.map(_.toString) def paramBounds: List[TypeBounds] = self.paramInfos - def param(idx: Int): Type = self.newParamRef(idx) - def resType: Type = self.resType + def param(idx: Int): TypeRepr = self.newParamRef(idx) + def resType: TypeRepr = self.resType end extension end TypeLambdaMethodsImpl type TypeBounds = dotc.core.Types.TypeBounds - object TypeBoundsTypeTest extends TypeTest[Type, TypeBounds]: + object TypeBoundsTypeTest extends TypeTest[TypeRepr, TypeBounds]: def runtimeClass: Class[?] = classOf[TypeBounds] override def unapply(x: Any): Option[TypeBounds] = x match case x: Types.TypeBounds => Some(x) @@ -2050,23 +2050,23 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end TypeBoundsTypeTest object TypeBounds extends TypeBoundsModule: - def apply(low: Type, hi: Type): TypeBounds = Types.TypeBounds(low, hi) - def unapply(x: TypeBounds): Option[(Type, Type)] = Some((x.low, x.hi)) + def apply(low: TypeRepr, hi: TypeRepr): TypeBounds = Types.TypeBounds(low, hi) + def unapply(x: TypeBounds): Option[(TypeRepr, TypeRepr)] = Some((x.low, x.hi)) def empty: TypeBounds = Types .TypeBounds.empty - def upper(hi: Type): TypeBounds = Types .TypeBounds.upper(hi) - def lower(lo: Type): TypeBounds = Types .TypeBounds.lower(lo) + def upper(hi: TypeRepr): TypeBounds = Types .TypeBounds.upper(hi) + def lower(lo: TypeRepr): TypeBounds = Types .TypeBounds.lower(lo) end TypeBounds object TypeBoundsMethodsImpl extends TypeBoundsMethods: extension (self: TypeBounds): - def low: Type = self.lo - def hi: Type = self.hi + def low: TypeRepr = self.lo + def hi: TypeRepr = self.hi end extension end TypeBoundsMethodsImpl type NoPrefix = dotc.core.Types.NoPrefix.type - object NoPrefixTypeTest extends TypeTest[Type, NoPrefix]: + object NoPrefixTypeTest extends TypeTest[TypeRepr, NoPrefix]: def runtimeClass: Class[?] = classOf[Types.NoPrefix.type] override def unapply(x: Any): Option[NoPrefix] = if (x == Types.NoPrefix) Some(Types.NoPrefix) else None @@ -2156,10 +2156,10 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end Null object ClassOf extends ConstantClassOfModule: - def apply(x: Type): Constant = + 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[Type] = + def unapply(constant: Constant): Option[TypeRepr] = if constant.tag == dotc.core.Constants.ClazzTag then Some(constant.typeValue) else None end ClassOf @@ -2179,7 +2179,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end ConstantMethodsImpl object Implicits extends ImplicitsModule: - def search(tpe: Type): ImplicitSearchResult = + def search(tpe: TypeRepr): ImplicitSearchResult = ctx.typer.inferImplicitArg(tpe, rootPosition.span) end Implicits @@ -2267,13 +2267,13 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: def requiredModule(path: String): Symbol = dotc.core.Symbols.requiredModule(path) def requiredMethod(path: String): Symbol = dotc.core.Symbols.requiredMethod(path) def classSymbol(fullName: String): Symbol = dotc.core.Symbols.requiredClass(fullName) - def newMethod(parent: Symbol, name: String, tpe: Type): Symbol = + def newMethod(parent: Symbol, name: String, tpe: TypeRepr): Symbol = newMethod(parent, name, tpe, Flags.EmptyFlags, noSymbol) - def newMethod(parent: Symbol, name: String, tpe: Type, flags: Flags, privateWithin: Symbol): Symbol = + def newMethod(parent: Symbol, name: String, tpe: TypeRepr, flags: Flags, privateWithin: Symbol): Symbol = dotc.core.Symbols.newSymbol(parent, name.toTermName, flags | dotc.core.Flags.Method, tpe, privateWithin) - def newVal(parent: Symbol, name: String, tpe: Type, flags: Flags, privateWithin: Symbol): Symbol = + def newVal(parent: Symbol, name: String, tpe: TypeRepr, flags: Flags, privateWithin: Symbol): Symbol = dotc.core.Symbols.newSymbol(parent, name.toTermName, flags, tpe, privateWithin) - def newBind(parent: Symbol, name: String, flags: Flags, tpe: Type): Symbol = + def newBind(parent: Symbol, name: String, flags: Flags, tpe: TypeRepr): Symbol = dotc.core.Symbols.newSymbol(parent, name.toTermName, flags | Case, tpe) def noSymbol: Symbol = dotc.core.Symbols.NoSymbol end Symbol @@ -2284,13 +2284,13 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: def maybeOwner: Symbol = self.denot.maybeOwner def flags: Flags = self.denot.flags - def privateWithin: Option[Type] = + def privateWithin: Option[TypeRepr] = val within: Symbol = self.denot.privateWithin if (within.exists && !self.is(dotc.core.Flags.Protected)) Some(within.typeRef) else None - def protectedWithin: Option[Type] = + def protectedWithin: Option[TypeRepr] = val within: Symbol = self.denot.privateWithin if (within.exists && self.is(dotc.core.Flags.Protected)) Some(within.typeRef) @@ -2401,7 +2401,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext: end extension - private def appliedTypeRef(sym: Symbol): Type = + private def appliedTypeRef(sym: Symbol): TypeRepr = sym.typeRef.appliedTo(sym.typeParams.map(_.typeRef)) private def isMethod(sym: Symbol): Boolean = diff --git a/library/src-bootstrapped/scala/internal/quoted/Type.scala b/library/src-bootstrapped/scala/internal/quoted/Type.scala index cd0f48cd6f9c..8ef20510f050 100644 --- a/library/src-bootstrapped/scala/internal/quoted/Type.scala +++ b/library/src-bootstrapped/scala/internal/quoted/Type.scala @@ -44,30 +44,30 @@ object Type { // TODO generalize following optimizations for all classes without parameters def Unit: QuoteContext ?=> quoted.Type[Unit] = - qctx.reflect.Type.typeConstructorOf(classOf[Unit]).seal.asInstanceOf[quoted.Type[Unit]] + qctx.reflect.TypeRepr.typeConstructorOf(classOf[Unit]).seal.asInstanceOf[quoted.Type[Unit]] def Boolean: QuoteContext ?=> quoted.Type[Boolean] = - qctx.reflect.Type.typeConstructorOf(classOf[Boolean]).seal.asInstanceOf[quoted.Type[Boolean]] + qctx.reflect.TypeRepr.typeConstructorOf(classOf[Boolean]).seal.asInstanceOf[quoted.Type[Boolean]] def Byte: QuoteContext ?=> quoted.Type[Byte] = - qctx.reflect.Type.typeConstructorOf(classOf[Byte]).seal.asInstanceOf[quoted.Type[Byte]] + qctx.reflect.TypeRepr.typeConstructorOf(classOf[Byte]).seal.asInstanceOf[quoted.Type[Byte]] def Char: QuoteContext ?=> quoted.Type[Char] = - qctx.reflect.Type.typeConstructorOf(classOf[Char]).seal.asInstanceOf[quoted.Type[Char]] + qctx.reflect.TypeRepr.typeConstructorOf(classOf[Char]).seal.asInstanceOf[quoted.Type[Char]] def Short: QuoteContext ?=> quoted.Type[Short] = - qctx.reflect.Type.typeConstructorOf(classOf[Short]).seal.asInstanceOf[quoted.Type[Short]] + qctx.reflect.TypeRepr.typeConstructorOf(classOf[Short]).seal.asInstanceOf[quoted.Type[Short]] def Int: QuoteContext ?=> quoted.Type[Int] = - qctx.reflect.Type.typeConstructorOf(classOf[Int]).seal.asInstanceOf[quoted.Type[Int]] + qctx.reflect.TypeRepr.typeConstructorOf(classOf[Int]).seal.asInstanceOf[quoted.Type[Int]] def Long: QuoteContext ?=> quoted.Type[Long] = - qctx.reflect.Type.typeConstructorOf(classOf[Long]).seal.asInstanceOf[quoted.Type[Long]] + qctx.reflect.TypeRepr.typeConstructorOf(classOf[Long]).seal.asInstanceOf[quoted.Type[Long]] def Float: QuoteContext ?=> quoted.Type[Float] = - qctx.reflect.Type.typeConstructorOf(classOf[Float]).seal.asInstanceOf[quoted.Type[Float]] + qctx.reflect.TypeRepr.typeConstructorOf(classOf[Float]).seal.asInstanceOf[quoted.Type[Float]] def Double: QuoteContext ?=> quoted.Type[Double] = - qctx.reflect.Type.typeConstructorOf(classOf[Double]).seal.asInstanceOf[quoted.Type[Double]] + qctx.reflect.TypeRepr.typeConstructorOf(classOf[Double]).seal.asInstanceOf[quoted.Type[Double]] } diff --git a/library/src-bootstrapped/scala/quoted/Liftable.scala b/library/src-bootstrapped/scala/quoted/Liftable.scala index bf53957391a5..2641da147a94 100644 --- a/library/src-bootstrapped/scala/quoted/Liftable.scala +++ b/library/src-bootstrapped/scala/quoted/Liftable.scala @@ -88,7 +88,7 @@ object Liftable { given ClassLiftable[T] as Liftable[Class[T]] = new Liftable[Class[T]] { def toExpr(x: Class[T]) = { import qctx.reflect._ - Ref(defn.Predef_classOf).appliedToType(Type.typeConstructorOf(x)).seal.asInstanceOf[Expr[Class[T]]] + Ref(defn.Predef_classOf).appliedToType(TypeRepr.typeConstructorOf(x)).seal.asInstanceOf[Expr[Class[T]]] } } diff --git a/library/src-bootstrapped/scala/quoted/util/ExprMap.scala b/library/src-bootstrapped/scala/quoted/util/ExprMap.scala index e931f5d808a9..683603dc8863 100644 --- a/library/src-bootstrapped/scala/quoted/util/ExprMap.scala +++ b/library/src-bootstrapped/scala/quoted/util/ExprMap.scala @@ -16,7 +16,7 @@ trait ExprMap { def localCtx(definition: Definition): Context = definition.symbol.localContext tree match { case tree: Term => - transformTerm(tree, Type.of[Any]) + transformTerm(tree, TypeRepr.of[Any]) case tree: Definition => transformDefinition(tree) case tree: Import => @@ -42,7 +42,7 @@ trait ExprMap { } } - def transformTermChildren(tree: Term, tpe: Type)(using ctx: Context): Term = tree match { + def transformTermChildren(tree: Term, tpe: TypeRepr)(using ctx: Context): Term = tree match { case Ident(name) => tree case Select(qualifier, name) => @@ -53,17 +53,17 @@ trait ExprMap { tree case tree as Apply(fun, args) => val MethodType(_, tpes, _) = fun.tpe.widen - Apply.copy(tree)(transformTerm(fun, Type.of[Any]), transformTerms(args, tpes)) + Apply.copy(tree)(transformTerm(fun, TypeRepr.of[Any]), transformTerms(args, tpes)) case TypeApply(fun, args) => - TypeApply.copy(tree)(transformTerm(fun, Type.of[Any]), args) + TypeApply.copy(tree)(transformTerm(fun, TypeRepr.of[Any]), args) case _: Literal => tree case New(tpt) => New.copy(tree)(transformTypeTree(tpt)) case Typed(expr, tpt) => val tp = tpt.tpe match - case AppliedType(TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), ""), List(tp0: Type)) => - Type.of[Seq].appliedTo(tp0) + case AppliedType(TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), ""), List(tp0: TypeRepr)) => + TypeRepr.of[Seq].appliedTo(tp0) case tp => tp Typed.copy(tree)(transformTerm(expr, tp), transformTypeTree(tpt)) case tree: NamedArg => @@ -74,7 +74,7 @@ trait ExprMap { Block.copy(tree)(transformStats(stats), transformTerm(expr, tpe)) case If(cond, thenp, elsep) => If.copy(tree)( - transformTerm(cond, Type.of[Boolean]), + transformTerm(cond, TypeRepr.of[Boolean]), transformTerm(thenp, tpe), transformTerm(elsep, tpe)) case _: Closure => @@ -87,16 +87,16 @@ trait ExprMap { // Return.copy(tree)(transformTerm(expr, expr.tpe)) tree case While(cond, body) => - While.copy(tree)(transformTerm(cond, Type.of[Boolean]), transformTerm(body, Type.of[Any])) + While.copy(tree)(transformTerm(cond, TypeRepr.of[Boolean]), transformTerm(body, TypeRepr.of[Any])) case Try(block, cases, finalizer) => - Try.copy(tree)(transformTerm(block, tpe), transformCaseDefs(cases, Type.of[Any]), finalizer.map(x => transformTerm(x, Type.of[Any]))) + Try.copy(tree)(transformTerm(block, tpe), transformCaseDefs(cases, TypeRepr.of[Any]), finalizer.map(x => transformTerm(x, TypeRepr.of[Any]))) case Repeated(elems, elemtpt) => Repeated.copy(tree)(transformTerms(elems, elemtpt.tpe), elemtpt) case Inlined(call, bindings, expansion) => Inlined.copy(tree)(call, transformDefinitions(bindings), transformTerm(expansion, tpe)/*()call.symbol.localContext)*/) } - def transformTerm(tree: Term, tpe: Type)(using ctx: Context): Term = + def transformTerm(tree: Term, tpe: TypeRepr)(using ctx: Context): Term = tree match case _: Closure => tree @@ -112,8 +112,8 @@ trait ExprMap { def transformTypeTree(tree: TypeTree)(using ctx: Context): TypeTree = tree - def transformCaseDef(tree: CaseDef, tpe: Type)(using ctx: Context): CaseDef = - CaseDef.copy(tree)(tree.pattern, tree.guard.map(x => transformTerm(x, Type.of[Boolean])), transformTerm(tree.rhs, tpe)) + def transformCaseDef(tree: CaseDef, tpe: TypeRepr)(using ctx: Context): CaseDef = + CaseDef.copy(tree)(tree.pattern, tree.guard.map(x => transformTerm(x, TypeRepr.of[Boolean])), transformTerm(tree.rhs, tpe)) def transformTypeCaseDef(tree: TypeCaseDef)(using ctx: Context): TypeCaseDef = { TypeCaseDef.copy(tree)(transformTypeTree(tree.pattern), transformTypeTree(tree.rhs)) @@ -125,7 +125,7 @@ trait ExprMap { def transformDefinitions(trees: List[Definition])(using ctx: Context): List[Definition] = trees mapConserve (transformDefinition(_)) - def transformTerms(trees: List[Term], tpes: List[Type])(using ctx: Context): List[Term] = + def transformTerms(trees: List[Term], tpes: List[TypeRepr])(using ctx: Context): List[Term] = var tpes2 = tpes // TODO use proper zipConserve trees mapConserve { x => val tpe :: tail = tpes2 @@ -133,13 +133,13 @@ trait ExprMap { transformTerm(x, tpe) } - def transformTerms(trees: List[Term], tpe: Type)(using ctx: Context): List[Term] = + def transformTerms(trees: List[Term], tpe: TypeRepr)(using ctx: Context): List[Term] = trees.mapConserve(x => transformTerm(x, tpe)) def transformTypeTrees(trees: List[TypeTree])(using ctx: Context): List[TypeTree] = trees mapConserve (transformTypeTree(_)) - def transformCaseDefs(trees: List[CaseDef], tpe: Type)(using ctx: Context): List[CaseDef] = + def transformCaseDefs(trees: List[CaseDef], tpe: TypeRepr)(using ctx: Context): List[CaseDef] = trees mapConserve (x => transformCaseDef(x, tpe)) def transformTypeCaseDefs(trees: List[TypeCaseDef])(using ctx: Context): List[TypeCaseDef] = diff --git a/library/src/scala/tasty/Reflection.scala b/library/src/scala/tasty/Reflection.scala index 1211a9e8fc99..f6dc337ce18f 100644 --- a/library/src/scala/tasty/Reflection.scala +++ b/library/src/scala/tasty/Reflection.scala @@ -75,26 +75,26 @@ import scala.tasty.reflect._ * +- Alternatives * * - * +- Type -+- ConstantType - * +- TermRef - * +- TypeRef - * +- SuperType - * +- Refinement - * +- AppliedType - * +- AnnotatedType - * +- AndType - * +- OrType - * +- MatchType - * +- ByNameType - * +- ParamRef - * +- ThisType - * +- RecursiveThis - * +- RecursiveType - * +- LambdaType -+- MethodType - * | +- PolyType - * | +- TypeLambda - * +- TypeBounds - * +- NoPrefix + * +- TypeRepr -+- ConstantType + * +- TermRef + * +- TypeRef + * +- SuperType + * +- Refinement + * +- AppliedType + * +- AnnotatedType + * +- AndType + * +- OrType + * +- MatchType + * +- ByNameType + * +- ParamRef + * +- ThisType + * +- RecursiveThis + * +- RecursiveType + * +- LambdaType -+- MethodType + * | +- PolyType + * | +- TypeLambda + * +- TypeBounds + * +- NoPrefix * * +- ImportSelector -+- SimpleSelector * +- RenameSelector @@ -283,7 +283,7 @@ trait Reflection { reflection => val DefDef: DefDefModule trait DefDefModule { this: DefDef.type => - def apply(symbol: Symbol, rhsFn: List[Type] => List[List[Term]] => Option[Term]): DefDef + def apply(symbol: Symbol, rhsFn: List[TypeRepr] => List[List[Term]] => Option[Term]): DefDef def copy(original: Tree)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term]): DefDef def unapply(ddef: DefDef): Option[(String, List[TypeDef], List[List[ValDef]], TypeTree, Option[Term])] } @@ -389,8 +389,8 @@ trait Reflection { reflection => /** Convert `Term` to an `quoted.Expr[Any]` if the term is a valid expression */ def sealOpt: Option[scala.quoted.Expr[Any]] - /** Type of this term */ - def tpe: Type + /** TypeRepr of this term */ + def tpe: TypeRepr /** Replace Inlined nodes and InlineProxy references to underlying arguments */ def underlyingArgument: Term @@ -419,10 +419,10 @@ trait Reflection { reflection => def appliedToNone: Apply /** The current tree applied to given type argument: `tree[targ]` */ - def appliedToType(targ: Type): Term + def appliedToType(targ: TypeRepr): Term /** The current tree applied to given type arguments: `tree[targ0, ..., targN]` */ - def appliedToTypes(targs: List[Type]): Term + def appliedToTypes(targs: List[TypeRepr]): Term /** The current tree applied to given type argument list: `tree[targs(0), ..., targs(targs.length - 1)]` */ def appliedToTypeTrees(targs: List[TypeTree]): Term @@ -514,10 +514,10 @@ trait Reflection { reflection => // TODO rename, this returns an Apply and not a Select /** Call an overloaded method with the given type and term parameters */ - def overloaded(qualifier: Term, name: String, targs: List[Type], args: List[Term]): Apply - + def overloaded(qualifier: Term, name: String, targs: List[TypeRepr], args: List[Term]): Apply + /** Call an overloaded method with the given type and term parameters */ - def overloaded(qualifier: Term, name: String, targs: List[Type], args: List[Term], returnType: Type): Apply + def overloaded(qualifier: Term, name: String, targs: List[TypeRepr], args: List[Term], returnType: TypeRepr): Apply def copy(original: Tree)(qualifier: Term, name: String): Select @@ -852,11 +852,11 @@ trait Reflection { reflection => trait ClosureModule { this: Closure.type => - def apply(meth: Term, tpe: Option[Type]): Closure + def apply(meth: Term, tpe: Option[TypeRepr]): Closure - def copy(original: Tree)(meth: Tree, tpe: Option[Type]): Closure + def copy(original: Tree)(meth: Tree, tpe: Option[TypeRepr]): Closure - def unapply(x: Closure): Option[(Term, Option[Type])] + def unapply(x: Closure): Option[(Term, Option[TypeRepr])] } given ClosureMethods as ClosureMethods = ClosureMethodsImpl @@ -865,7 +865,7 @@ trait Reflection { reflection => trait ClosureMethods: extension (self: Closure): def meth: Term - def tpeOpt: Option[Type] + def tpeOpt: Option[TypeRepr] end extension end ClosureMethods @@ -1158,8 +1158,8 @@ trait Reflection { reflection => trait TypeTreeMethods: extension (self: TypeTree): - /** Type of this type tree */ - def tpe: Type + /** TypeRepr of this type tree */ + def tpe: TypeRepr end extension end TypeTreeMethods @@ -1173,7 +1173,7 @@ trait Reflection { reflection => val Inferred: InferredModule trait InferredModule { this: Inferred.type => - def apply(tpe: Type): Inferred + def apply(tpe: TypeRepr): Inferred /** Matches a TypeTree containing an inferred type */ def unapply(x: Inferred): Boolean } @@ -1510,7 +1510,7 @@ trait Reflection { reflection => trait WildcardTypeTreeMethods: extension (self: WildcardTypeTree): - def tpe: Type + def tpe: TypeRepr end extension end WildcardTypeTreeMethods @@ -1728,23 +1728,23 @@ trait Reflection { reflection => // ----- Types ---------------------------------------------------- /** A type, type constructors, type bounds or NoPrefix */ - type Type + type TypeRepr - val Type: TypeModule + val TypeRepr: TypeModule - trait TypeModule { this: Type.type => - /** Returns the type or kind (Type) of T */ - def of[T <: AnyKind](using qtype: scala.quoted.Type[T]): Type + trait TypeModule { this: TypeRepr.type => + /** Returns the type or kind (TypeRepr) of T */ + def of[T <: AnyKind](using qtype: scala.quoted.Type[T]): TypeRepr /** Returns the type constructor of the runtime (erased) class */ - def typeConstructorOf(clazz: Class[?]): Type + def typeConstructorOf(clazz: Class[?]): TypeRepr } given TypeMethods as TypeMethods = TypeMethodsImpl protected val TypeMethodsImpl: TypeMethods trait TypeMethods { - extension (self: Type): + extension (self: TypeRepr): /** Shows the tree as extractors */ def showExtractors: String @@ -1755,16 +1755,16 @@ trait Reflection { reflection => /** Shows the tree as fully typed source code */ def showWith(syntaxHighlight: SyntaxHighlight): String - /** Convert `Type` to an `quoted.Type[_]` */ + /** Convert `TypeRepr` to an `quoted.Type[_]` */ def seal: scala.quoted.Type[_] /** Is `self` type the same as `that` type? * This is the case iff `self <:< that` and `that <:< self`. */ - def =:=(that: Type): Boolean + def =:=(that: TypeRepr): Boolean /** Is this type a subtype of that type? */ - def <:<(that: Type): Boolean + def <:<(that: TypeRepr): Boolean /** Widen from singleton type to its underlying non-singleton * base type by applying one or more `underlying` dereferences, @@ -1775,29 +1775,29 @@ trait Reflection { reflection => * def o: Outer * .widen = o.C */ - def widen: Type + def widen: TypeRepr /** Widen from TermRef to its underlying non-termref * base type, while also skipping `=>T` types. */ - def widenTermRefExpr: Type + def widenTermRefExpr: TypeRepr /** Follow aliases and dereferences LazyRefs, annotated types and instantiated * TypeVars until type is no longer alias type, annotated type, LazyRef, * or instantiated type variable. */ - def dealias: Type + def dealias: TypeRepr /** A simplified version of this type which is equivalent wrt =:= to this type. * Reduces typerefs, applied match types, and and or types. */ - def simplified: Type + def simplified: TypeRepr def classSymbol: Option[Symbol] def typeSymbol: Symbol def termSymbol: Symbol def isSingleton: Boolean - def memberType(member: Symbol): Type + def memberType(member: Symbol): TypeRepr /** The base classes of this type with the class itself as first element. */ def baseClasses: List[Symbol] @@ -1810,7 +1810,7 @@ trait Reflection { reflection => * ThisType(C).baseType(D) = p.D[Int] * }}} */ - def baseType(cls: Symbol): Type + def baseType(cls: Symbol): TypeRepr /** Is this type an instance of a non-bottom subclass of the given class `cls`? */ def derivesFrom(cls: Symbol): Boolean @@ -1845,22 +1845,22 @@ trait Reflection { reflection => def isDependentFunctionType: Boolean /** The type , reduced if possible */ - def select(sym: Symbol): Type + def select(sym: Symbol): TypeRepr /** The current type applied to given type arguments: `this[targ]` */ - def appliedTo(targ: Type): Type + def appliedTo(targ: TypeRepr): TypeRepr /** The current type applied to given type arguments: `this[targ0, ..., targN]` */ - def appliedTo(targs: List[Type]): Type + def appliedTo(targs: List[TypeRepr]): TypeRepr end extension } /** A singleton type representing a known constant value */ - type ConstantType <: Type + type ConstantType <: TypeRepr - given TypeTest[Type, ConstantType] = ConstantTypeTypeTest - protected val ConstantTypeTypeTest: TypeTest[Type, ConstantType] + given TypeTest[TypeRepr, ConstantType] = ConstantTypeTypeTest + protected val ConstantTypeTypeTest: TypeTest[TypeRepr, ConstantType] val ConstantType: ConstantTypeModule @@ -1879,16 +1879,16 @@ trait Reflection { reflection => end ConstantTypeMethods /** Type of a reference to a term symbol */ - type TermRef <: Type + type TermRef <: TypeRepr - given TypeTest[Type, TermRef] = TermRefTypeTest - protected val TermRefTypeTest: TypeTest[Type, TermRef] + given TypeTest[TypeRepr, TermRef] = TermRefTypeTest + protected val TermRefTypeTest: TypeTest[TypeRepr, TermRef] val TermRef: TermRefModule trait TermRefModule { this: TermRef.type => - def apply(qual: Type, name: String): TermRef - def unapply(x: TermRef): Option[(Type, String)] + def apply(qual: TypeRepr, name: String): TermRef + def unapply(x: TermRef): Option[(TypeRepr, String)] } given TermRefMethods as TermRefMethods = TermRefMethodsImpl @@ -1896,21 +1896,21 @@ trait Reflection { reflection => trait TermRefMethods: extension (self: TermRef): - def qualifier: Type + def qualifier: TypeRepr def name: String end extension end TermRefMethods /** Type of a reference to a type symbol */ - type TypeRef <: Type + type TypeRef <: TypeRepr - given TypeTest[Type, TypeRef] = TypeRefTypeTest - protected val TypeRefTypeTest: TypeTest[Type, TypeRef] + given TypeTest[TypeRepr, TypeRef] = TypeRefTypeTest + protected val TypeRefTypeTest: TypeTest[TypeRepr, TypeRef] val TypeRef: TypeRefModule trait TypeRefModule { this: TypeRef.type => - def unapply(x: TypeRef): Option[(Type, String)] + def unapply(x: TypeRef): Option[(TypeRepr, String)] } given TypeRefMethods as TypeRefMethods = TypeRefMethodsImpl @@ -1918,24 +1918,24 @@ trait Reflection { reflection => trait TypeRefMethods: extension (self: TypeRef): - def qualifier: Type + def qualifier: TypeRepr def name: String def isOpaqueAlias: Boolean - def translucentSuperType: Type + def translucentSuperType: TypeRepr end extension end TypeRefMethods /** Type of a `super` reference */ - type SuperType <: Type + type SuperType <: TypeRepr - given TypeTest[Type, SuperType] = SuperTypeTypeTest - protected val SuperTypeTypeTest: TypeTest[Type, SuperType] + given TypeTest[TypeRepr, SuperType] = SuperTypeTypeTest + protected val SuperTypeTypeTest: TypeTest[TypeRepr, SuperType] val SuperType: SuperTypeModule trait SuperTypeModule { this: SuperType.type => - def apply(thistpe: Type, supertpe: Type): SuperType - def unapply(x: SuperType): Option[(Type, Type)] + def apply(thistpe: TypeRepr, supertpe: TypeRepr): SuperType + def unapply(x: SuperType): Option[(TypeRepr, TypeRepr)] } given SuperTypeMethods as SuperTypeMethods = SuperTypeMethodsImpl @@ -1943,22 +1943,22 @@ trait Reflection { reflection => trait SuperTypeMethods { this: SuperTypeMethods => extension (self: SuperType): - def thistpe: Type - def supertpe: Type + def thistpe: TypeRepr + def supertpe: TypeRepr end extension } /** A type with a type refinement `T { type U }` */ - type Refinement <: Type + type Refinement <: TypeRepr - given TypeTest[Type, Refinement] = RefinementTypeTest - protected val RefinementTypeTest: TypeTest[Type, Refinement] + given TypeTest[TypeRepr, Refinement] = RefinementTypeTest + protected val RefinementTypeTest: TypeTest[TypeRepr, Refinement] val Refinement: RefinementModule trait RefinementModule { this: Refinement.type => - def apply(parent: Type, name: String, info: Type): Refinement - def unapply(x: Refinement): Option[(Type, String, Type)] + def apply(parent: TypeRepr, name: String, info: TypeRepr): Refinement + def unapply(x: Refinement): Option[(TypeRepr, String, TypeRepr)] } given RefinementMethods as RefinementMethods = RefinementMethodsImpl @@ -1966,22 +1966,22 @@ trait Reflection { reflection => trait RefinementMethods: extension (self: Refinement): - def parent: Type + def parent: TypeRepr def name: String - def info: Type + def info: TypeRepr end extension end RefinementMethods /** A higher kinded type applied to some types `T[U]` */ - type AppliedType <: Type + type AppliedType <: TypeRepr - given TypeTest[Type, AppliedType] = AppliedTypeTypeTest - protected val AppliedTypeTypeTest: TypeTest[Type, AppliedType] + given TypeTest[TypeRepr, AppliedType] = AppliedTypeTypeTest + protected val AppliedTypeTypeTest: TypeTest[TypeRepr, AppliedType] val AppliedType: AppliedTypeModule trait AppliedTypeModule { this: AppliedType.type => - def unapply(x: AppliedType): Option[(Type, List[Type])] + def unapply(x: AppliedType): Option[(TypeRepr, List[TypeRepr])] } given AppliedTypeMethods as AppliedTypeMethods = AppliedTypeMethodsImpl @@ -1989,22 +1989,22 @@ trait Reflection { reflection => trait AppliedTypeMethods: extension (self: AppliedType): - def tycon: Type - def args: List[Type] + def tycon: TypeRepr + def args: List[TypeRepr] end extension end AppliedTypeMethods /** A type with an anottation `T @foo` */ - type AnnotatedType <: Type + type AnnotatedType <: TypeRepr - given TypeTest[Type, AnnotatedType] = AnnotatedTypeTypeTest - protected val AnnotatedTypeTypeTest: TypeTest[Type, AnnotatedType] + given TypeTest[TypeRepr, AnnotatedType] = AnnotatedTypeTypeTest + protected val AnnotatedTypeTypeTest: TypeTest[TypeRepr, AnnotatedType] val AnnotatedType: AnnotatedTypeModule trait AnnotatedTypeModule { this: AnnotatedType.type => - def apply(underlying: Type, annot: Term): AnnotatedType - def unapply(x: AnnotatedType): Option[(Type, Term)] + def apply(underlying: TypeRepr, annot: Term): AnnotatedType + def unapply(x: AnnotatedType): Option[(TypeRepr, Term)] } given AnnotatedTypeMethods as AnnotatedTypeMethods = AnnotatedTypeMethodsImpl @@ -2012,22 +2012,22 @@ trait Reflection { reflection => trait AnnotatedTypeMethods: extension (self: AnnotatedType): - def underlying: Type + def underlying: TypeRepr def annot: Term end extension end AnnotatedTypeMethods /** Intersection type `T & U` */ - type AndType <: Type + type AndType <: TypeRepr - given TypeTest[Type, AndType] = AndTypeTypeTest - protected val AndTypeTypeTest: TypeTest[Type, AndType] + given TypeTest[TypeRepr, AndType] = AndTypeTypeTest + protected val AndTypeTypeTest: TypeTest[TypeRepr, AndType] val AndType: AndTypeModule trait AndTypeModule { this: AndType.type => - def apply(lhs: Type, rhs: Type): AndType - def unapply(x: AndType): Option[(Type, Type)] + def apply(lhs: TypeRepr, rhs: TypeRepr): AndType + def unapply(x: AndType): Option[(TypeRepr, TypeRepr)] } given AndTypeMethods as AndTypeMethods = AndTypeMethodsImpl @@ -2035,22 +2035,22 @@ trait Reflection { reflection => trait AndTypeMethods: extension (self: AndType): - def left: Type - def right: Type + def left: TypeRepr + def right: TypeRepr end extension end AndTypeMethods /** Union type `T | U` */ - type OrType <: Type + type OrType <: TypeRepr - given TypeTest[Type, OrType] = OrTypeTypeTest - protected val OrTypeTypeTest: TypeTest[Type, OrType] + given TypeTest[TypeRepr, OrType] = OrTypeTypeTest + protected val OrTypeTypeTest: TypeTest[TypeRepr, OrType] val OrType: OrTypeModule trait OrTypeModule { this: OrType.type => - def apply(lhs: Type, rhs: Type): OrType - def unapply(x: OrType): Option[(Type, Type)] + def apply(lhs: TypeRepr, rhs: TypeRepr): OrType + def unapply(x: OrType): Option[(TypeRepr, TypeRepr)] } given OrTypeMethods as OrTypeMethods = OrTypeMethodsImpl @@ -2058,22 +2058,22 @@ trait Reflection { reflection => trait OrTypeMethods: extension (self: OrType): - def left: Type - def right: Type + def left: TypeRepr + def right: TypeRepr end extension end OrTypeMethods /** Type match `T match { case U => ... }` */ - type MatchType <: Type + type MatchType <: TypeRepr - given TypeTest[Type, MatchType] = MatchTypeTypeTest - protected val MatchTypeTypeTest: TypeTest[Type, MatchType] + given TypeTest[TypeRepr, MatchType] = MatchTypeTypeTest + protected val MatchTypeTypeTest: TypeTest[TypeRepr, MatchType] val MatchType: MatchTypeModule trait MatchTypeModule { this: MatchType.type => - def apply(bound: Type, scrutinee: Type, cases: List[Type]): MatchType - def unapply(x: MatchType): Option[(Type, Type, List[Type])] + def apply(bound: TypeRepr, scrutinee: TypeRepr, cases: List[TypeRepr]): MatchType + def unapply(x: MatchType): Option[(TypeRepr, TypeRepr, List[TypeRepr])] } given MatchTypeMethods as MatchTypeMethods = MatchTypeMethodsImpl @@ -2081,23 +2081,23 @@ trait Reflection { reflection => trait MatchTypeMethods: extension (self: MatchType): - def bound: Type - def scrutinee: Type - def cases: List[Type] + def bound: TypeRepr + def scrutinee: TypeRepr + def cases: List[TypeRepr] end extension end MatchTypeMethods /** Type of a by by name parameter */ - type ByNameType <: Type + type ByNameType <: TypeRepr - given TypeTest[Type, ByNameType] = ByNameTypeTypeTest - protected val ByNameTypeTypeTest: TypeTest[Type, ByNameType] + given TypeTest[TypeRepr, ByNameType] = ByNameTypeTypeTest + protected val ByNameTypeTypeTest: TypeTest[TypeRepr, ByNameType] val ByNameType: ByNameTypeModule trait ByNameTypeModule { this: ByNameType.type => - def apply(underlying: Type): Type - def unapply(x: ByNameType): Option[Type] + def apply(underlying: TypeRepr): TypeRepr + def unapply(x: ByNameType): Option[TypeRepr] } given ByNameTypeMethods as ByNameTypeMethods = ByNameTypeMethodsImpl @@ -2105,15 +2105,15 @@ trait Reflection { reflection => trait ByNameTypeMethods: extension (self: ByNameType): - def underlying: Type + def underlying: TypeRepr end extension end ByNameTypeMethods /** Type of a parameter reference */ - type ParamRef <: Type + type ParamRef <: TypeRepr - given TypeTest[Type, ParamRef] = ParamRefTypeTest - protected val ParamRefTypeTest: TypeTest[Type, ParamRef] + given TypeTest[TypeRepr, ParamRef] = ParamRefTypeTest + protected val ParamRefTypeTest: TypeTest[TypeRepr, ParamRef] val ParamRef: ParamRefModule @@ -2132,15 +2132,15 @@ trait Reflection { reflection => end ParamRefMethods /** Type of `this` */ - type ThisType <: Type + type ThisType <: TypeRepr - given TypeTest[Type, ThisType] = ThisTypeTypeTest - protected val ThisTypeTypeTest: TypeTest[Type, ThisType] + given TypeTest[TypeRepr, ThisType] = ThisTypeTypeTest + protected val ThisTypeTypeTest: TypeTest[TypeRepr, ThisType] val ThisType: ThisTypeModule trait ThisTypeModule { this: ThisType.type => - def unapply(x: ThisType): Option[Type] + def unapply(x: ThisType): Option[TypeRepr] } given ThisTypeMethods as ThisTypeMethods = ThisTypeMethodsImpl @@ -2148,15 +2148,15 @@ trait Reflection { reflection => trait ThisTypeMethods: extension (self: ThisType): - def tref: Type + def tref: TypeRepr end extension end ThisTypeMethods /** A type that is recursively defined `this` */ - type RecursiveThis <: Type + type RecursiveThis <: TypeRepr - given TypeTest[Type, RecursiveThis] = RecursiveThisTypeTest - protected val RecursiveThisTypeTest: TypeTest[Type, RecursiveThis] + given TypeTest[TypeRepr, RecursiveThis] = RecursiveThisTypeTest + protected val RecursiveThisTypeTest: TypeTest[TypeRepr, RecursiveThis] val RecursiveThis: RecursiveThisModule @@ -2174,10 +2174,10 @@ trait Reflection { reflection => end RecursiveThisMethods /** A type that is recursively defined */ - type RecursiveType <: Type + type RecursiveType <: TypeRepr - given TypeTest[Type, RecursiveType] = RecursiveTypeTypeTest - protected val RecursiveTypeTypeTest: TypeTest[Type, RecursiveType] + given TypeTest[TypeRepr, RecursiveType] = RecursiveTypeTypeTest + protected val RecursiveTypeTypeTest: TypeTest[TypeRepr, RecursiveType] val RecursiveType: RecursiveTypeModule @@ -2191,9 +2191,9 @@ trait Reflection { reflection => * `type T`. This avoids infinite recursions later when we * try to follow these references. */ - def apply(parentExp: RecursiveType => Type): RecursiveType + def apply(parentExp: RecursiveType => TypeRepr): RecursiveType - def unapply(x: RecursiveType): Option[Type] + def unapply(x: RecursiveType): Option[TypeRepr] } given RecursiveTypeMethods as RecursiveTypeMethods = RecursiveTypeMethodsImpl @@ -2201,26 +2201,26 @@ trait Reflection { reflection => trait RecursiveTypeMethods: extension (self: RecursiveType): - def underlying: Type + def underlying: TypeRepr def recThis: RecursiveThis end extension end RecursiveTypeMethods // TODO: remove LambdaType and use union types (MethodType | PolyType | TypeLambda) /** Common abstraction for lambda types (MethodType, PolyType and TypeLambda). */ - type LambdaType <: Type + type LambdaType <: TypeRepr /** Type of the definition of a method taking a single list of parameters. It's return type may be a MethodType. */ type MethodType <: LambdaType - given TypeTest[Type, MethodType] = MethodTypeTypeTest - protected val MethodTypeTypeTest: TypeTest[Type, MethodType] + given TypeTest[TypeRepr, MethodType] = MethodTypeTypeTest + protected val MethodTypeTypeTest: TypeTest[TypeRepr, MethodType] val MethodType: MethodTypeModule trait MethodTypeModule { this: MethodType.type => - def apply(paramNames: List[String])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type): MethodType - def unapply(x: MethodType): Option[(List[String], List[Type], Type)] + def apply(paramNames: List[String])(paramInfosExp: MethodType => List[TypeRepr], resultTypeExp: MethodType => TypeRepr): MethodType + def unapply(x: MethodType): Option[(List[String], List[TypeRepr], TypeRepr)] } given MethodTypeMethods as MethodTypeMethods = MethodTypeMethodsImpl @@ -2230,24 +2230,24 @@ trait Reflection { reflection => extension (self: MethodType): def isImplicit: Boolean def isErased: Boolean - def param(idx: Int): Type + def param(idx: Int): TypeRepr def paramNames: List[String] - def paramTypes: List[Type] - def resType: Type + def paramTypes: List[TypeRepr] + def resType: TypeRepr end extension end MethodTypeMethods /** Type of the definition of a method taking a list of type parameters. It's return type may be a MethodType. */ type PolyType <: LambdaType - given TypeTest[Type, PolyType] = PolyTypeTypeTest - protected val PolyTypeTypeTest: TypeTest[Type, PolyType] + given TypeTest[TypeRepr, PolyType] = PolyTypeTypeTest + protected val PolyTypeTypeTest: TypeTest[TypeRepr, PolyType] val PolyType: PolyTypeModule trait PolyTypeModule { this: PolyType.type => - def apply(paramNames: List[String])(paramBoundsExp: PolyType => List[TypeBounds], resultTypeExp: PolyType => Type): PolyType - def unapply(x: PolyType): Option[(List[String], List[TypeBounds], Type)] + def apply(paramNames: List[String])(paramBoundsExp: PolyType => List[TypeBounds], resultTypeExp: PolyType => TypeRepr): PolyType + def unapply(x: PolyType): Option[(List[String], List[TypeBounds], TypeRepr)] } given PolyTypeMethods as PolyTypeMethods = PolyTypeMethodsImpl @@ -2255,24 +2255,24 @@ trait Reflection { reflection => trait PolyTypeMethods: extension (self: PolyType): - def param(idx: Int): Type + def param(idx: Int): TypeRepr def paramNames: List[String] def paramBounds: List[TypeBounds] - def resType: Type + def resType: TypeRepr end extension end PolyTypeMethods /** Type of the definition of a type lambda taking a list of type parameters. It's return type may be a TypeLambda. */ type TypeLambda <: LambdaType - given TypeTest[Type, TypeLambda] = TypeLambdaTypeTest - protected val TypeLambdaTypeTest: TypeTest[Type, TypeLambda] + given TypeTest[TypeRepr, TypeLambda] = TypeLambdaTypeTest + protected val TypeLambdaTypeTest: TypeTest[TypeRepr, TypeLambda] val TypeLambda: TypeLambdaModule trait TypeLambdaModule { this: TypeLambda.type => - def apply(paramNames: List[String], boundsFn: TypeLambda => List[TypeBounds], bodyFn: TypeLambda => Type): TypeLambda - def unapply(x: TypeLambda): Option[(List[String], List[TypeBounds], Type)] + def apply(paramNames: List[String], boundsFn: TypeLambda => List[TypeBounds], bodyFn: TypeLambda => TypeRepr): TypeLambda + def unapply(x: TypeLambda): Option[(List[String], List[TypeBounds], TypeRepr)] } given TypeLambdaMethods as TypeLambdaMethods = TypeLambdaMethodsImpl @@ -2282,27 +2282,27 @@ trait Reflection { reflection => extension (self: TypeLambda): def paramNames: List[String] def paramBounds: List[TypeBounds] - def param(idx: Int) : Type - def resType: Type + def param(idx: Int) : TypeRepr + def resType: TypeRepr end extension end TypeLambdaMethods // ----- TypeBounds ----------------------------------------------- /** Type bounds */ - type TypeBounds <: Type + type TypeBounds <: TypeRepr - given TypeTest[Type, TypeBounds] = TypeBoundsTypeTest - protected val TypeBoundsTypeTest: TypeTest[Type, TypeBounds] + given TypeTest[TypeRepr, TypeBounds] = TypeBoundsTypeTest + protected val TypeBoundsTypeTest: TypeTest[TypeRepr, TypeBounds] val TypeBounds: TypeBoundsModule trait TypeBoundsModule { this: TypeBounds.type => - def apply(low: Type, hi: Type): TypeBounds - def unapply(x: TypeBounds): Option[(Type, Type)] + def apply(low: TypeRepr, hi: TypeRepr): TypeBounds + def unapply(x: TypeBounds): Option[(TypeRepr, TypeRepr)] def empty: TypeBounds - def upper(hi: Type): TypeBounds - def lower(lo: Type): TypeBounds + def upper(hi: TypeRepr): TypeBounds + def lower(lo: TypeRepr): TypeBounds } given TypeBoundsMethods as TypeBoundsMethods = TypeBoundsMethodsImpl @@ -2310,18 +2310,18 @@ trait Reflection { reflection => trait TypeBoundsMethods: extension (self: TypeBounds): - def low: Type - def hi: Type + def low: TypeRepr + def hi: TypeRepr end extension end TypeBoundsMethods // ----- NoPrefix ------------------------------------------------- /** NoPrefix for a type selection */ - type NoPrefix <: Type + type NoPrefix <: TypeRepr - given TypeTest[Type, NoPrefix] = NoPrefixTypeTest - protected val NoPrefixTypeTest: TypeTest[Type, NoPrefix] + given TypeTest[TypeRepr, NoPrefix] = NoPrefixTypeTest + protected val NoPrefixTypeTest: TypeTest[TypeRepr, NoPrefix] val NoPrefix: NoPrefixModule @@ -2469,9 +2469,9 @@ trait Reflection { reflection => /** Constant class value representing a `classOf[T]` */ trait ConstantClassOfModule { this: ClassOf.type => /** Create a constant class value representing `classOf[]` */ - def apply(tpe: Type): Constant + def apply(tpe: TypeRepr): Constant /** Match a class value constant representing `classOf[]` and extract its type */ - def unapply(constant: Constant): Option[Type] + def unapply(constant: Constant): Option[TypeRepr] } } @@ -2507,7 +2507,7 @@ trait Reflection { reflection => * * @param tpe type of the implicit parameter */ - def search(tpe: Type): ImplicitSearchResult + def search(tpe: TypeRepr): ImplicitSearchResult } /** Result of a given instance search */ @@ -2596,14 +2596,14 @@ trait Reflection { reflection => * @note As a macro can only splice code into the point at which it is expanded, all generated symbols must be * direct or indirect children of the reflection context's owner. */ - def newMethod(parent: Symbol, name: String, tpe: Type): Symbol + def newMethod(parent: Symbol, name: String, tpe: TypeRepr): Symbol /** Works as the other newMethod, but with additional parameters. * * @param flags extra flags to with which the symbol should be constructed * @param privateWithin the symbol within which this new method symbol should be private. May be noSymbol. */ - def newMethod(parent: Symbol, name: String, tpe: Type, flags: Flags, privateWithin: Symbol): Symbol + def newMethod(parent: Symbol, name: String, tpe: TypeRepr, flags: Flags, privateWithin: Symbol): Symbol /** Generates a new val/var/lazy val symbol with the given parent, name and type. * @@ -2618,7 +2618,7 @@ trait Reflection { reflection => * @note As a macro can only splice code into the point at which it is expanded, all generated symbols must be * direct or indirect children of the reflection context's owner. */ - def newVal(parent: Symbol, name: String, tpe: Type, flags: Flags, privateWithin: Symbol): Symbol + def newVal(parent: Symbol, name: String, tpe: TypeRepr, flags: Flags, privateWithin: Symbol): Symbol /** Generates a pattern bind symbol with the given parent, name and type. * @@ -2630,7 +2630,7 @@ trait Reflection { reflection => * @note As a macro can only splice code into the point at which it is expanded, all generated symbols must be * direct or indirect children of the reflection context's owner. */ - def newBind(parent: Symbol, name: String, flags: Flags, tpe: Type): Symbol + def newBind(parent: Symbol, name: String, flags: Flags, tpe: TypeRepr): Symbol /** Definition not available */ def noSymbol: Symbol @@ -2652,10 +2652,10 @@ trait Reflection { reflection => def flags: Flags /** This symbol is private within the resulting type */ - def privateWithin: Option[Type] + def privateWithin: Option[TypeRepr] /** This symbol is protected within the resulting type */ - def protectedWithin: Option[Type] + def protectedWithin: Option[TypeRepr] /** The name of this symbol */ def name: String @@ -3079,7 +3079,7 @@ trait Reflection { reflection => /** Is this symbol `lazy` */ def Lazy: Flags - /** Is this symbol local? Used in conjunction with private/private[Type] to mean private[this] extends Modifier proctected[this] */ + /** Is this symbol local? Used in conjunction with private/private[T] to mean private[this] extends Modifier proctected[this] */ def Local: Flags /** Is this symbol marked as a macro. An inline method containing toplevel splices */ diff --git a/library/src/scala/tasty/reflect/ExtractorsPrinter.scala b/library/src/scala/tasty/reflect/ExtractorsPrinter.scala index 1222d270bd97..b83cb0d43e3c 100644 --- a/library/src/scala/tasty/reflect/ExtractorsPrinter.scala +++ b/library/src/scala/tasty/reflect/ExtractorsPrinter.scala @@ -7,7 +7,7 @@ class ExtractorsPrinter[R <: Reflection & Singleton](val reflect: R) extends Pri def showTree(tree: Tree): String = new Buffer().visitTree(tree).result() - def showType(tpe: Type): String = + def showType(tpe: TypeRepr): String = new Buffer().visitType(tpe).result() def showConstant(const: Constant): String = @@ -181,7 +181,7 @@ class ExtractorsPrinter[R <: Reflection & Singleton](val reflect: R) extends Pri visitType(value) += ")" } - def visitType(x: Type): Buffer = x match { + def visitType(x: TypeRepr): Buffer = x match { case ConstantType(value) => this += "ConstantType(" += value += ")" case TermRef(qual, name) => @@ -272,9 +272,9 @@ class ExtractorsPrinter[R <: Reflection & Singleton](val reflect: R) extends Pri } private implicit class TypeOps(buff: Buffer) { - def +=(x: Type): Buffer = { visitType(x); buff } - def +=(x: Option[Type]): Buffer = { visitOption(x, visitType); buff } - def ++=(x: List[Type]): Buffer = { visitList(x, visitType); buff } + def +=(x: TypeRepr): Buffer = { visitType(x); buff } + def +=(x: Option[TypeRepr]): Buffer = { visitOption(x, visitType); buff } + def ++=(x: List[TypeRepr]): Buffer = { visitList(x, visitType); buff } } private implicit class SignatureOps(buff: Buffer) { diff --git a/library/src/scala/tasty/reflect/Printer.scala b/library/src/scala/tasty/reflect/Printer.scala index 5f5ed17859c2..7a897cc29dd2 100644 --- a/library/src/scala/tasty/reflect/Printer.scala +++ b/library/src/scala/tasty/reflect/Printer.scala @@ -12,7 +12,7 @@ trait Printer[R <: Reflection & Singleton] { def showTree(tree: Tree): String /** Show a String representation of a reflect.Type */ - def showType(tpe: Type): String + def showType(tpe: TypeRepr): String /** Show a String representation of a reflect.Constant */ def showConstant(const: Constant): String diff --git a/library/src/scala/tasty/reflect/SourceCodePrinter.scala b/library/src/scala/tasty/reflect/SourceCodePrinter.scala index 43fc42cec1cb..078bc21c604f 100644 --- a/library/src/scala/tasty/reflect/SourceCodePrinter.scala +++ b/library/src/scala/tasty/reflect/SourceCodePrinter.scala @@ -12,7 +12,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl def showTree(tree: Tree): String = (new Buffer).printTree(tree).result() - def showType(tpe: Type): String = + def showType(tpe: TypeRepr): String = (new Buffer).printType(tpe)(using None).result() def showConstant(const: Constant): String = @@ -437,7 +437,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl inParens { printTree(term) this += (if (scala.internal.Chars.isOperatorPart(sb.last)) " : " else ": ") - def printTypeOrAnnots(tpe: Type): Unit = tpe match { + def printTypeOrAnnots(tpe: TypeRepr): Unit = tpe match { case AnnotatedType(tp, annot) if tp == term.tpe => printAnnotation(annot) case AnnotatedType(tp, annot) => @@ -651,8 +651,8 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl def printTypeTrees(trees: List[TypeTree], sep: String)(using elideThis: Option[Symbol] = None): Buffer = printList(trees, sep, (t: TypeTree) => printTypeTree(t)) - def printTypes(trees: List[Type], sep: String)(using elideThis: Option[Symbol]): Buffer = { - def printSeparated(list: List[Type]): Unit = list match { + def printTypes(trees: List[TypeRepr], sep: String)(using elideThis: Option[Symbol]): Buffer = { + def printSeparated(list: List[TypeRepr]): Unit = list match { case Nil => case x :: Nil => printType(x) case x :: xs => @@ -717,8 +717,8 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl this } - def printTypesOrBounds(types: List[Type], sep: String)(using elideThis: Option[Symbol]): Buffer = { - def printSeparated(list: List[Type]): Unit = list match { + def printTypesOrBounds(types: List[TypeRepr], sep: String)(using elideThis: Option[Symbol]): Buffer = { + def printSeparated(list: List[TypeRepr]): Unit = list match { case Nil => case x :: Nil => printType(x) case x :: xs => @@ -976,7 +976,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl def printTypeTree(tree: TypeTree)(using elideThis: Option[Symbol] = None): Buffer = tree match { case Inferred() => // TODO try to move this logic into `printType` - def printTypeAndAnnots(tpe: Type): Buffer = tpe match { + def printTypeAndAnnots(tpe: TypeRepr): Buffer = tpe match { case AnnotatedType(tp, annot) => printTypeAndAnnots(tp) this += " " @@ -1067,7 +1067,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl * Self type annotation and types in parent list should elide current class * prefix `C.this` to avoid type checking errors. */ - def printType(tpe: Type)(using elideThis: Option[Symbol] = None): Buffer = tpe match { + def printType(tpe: TypeRepr)(using elideThis: Option[Symbol] = None): Buffer = tpe match { case ConstantType(const) => printConstant(const) @@ -1090,7 +1090,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl this += "#" case ThisType(TermRef(cdef, _)) if elideThis.nonEmpty && cdef == elideThis.get => case ThisType(TypeRef(cdef, _)) if elideThis.nonEmpty && cdef == elideThis.get => - case prefix: Type => + case prefix: TypeRepr => printType(prefix) this += "." } @@ -1194,7 +1194,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl case tpe: MethodType => this += "(" printList(tpe.paramNames.zip(tpe.paramTypes), ", ", - (x: (String, Type)) => (this += x._1 += ": ").printType(x._2)) + (x: (String, TypeRepr)) => (this += x._1 += ": ").printType(x._2)) this += ")" printType(tpe.resType) @@ -1261,8 +1261,8 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl else this } - def printRefinement(tpe: Type)(using elideThis: Option[Symbol]): Buffer = { - def printMethodicType(tp: Type): Unit = tp match { + def printRefinement(tpe: TypeRepr)(using elideThis: Option[Symbol]): Buffer = { + def printMethodicType(tp: TypeRepr): Unit = tp match { case tp @ MethodType(paramNames, params, res) => inParens(printMethodicTypeParams(paramNames, params)) printMethodicType(res) @@ -1272,11 +1272,11 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl case ByNameType(t) => this += ": " printType(t) - case tp: Type => + case tp: TypeRepr => this += ": " printType(tp) } - def rec(tp: Type): Unit = tp match { + def rec(tp: TypeRepr): Unit = tp match { case Refinement(parent, name, info) => rec(parent) indented { @@ -1288,7 +1288,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl case ByNameType(_) | MethodType(_, _, _) | TypeLambda(_, _, _) => this += highlightKeyword("def ") += highlightTypeDef(name) printMethodicType(info) - case info: Type => + case info: TypeRepr => this += highlightKeyword("val ") += highlightValDef(name) printMethodicType(info) } @@ -1301,14 +1301,14 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl this += lineBreak() += "}" } - def printMethodicTypeParams(paramNames: List[String], params: List[Type])(using elideThis: Option[Symbol]): Unit = { - def printInfo(info: Type) = info match { + def printMethodicTypeParams(paramNames: List[String], params: List[TypeRepr])(using elideThis: Option[Symbol]): Unit = { + def printInfo(info: TypeRepr) = info match { case info: TypeBounds => printBounds(info) - case info: Type => + case info: TypeRepr => this += ": " printType(info) } - def printSeparated(list: List[(String, Type)]): Unit = list match { + def printSeparated(list: List[(String, TypeRepr)]): Unit = list match { case Nil => case (name, info) :: Nil => this += name @@ -1346,7 +1346,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl def printProtectedOrPrivate(definition: Definition): Boolean = { var prefixWasPrinted = false - def printWithin(within: Type) = within match { + def printWithin(within: TypeRepr) = within match { case TypeRef(_, name) => this += name case _ => printFullClassName(within) } @@ -1372,8 +1372,8 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl prefixWasPrinted } - def printFullClassName(tp: Type): Unit = { - def printClassPrefix(prefix: Type): Unit = prefix match { + def printFullClassName(tp: TypeRepr): Unit = { + def printClassPrefix(prefix: TypeRepr): Unit = prefix match { case TypeRef(prefix2, name) => printClassPrefix(prefix2) this += name += "." @@ -1457,8 +1457,8 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl private object Types { object Sequence { - def unapply(tpe: Type): Option[Type] = tpe match { - case AppliedType(seq, (tp: Type) :: Nil) + def unapply(tpe: TypeRepr): Option[TypeRepr] = tpe match { + case AppliedType(seq, (tp: TypeRepr) :: Nil) if seq.typeSymbol == Symbol.requiredClass("scala.collection.Seq") || seq.typeSymbol == Symbol.requiredClass("scala.collection.immutable.Seq") => Some(tp) case _ => None @@ -1466,8 +1466,8 @@ class SourceCodePrinter[R <: Reflection & Singleton](val reflect: R)(syntaxHighl } object Repeated { - def unapply(tpe: Type): Option[Type] = tpe match { - case AppliedType(rep, (tp: Type) :: Nil) if rep.typeSymbol == Symbol.requiredClass("scala.") => Some(tp) + def unapply(tpe: TypeRepr): Option[TypeRepr] = tpe match { + case AppliedType(rep, (tp: TypeRepr) :: Nil) if rep.typeSymbol == Symbol.requiredClass("scala.") => Some(tp) case _ => None } } diff --git a/tests/disabled/macro/run/reflection-magicsymbols-invoke.scala b/tests/disabled/macro/run/reflection-magicsymbols-invoke.scala index 1fff85171c3f..5b41a80390ad 100644 --- a/tests/disabled/macro/run/reflection-magicsymbols-invoke.scala +++ b/tests/disabled/macro/run/reflection-magicsymbols-invoke.scala @@ -10,7 +10,7 @@ package scala { object Test extends App { def key(sym: Symbol) = sym + ": " + sym.info - def test(tpe: Type, receiver: Any, method: String, args: Any*): Unit = { + def test(tpeTypeRepr, receiver: Any, method: String, args: Any*): Unit = { def wrap[T](op: => T) = try { var result = op.asInstanceOf[AnyRef] diff --git a/tests/disabled/macro/run/reify_printf.scala b/tests/disabled/macro/run/reify_printf.scala index c4ade7983740..1d2925f3b773 100644 --- a/tests/disabled/macro/run/reify_printf.scala +++ b/tests/disabled/macro/run/reify_printf.scala @@ -25,7 +25,7 @@ object Test extends App { var i = 0 def gensym(name: String) = { i += 1; TermName(name + i) } - def createTempValDef( value : Tree, tpe : Type ) : (Option[Tree],Tree) = { + def createTempValDef( value : Tree, tpe: TypeRepr ) : (Option[Tree],Tree) = { val local = gensym("temp") ( Some( diff --git a/tests/neg-macros/i7919.scala b/tests/neg-macros/i7919.scala index e235ccf7a3a9..986f91a4fc29 100644 --- a/tests/neg-macros/i7919.scala +++ b/tests/neg-macros/i7919.scala @@ -3,9 +3,9 @@ import scala.quoted._ object Test { def staged[T](using qctx: QuoteContext) = { import qctx.reflect._ - given typeT as quoted.Type[T] // error + given typeT as Type[T] // error val tTypeTree = typeT.unseal - val tt = Type.of[T] + val tt = TypeRepr.of[T] '{ "in staged" } } diff --git a/tests/neg-macros/i8871.scala b/tests/neg-macros/i8871.scala index d3e7b58c45fc..703704dab41f 100644 --- a/tests/neg-macros/i8871.scala +++ b/tests/neg-macros/i8871.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macro { def impl[A : Type](using qctx: QuoteContext): Unit = { import qctx.reflect._ - val tpe = Type.of[A].seal.asInstanceOf[quoted.Type[_ <: AnyRef]] + val tpe = TypeRepr.of[A].seal.asInstanceOf[Type[_ <: AnyRef]] '{ (a: ${tpe}) => ???} // error } } diff --git a/tests/neg-macros/i8871b.scala b/tests/neg-macros/i8871b.scala index c47660dd1b40..4c6ee309ebaa 100644 --- a/tests/neg-macros/i8871b.scala +++ b/tests/neg-macros/i8871b.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macro { def impl[A : Type](using qctx: QuoteContext): Unit = { import qctx.reflect._ - val tpe/*: quoted.Type[? <: AnyKind]*/ = Type.of[A].seal + val tpe/*: Type[? <: AnyKind]*/ = TypeRepr.of[A].seal '{ f[$tpe] } // error } def f[T <: AnyKind]: Unit = () diff --git a/tests/neg-macros/quotedPatterns-6.scala b/tests/neg-macros/quotedPatterns-6.scala index 249763b0461d..002b1d47a7b0 100644 --- a/tests/neg-macros/quotedPatterns-6.scala +++ b/tests/neg-macros/quotedPatterns-6.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Test { def test(x: quoted.Expr[Int])(using QuoteContext) = x match { case '{ poly[${Foo(t)}]($x); 4 } => ??? // error - case '{ type $t; poly[${Foo(y: quoted.Type[`$t`])}]($x); 4 } => ??? // error + case '{ type $t; poly[${Foo(y: Type[`$t`])}]($x); 4 } => ??? // error case _ => } diff --git a/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala b/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala index b9a03c7eed8c..be4f9c090fb9 100644 --- a/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala @@ -17,7 +17,7 @@ object Asserts { val tree = cond.unseal - def isOps(tpe: Type): Boolean = tpe match { + def isOps(tpe: TypeRepr): Boolean = tpe match { case tpe: TermRef => tpe.termSymbol.isDefDef && tpe.name == "Ops"// TODO check that the parent is Asserts case _ => false } diff --git a/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala b/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala index 7f1b930d1691..2ebe7edd2728 100644 --- a/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala @@ -17,7 +17,7 @@ object Asserts { val tree = cond.unseal - def isOps(tpe: Type): Boolean = tpe match { + def isOps(tpe: TypeRepr): Boolean = tpe match { case tpe: TermRef => tpe.termSymbol.isDefDef && tpe.name == "Ops"// TODO check that the parent is Asserts case _ => false } diff --git a/tests/pos-macros/i4539b.scala b/tests/pos-macros/i4539b.scala index d1eb6ce4fa4b..8e0c813bdef3 100644 --- a/tests/pos-macros/i4539b.scala +++ b/tests/pos-macros/i4539b.scala @@ -13,10 +13,10 @@ def test(using QuoteContext) = { '[String] } - def bar[T](t: quoted.Type[T]) = ??? + def bar[T](t: Type[T]) = ??? bar('[String]) - class Baz[T](t: quoted.Type[T]) + class Baz[T](t: Type[T]) new Baz('[String]) } diff --git a/tests/pos-macros/i8521/Macro_1.scala b/tests/pos-macros/i8521/Macro_1.scala index 3ac677044d2f..061029df42cf 100644 --- a/tests/pos-macros/i8521/Macro_1.scala +++ b/tests/pos-macros/i8521/Macro_1.scala @@ -4,7 +4,7 @@ object Foo { inline def foo[T <: AnyKind]: String = ${ bar[T] } def bar[T <: AnyKind : Type](using qctx: QuoteContext): Expr[String] = { - import qctx.reflect.{Type => _, _} + import qctx.reflect._ def packageToName(sym: Symbol): Unit = { if sym.isPackageDef then diff --git a/tests/pos-macros/i8879/Macro_1.scala b/tests/pos-macros/i8879/Macro_1.scala index 92f96ee4ac27..fbbcca60f116 100644 --- a/tests/pos-macros/i8879/Macro_1.scala +++ b/tests/pos-macros/i8879/Macro_1.scala @@ -9,10 +9,10 @@ object Test { import qctx.reflect._ import util._ - val foo = Type.of[Foo[String]] + val foo = TypeRepr.of[Foo[String]] val symbol = foo.typeSymbol.field("a") val a = foo.select(symbol) - assert(a <:< Type.of[String]) + assert(a <:< TypeRepr.of[String]) '{???} } diff --git a/tests/pos-macros/i9240/Macro_1.scala b/tests/pos-macros/i9240/Macro_1.scala index 8952f0ee2459..8cc0bf470b93 100644 --- a/tests/pos-macros/i9240/Macro_1.scala +++ b/tests/pos-macros/i9240/Macro_1.scala @@ -3,11 +3,11 @@ import scala.tasty._ inline def diveInto[T]: String = ${ diveIntoImpl[T]() } -def diveIntoImpl[T]()(implicit qctx: QuoteContext, ttype: scala.quoted.Type[T]): Expr[String] = +def diveIntoImpl[T]()(implicit qctx: QuoteContext, ttype: Type[T]): Expr[String] = import qctx.reflect._ - Expr( unwindType(qctx.tasty)(Type.of[T]) ) + Expr( unwindType(qctx.tasty)(TypeRepr.of[T]) ) -def unwindType(reflect: Reflection)(aType: reflect.Type): String = +def unwindType(reflect: Reflection)(aType: reflect.TypeRepr): String = import reflect._ aType match { diff --git a/tests/pos-macros/i9251/Macro_1.scala b/tests/pos-macros/i9251/Macro_1.scala index 8a1b88d40982..304913be756d 100644 --- a/tests/pos-macros/i9251/Macro_1.scala +++ b/tests/pos-macros/i9251/Macro_1.scala @@ -26,7 +26,7 @@ object Async { case Inlined(_,_,Block(_,Apply(TypeApply(Select(q,n),tparams),List(param)))) => param.tpe match case AppliedType(tp,tparams1) => - val fType = summon[quoted.Type[F]] + val fType = Type[F] val ptp = tparams1.tail.head val ptpTree = Inferred(fType.unseal.tpe.appliedTo(ptp)) '{ println(${Expr(ptpTree.show)}) } diff --git a/tests/pos-macros/i9518/Macro_1.scala b/tests/pos-macros/i9518/Macro_1.scala index 34be88c7345f..99d342d39792 100644 --- a/tests/pos-macros/i9518/Macro_1.scala +++ b/tests/pos-macros/i9518/Macro_1.scala @@ -12,7 +12,7 @@ def shiftTerm(using QuoteContext): Expr[Unit] = { val tp2 = '[([X] =>> CB[X])[Int]].unseal.tpe val ta = '[[X] =>> CB[X]] val tp3 = '[ta.T[Int]].unseal.tpe - val tp4 = '[CB].unseal.tpe.appliedTo(Type.of[Int]) + val tp4 = '[CB].unseal.tpe.appliedTo(TypeRepr.of[Int]) assert(nTree.tpe <:< tp1) assert(nTree.tpe <:< tp2) assert(nTree.tpe <:< tp3) diff --git a/tests/pos-macros/quotedPatterns.scala b/tests/pos-macros/quotedPatterns.scala index 3a7248fdfef6..45d9675aace8 100644 --- a/tests/pos-macros/quotedPatterns.scala +++ b/tests/pos-macros/quotedPatterns.scala @@ -35,6 +35,6 @@ object Test { def poly[T](x: T): Unit = () object Foo { - def unapply[T](arg: quoted.Type[T]): Option[quoted.Type[T]] = Some(arg) + def unapply[T](arg: Type[T]): Option[Type[T]] = Some(arg) } } \ No newline at end of file diff --git a/tests/pos-macros/tasty-constant-type/Macro_1.scala b/tests/pos-macros/tasty-constant-type/Macro_1.scala index 51738c86e059..9bd81775d148 100644 --- a/tests/pos-macros/tasty-constant-type/Macro_1.scala +++ b/tests/pos-macros/tasty-constant-type/Macro_1.scala @@ -9,8 +9,8 @@ object Macro { def impl[A <: Int : Type, B <: Int : Type](using qctx: QuoteContext) : Expr[AddInt[A, B]] = { import qctx.reflect._ - val ConstantType(Constant.Int(v1)) = Type.of[A] - val ConstantType(Constant.Int(v2)) = Type.of[B] + val ConstantType(Constant.Int(v1)) = TypeRepr.of[A] + val ConstantType(Constant.Int(v2)) = TypeRepr.of[B] Literal(Constant.Int(v1 + v2)).tpe.seal match case '[$T] => '{ null: AddInt[A, B] { type Out = T } } diff --git a/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala b/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala index 1567c686be36..05627fd93354 100644 --- a/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala +++ b/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala @@ -193,19 +193,19 @@ abstract class TreeInterpreter[QCtx <: QuoteContext & Singleton](using val qctx: } } - private def isNumericPrimitive(tpe: Type): Boolean = + private def isNumericPrimitive(tpe: TypeRepr): Boolean = isIntegralPrimitive(tpe) || isFractionalPrimitive(tpe) - private def isIntegralPrimitive(tpe: Type): Boolean = { - tpe <:< Type.of[Byte] || - tpe <:< Type.of[Char] || - tpe <:< Type.of[Short] || - tpe <:< Type.of[Int] || - tpe <:< Type.of[Long] + private def isIntegralPrimitive(tpe: TypeRepr): Boolean ={ + tpe <:< TypeRepr.of[Byte] || + tpe <:< TypeRepr.of[Char] || + tpe <:< TypeRepr.of[Short] || + tpe <:< TypeRepr.of[Int] || + tpe <:< TypeRepr.of[Long] } - private def isFractionalPrimitive(tpe: Type): Boolean = - tpe <:< Type.of[Float] || tpe <:< Type.of[Double] + private def isFractionalPrimitive(tpe: TypeRepr): Boolean = + tpe <:< TypeRepr.of[Float] || tpe <:< TypeRepr.of[Double] private object Call { diff --git a/tests/run-macros/f-interpolation-1/FQuote_1.scala b/tests/run-macros/f-interpolation-1/FQuote_1.scala index f6c3aeeaa3b4..1c2f800cdee8 100644 --- a/tests/run-macros/f-interpolation-1/FQuote_1.scala +++ b/tests/run-macros/f-interpolation-1/FQuote_1.scala @@ -46,7 +46,7 @@ object FQuote { val Typed(Repeated(allArgs, _), _) = args.unseal.underlyingArgument for ((arg, part) <- allArgs.zip(parts.tail)) { - if (part.startsWith("%d") && !(arg.tpe <:< Type.of[Int])) { + if (part.startsWith("%d") && !(arg.tpe <:< TypeRepr.of[Int])) { return '{s"`${${Expr(arg.show)}}` is not of type Int"} } diff --git a/tests/run-macros/i4515/Macro_1.scala b/tests/run-macros/i4515/Macro_1.scala index 4a76d45597eb..185e74a2602c 100644 --- a/tests/run-macros/i4515/Macro_1.scala +++ b/tests/run-macros/i4515/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def foo[X](x: X): Unit = ${fooImpl('x)} - def fooImpl[X: quoted.Type](x: Expr[X])(using QuoteContext): Expr[Unit] = '{} + def fooImpl[X: Type](x: Expr[X])(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/run-macros/i5941/macro_1.scala b/tests/run-macros/i5941/macro_1.scala index 7e81dbfdf286..b52e3b7493ca 100644 --- a/tests/run-macros/i5941/macro_1.scala +++ b/tests/run-macros/i5941/macro_1.scala @@ -88,8 +88,8 @@ object Iso { import qctx.reflect._ import util._ - val tpS = Type.of[S] - val tpA = Type.of[A] + val tpS = TypeRepr.of[S] + val tpA = TypeRepr.of[A] // 1. S must be a case class // 2. A must be a tuple @@ -127,7 +127,7 @@ object Iso { import qctx.reflect._ import util._ - val tpS = Type.of[S] + val tpS = TypeRepr.of[S] if (tpS.isSingleton) { val ident = Ident(tpS.asInstanceOf[TermRef]).seal.cast[S] diff --git a/tests/run-macros/i6171/Macro_1.scala b/tests/run-macros/i6171/Macro_1.scala index 262f635a1af5..867f9543804b 100644 --- a/tests/run-macros/i6171/Macro_1.scala +++ b/tests/run-macros/i6171/Macro_1.scala @@ -8,7 +8,7 @@ object scalatest { import qctx.reflect._ import util._ - def isImplicitMethodType(tp: Type): Boolean = tp match + def isImplicitMethodType(tp: TypeRepr): Boolean = tp match case tp: MethodType => tp.isImplicit case _ => false diff --git a/tests/run-macros/i6518/Macro_1.scala b/tests/run-macros/i6518/Macro_1.scala index cb7cab3d6498..99f65738c744 100644 --- a/tests/run-macros/i6518/Macro_1.scala +++ b/tests/run-macros/i6518/Macro_1.scala @@ -6,7 +6,7 @@ object Macros { private def testImpl(using qctx: QuoteContext) : Expr[String] = { import qctx.reflect._ - val classSym = Type.of[Function1].classSymbol.get + val classSym = TypeRepr.of[Function1].classSymbol.get classSym.classMethod("apply") classSym.classMethods classSym.method("apply") diff --git a/tests/run-macros/quote-matcher-runtime/quoted_1.scala b/tests/run-macros/quote-matcher-runtime/quoted_1.scala index 38be7be24240..704ac751a308 100644 --- a/tests/run-macros/quote-matcher-runtime/quoted_1.scala +++ b/tests/run-macros/quote-matcher-runtime/quoted_1.scala @@ -11,7 +11,7 @@ object Macros { tup.toArray.toList.map { case r: Expr[_] => s"Expr(${r.unseal.show})" - case r: quoted.Type[_] => + case r: Type[_] => s"Type(${r.unseal.show})" case r: String => s"String($r)" diff --git a/tests/run-macros/quote-type-matcher/quoted_1.scala b/tests/run-macros/quote-type-matcher/quoted_1.scala index f81c290ec8a2..a4aaa4dd451e 100644 --- a/tests/run-macros/quote-type-matcher/quoted_1.scala +++ b/tests/run-macros/quote-type-matcher/quoted_1.scala @@ -9,7 +9,7 @@ object Macros { val res = scala.internal.quoted.Type.unapply[Tuple, Tuple](a)(using b, qctx).map { tup => tup.toArray.toList.map { - case r: quoted.Type[_] => + case r: Type[_] => s"Type(${r.unseal.show})" case r: String => s"String($r)" diff --git a/tests/run-macros/refined-selectable-macro/Macro_1.scala b/tests/run-macros/refined-selectable-macro/Macro_1.scala index 03d2a6279857..1e8bcd490f9f 100644 --- a/tests/run-macros/refined-selectable-macro/Macro_1.scala +++ b/tests/run-macros/refined-selectable-macro/Macro_1.scala @@ -19,7 +19,7 @@ object Macro { val repr = s.unseal.tpe.widenTermRefExpr.dealias - def rec(tpe: Type): List[(String, Type)] = { + def rec(tpe: TypeRepr): List[(String, TypeRepr)] = { tpe match { case Refinement(parent, name, info) => info match { @@ -28,7 +28,7 @@ object Macro { case _: MethodType | _: PolyType | _: TypeBounds | _: ByNameType => report.warning(s"Ignored `$name` as a field of the record", s) rec(parent) - case info: Type => + case info: TypeRepr => (name, info) :: rec(parent) } @@ -36,7 +36,7 @@ object Macro { } } - def tupleElem(name: String, info: Type): Expr[Any] = { + def tupleElem(name: String, info: TypeRepr): Expr[Any] = { val nameExpr = Expr(name) info.seal match { case '[$qType] => Expr.ofTupleFromSeq(Seq(nameExpr, '{ $s.selectDynamic($nameExpr).asInstanceOf[qType] })) @@ -55,28 +55,28 @@ object Macro { def isTupleCons(sym: Symbol): Boolean = sym.owner == defn.ScalaPackageClass && sym.name == "*:" - def extractTuple(tpe: Type, seen: Set[String]): (Set[String], (String, Type)) = { + 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: Type) :: Nil) if (parent.typeSymbol == defn.TupleClass(2)) => + case AppliedType(parent, ConstantType(Constant.String(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)) case _ => report.error("Tuple type was not explicit expected `(S, T)` where S is a singleton string", s) - (seen, ("", Type.of[Any])) + (seen, ("", TypeRepr.of[Any])) } } - def rec(tpe: Type, seen: Set[String]): List[(String, Type)] = { - if tpe =:= Type.of[EmptyTuple] then Nil + def rec(tpe: TypeRepr, seen: Set[String]): List[(String, TypeRepr)] = { + if tpe =:= TypeRepr.of[EmptyTuple] then Nil else tpe match { // head *: tail - case AppliedType(parent, List(head, tail: Type)) if isTupleCons(parent.typeSymbol) => + case AppliedType(parent, List(head, tail: TypeRepr)) if isTupleCons(parent.typeSymbol) => val (seen2, head2) = extractTuple(head, seen) head2 :: rec(tail, seen2) // Tuple1(...), Tuple2(...), ..., Tuple22(...) case AppliedType(parent, args) if defn.isTupleClass(parent.typeSymbol) => - (args.foldLeft((seen, List.empty[(String, Type)])){ case ((seenAcc, acc), arg) => + (args.foldLeft((seen, List.empty[(String, TypeRepr)])){ case ((seenAcc, acc), arg) => val (seen3, arg2) = extractTuple(arg, seenAcc) (seen3, arg2 :: acc) })._2 diff --git a/tests/run-macros/reflect-dsl/assert_1.scala b/tests/run-macros/reflect-dsl/assert_1.scala index 5db9b39d80c4..a6fc8a23a5e8 100644 --- a/tests/run-macros/reflect-dsl/assert_1.scala +++ b/tests/run-macros/reflect-dsl/assert_1.scala @@ -8,7 +8,7 @@ object scalatest { import qctx.reflect._ import util._ - def isImplicitMethodType(tp: Type): Boolean = tp match + def isImplicitMethodType(tp: TypeRepr): Boolean = tp match case tp: MethodType => tp.isImplicit case _ => false diff --git a/tests/run-macros/reflect-select-constructor/assert_1.scala b/tests/run-macros/reflect-select-constructor/assert_1.scala index ef2955c12602..ed14a7609283 100644 --- a/tests/run-macros/reflect-select-constructor/assert_1.scala +++ b/tests/run-macros/reflect-select-constructor/assert_1.scala @@ -8,7 +8,7 @@ object scalatest { import qctx.reflect._ import util._ - def isImplicitMethodType(tp: Type): Boolean = tp match + def isImplicitMethodType(tp: TypeRepr): Boolean = tp match case tp: MethodType => tp.isImplicit case _ => false diff --git a/tests/run-macros/reflect-select-copy-2/assert_1.scala b/tests/run-macros/reflect-select-copy-2/assert_1.scala index c960a788af1b..f664d031fb86 100644 --- a/tests/run-macros/reflect-select-copy-2/assert_1.scala +++ b/tests/run-macros/reflect-select-copy-2/assert_1.scala @@ -8,7 +8,7 @@ object scalatest { import qctx.reflect._ import util._ - def isImplicitMethodType(tp: Type): Boolean = tp match + def isImplicitMethodType(tp: TypeRepr): Boolean = tp match case tp: MethodType => tp.isImplicit case _ => false diff --git a/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala b/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala index 441fb39d8de8..5b6d61510521 100644 --- a/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala +++ b/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala @@ -8,7 +8,7 @@ object scalatest { import qctx.reflect._ import util._ - def isImplicitMethodType(tp: Type): Boolean = tp match + def isImplicitMethodType(tp: TypeRepr): Boolean = tp match case tp: MethodType => tp.isImplicit case _ => false diff --git a/tests/run-macros/reflect-select-value-class/assert_1.scala b/tests/run-macros/reflect-select-value-class/assert_1.scala index f45164d7d040..8233d59efbdb 100644 --- a/tests/run-macros/reflect-select-value-class/assert_1.scala +++ b/tests/run-macros/reflect-select-value-class/assert_1.scala @@ -8,7 +8,7 @@ object scalatest { import qctx.reflect._ import util._ - def isImplicitMethodType(tp: Type): Boolean = tp match + def isImplicitMethodType(tp: TypeRepr): Boolean = tp match case tp: MethodType => tp.isImplicit case _ => false diff --git a/tests/run-macros/tasty-construct-types/Macro_1.scala b/tests/run-macros/tasty-construct-types/Macro_1.scala index 8f5db4ec7b5d..57605b80e606 100644 --- a/tests/run-macros/tasty-construct-types/Macro_1.scala +++ b/tests/run-macros/tasty-construct-types/Macro_1.scala @@ -16,28 +16,28 @@ object Macros { val x1T = ConstantType(Constant.Int(1)) val x2T = OrType(ConstantType(Constant.Int(1)), ConstantType(Constant.Int(2))) - val x3T = AndType(ConstantType(Constant.Int(3)), Type.of[Any]) + val x3T = AndType(ConstantType(Constant.Int(3)), TypeRepr.of[Any]) val x4T = TypeLambda( List("A","B"), - _ => List(TypeBounds(Type.of[Nothing], Type.of[Any]), TypeBounds(Type.of[Nothing], Type.of[Any])), + _ => List(TypeBounds(TypeRepr.of[Nothing], TypeRepr.of[Any]), TypeBounds(TypeRepr.of[Nothing], TypeRepr.of[Any])), (tl : TypeLambda) => tl.param(1)) val x5T = Refinement( - Type.of[RefineMe], + TypeRepr.of[RefineMe], "T", - TypeBounds(Type.of[Int], Type.of[Int])) - val x6T = Type.of[List].appliedTo(List(Type.of[Int])) + 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 }.unseal) val x8T = MatchType( - Type.of[Int], - Type.of[List[8]], + TypeRepr.of[Int], + TypeRepr.of[List[8]], List( TypeLambda( List("t"), - _ => List(TypeBounds(Type.of[Nothing], Type.of[Any])), - tl => Type.of[scala.internal.MatchCase].appliedTo(List(Type.of[List].appliedTo(tl.param(0)), tl.param(0))))) + _ => List(TypeBounds(TypeRepr.of[Nothing], TypeRepr.of[Any])), + tl => TypeRepr.of[scala.internal.MatchCase].appliedTo(List(TypeRepr.of[List].appliedTo(tl.param(0)), tl.param(0))))) ) assert(x1T =:= '[1].unseal.tpe) 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 6bb38a471fb5..8d296e1d58af 100644 --- a/tests/run-macros/tasty-create-method-symbol/Macro_1.scala +++ b/tests/run-macros/tasty-create-method-symbol/Macro_1.scala @@ -12,8 +12,8 @@ object Macros { Symbol.currentOwner, "sym1", MethodType(List("a","b"))( - _ => List(Type.of[Int], Type.of[Int]), - _ => Type.of[Int])) + _ => List(TypeRepr.of[Int], TypeRepr.of[Int]), + _ => TypeRepr.of[Int])) assert(sym1.isDefDef) assert(sym1.name == "sym1") val sym1Statements : List[Statement] = List( @@ -29,7 +29,7 @@ object Macros { val sym2 : Symbol = Symbol.newMethod( Symbol.currentOwner, "sym2", - ByNameType(Type.of[Int])) + ByNameType(TypeRepr.of[Int])) assert(sym2.isDefDef) assert(sym2.name == "sym2") val sym2Statements : List[Statement] = List( @@ -46,7 +46,7 @@ object Macros { Symbol.currentOwner, "sym3", MethodType(List("a"))( - _ => List(Type.of[Int]), + _ => List(TypeRepr.of[Int]), mt => MethodType(List("b"))( _ => List(mt.param(0)), _ => mt.param(0)))) @@ -66,8 +66,8 @@ object Macros { Symbol.currentOwner, "sym4", MethodType(List("x"))( - _ => List(Type.of[Int]), - _ => Type.of[Int])) + _ => List(TypeRepr.of[Int]), + _ => TypeRepr.of[Int])) assert(sym4.isDefDef) assert(sym4.name == "sym4") val sym4Statements : List[Statement] = List( @@ -88,8 +88,8 @@ object Macros { Symbol.currentOwner, "sym5", MethodType(List("x"))( - _ => List(Type.of[Int]), - _ => Type.of[Int=>Int])) + _ => List(TypeRepr.of[Int]), + _ => TypeRepr.of[Int=>Int])) assert(sym5.isDefDef) assert(sym5.name == "sym5") val sym5Statements : List[Statement] = List( @@ -101,8 +101,8 @@ object Macros { sym5, "sym51", MethodType(List("x"))( - _ => List(Type.of[Int]), - _ => Type.of[Int])) + _ => List(TypeRepr.of[Int]), + _ => TypeRepr.of[Int])) Block( List( DefDef(sym51, { @@ -122,14 +122,14 @@ object Macros { Symbol.currentOwner, "sym6_1", MethodType(List("x"))( - _ => List(Type.of[Int]), - _ => Type.of[Int])) + _ => List(TypeRepr.of[Int]), + _ => TypeRepr.of[Int])) val sym6_2 : Symbol = Symbol.newMethod( Symbol.currentOwner, "sym6_2", MethodType(List("x"))( - _ => List(Type.of[Int]), - _ => Type.of[Int])) + _ => List(TypeRepr.of[Int]), + _ => TypeRepr.of[Int])) assert(sym6_1.isDefDef) assert(sym6_2.isDefDef) assert(sym6_1.name == "sym6_1") @@ -169,7 +169,7 @@ object Macros { Symbol.currentOwner, "sym7", PolyType(List("T"))( - tp => List(TypeBounds(Type.of[Nothing], Type.of[Any])), + tp => List(TypeBounds(TypeRepr.of[Nothing], TypeRepr.of[Any])), tp => MethodType(List("t"))( _ => List(tp.param(0)), _ => tp.param(0)))) @@ -182,7 +182,7 @@ object Macros { Some(Typed(x, Inferred(t))) } }), - '{ assert(${ Apply(TypeApply(Ref(sym7), List(Inferred(Type.of[Int]))), List(Literal(Constant.Int(7)))).seal.asInstanceOf[Expr[Int]] } == 7) }.unseal) + '{ assert(${ Apply(TypeApply(Ref(sym7), List(Inferred(TypeRepr.of[Int]))), List(Literal(Constant.Int(7)))).seal.asInstanceOf[Expr[Int]] } == 7) }.unseal) Block( sym1Statements ++ diff --git a/tests/run-macros/tasty-custom-show/quoted_1.scala b/tests/run-macros/tasty-custom-show/quoted_1.scala index e2d24b333471..56f4a9019a47 100644 --- a/tests/run-macros/tasty-custom-show/quoted_1.scala +++ b/tests/run-macros/tasty-custom-show/quoted_1.scala @@ -42,7 +42,7 @@ object Macros { val reflect = qctx.reflect import qctx.reflect._ def showTree(tree: Tree): String = "Tree" - def showType(tpe: Type): String = "Type" + def showType(tpe: TypeRepr): String = "TypeRepr" def showConstant(const: Constant): String = "Constant" def showSymbol(symbol: Symbol): String = "Symbol" def showFlags(flags: Flags): String = "Flags" diff --git a/tests/run-macros/tasty-dealias/quoted_1.scala b/tests/run-macros/tasty-dealias/quoted_1.scala index 3cdc87bf60e2..55382f30348c 100644 --- a/tests/run-macros/tasty-dealias/quoted_1.scala +++ b/tests/run-macros/tasty-dealias/quoted_1.scala @@ -4,7 +4,7 @@ object Macros { inline def dealias[T]: String = ${ impl('[T]) } - def impl[T](x: quoted.Type[T])(using qctx: QuoteContext) : Expr[String] = { + def impl[T](x: Type[T])(using qctx: QuoteContext) : Expr[String] = { import qctx.reflect._ Expr(x.unseal.tpe.dealias.show) } diff --git a/tests/run-macros/tasty-definitions-1/quoted_1.scala b/tests/run-macros/tasty-definitions-1/quoted_1.scala index a8c0ce5c4f05..059aa45e4d66 100644 --- a/tests/run-macros/tasty-definitions-1/quoted_1.scala +++ b/tests/run-macros/tasty-definitions-1/quoted_1.scala @@ -74,21 +74,21 @@ object Macros { printout(defn.ScalaPrimitiveValueClasses.map(_.name).toString) printout(defn.ScalaNumericValueClasses.map(_.name).toString) - printout(Type.of[Unit].showExtractors) - printout(Type.of[Byte].showExtractors) - printout(Type.of[Char].showExtractors) - printout(Type.of[Int].showExtractors) - printout(Type.of[Long].showExtractors) - printout(Type.of[Float].showExtractors) - printout(Type.of[Double].showExtractors) - printout(Type.of[Boolean].showExtractors) - printout(Type.of[Any].showExtractors) - printout(Type.of[AnyVal].showExtractors) - printout(Type.of[AnyRef].showExtractors) - printout(Type.of[Object].showExtractors) - printout(Type.of[Nothing].showExtractors) - printout(Type.of[Null].showExtractors) - printout(Type.of[String].showExtractors) + printout(TypeRepr.of[Unit].showExtractors) + printout(TypeRepr.of[Byte].showExtractors) + printout(TypeRepr.of[Char].showExtractors) + printout(TypeRepr.of[Int].showExtractors) + printout(TypeRepr.of[Long].showExtractors) + printout(TypeRepr.of[Float].showExtractors) + printout(TypeRepr.of[Double].showExtractors) + printout(TypeRepr.of[Boolean].showExtractors) + printout(TypeRepr.of[Any].showExtractors) + printout(TypeRepr.of[AnyVal].showExtractors) + printout(TypeRepr.of[AnyRef].showExtractors) + printout(TypeRepr.of[Object].showExtractors) + printout(TypeRepr.of[Nothing].showExtractors) + printout(TypeRepr.of[Null].showExtractors) + printout(TypeRepr.of[String].showExtractors) '{println(${Expr(buff.result().mkString("\n"))})} diff --git a/tests/run-macros/tasty-indexed-map/quoted_1.scala b/tests/run-macros/tasty-indexed-map/quoted_1.scala index 9327d8d9b4d0..902d58a439b8 100644 --- a/tests/run-macros/tasty-indexed-map/quoted_1.scala +++ b/tests/run-macros/tasty-indexed-map/quoted_1.scala @@ -27,11 +27,11 @@ object Index { def succImpl[K, H, T](implicit qctx: QuoteContext, k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = { import qctx.reflect._ - def name(tp: Type): String = tp match { + def name(tp: TypeRepr): String = tp match { case ConstantType(Constant.String(str)) => str } - def names(tp: Type): List[String] = tp match { + def names(tp: TypeRepr): List[String] = tp match { case AppliedType(_, x1 :: x2 :: Nil) => name(x1) :: names(x2) case _ => Nil } diff --git a/tests/run-macros/tasty-macro-assert/quoted_1.scala b/tests/run-macros/tasty-macro-assert/quoted_1.scala index 164abd126551..25e11e38170d 100644 --- a/tests/run-macros/tasty-macro-assert/quoted_1.scala +++ b/tests/run-macros/tasty-macro-assert/quoted_1.scala @@ -17,7 +17,7 @@ object Asserts { val tree = cond.unseal - def isOps(tpe: Type): Boolean = tpe match { + def isOps(tpe: TypeRepr): Boolean = tpe match { case tpe: TermRef => tpe.termSymbol.isDefDef && tpe.name == "Ops"// TODO check that the parent is Asserts case _ => false } diff --git a/tests/run-macros/tasty-macro-positions/quoted_1.scala b/tests/run-macros/tasty-macro-positions/quoted_1.scala index 1ec5ee1b3c88..36fe4965433f 100644 --- a/tests/run-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/run-macros/tasty-macro-positions/quoted_1.scala @@ -18,7 +18,7 @@ object Macros { } } - def impl2[T](x: quoted.Type[T])(using qctx: QuoteContext) : Expr[Unit] = { + def impl2[T](x: Type[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.reflect._ val pos = x.unseal.pos val code = x.unseal.show diff --git a/tests/run-macros/tasty-overload-secondargs/Macro_1.scala b/tests/run-macros/tasty-overload-secondargs/Macro_1.scala index 2e53fffc5306..f7db9ec2097c 100644 --- a/tests/run-macros/tasty-overload-secondargs/Macro_1.scala +++ b/tests/run-macros/tasty-overload-secondargs/Macro_1.scala @@ -20,15 +20,15 @@ object Macro: inline def mThen[A,B](inline x:PartialFunction[A,B]): Option[B] = ${ mThenImpl[A,B,PartialFunction[A,B],Option[B]]('x) } - + def mThenImpl[A:Type, B:Type, S<:(A=>B) :Type, R:Type](x:Expr[S])(using qctx: QuoteContext):Expr[R]= import qctx.reflect._ val fun = '{X}.unseal - val returnType = quoted.Type[(S) => ?].unseal.tpe + 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))), - quoted.Type[(S) => R].unseal.tpe + TypeRepr.of[(S) => R] ) val r = Apply(firstPart,List(x.unseal)) r.seal.cast[R] diff --git a/tests/run-macros/tasty-simplified/quoted_1.scala b/tests/run-macros/tasty-simplified/quoted_1.scala index 357e181b5b86..da33cc8612fc 100644 --- a/tests/run-macros/tasty-simplified/quoted_1.scala +++ b/tests/run-macros/tasty-simplified/quoted_1.scala @@ -8,17 +8,17 @@ object Macros { def impl[T: Type](using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.reflect._ - def unpackTuple(tp: Type): List[Type] = { + def unpackTuple(tp: TypeRepr): List[TypeRepr] = { @tailrec - def loop(tp: Type, acc: List[Type]): List[Type] = tp.dealias.simplified match { - case AppliedType(_, List(hd: Type, tl: Type)) => + def loop(tp: TypeRepr, acc: List[TypeRepr]): List[TypeRepr] = tp.dealias.simplified match { + case AppliedType(_, List(hd: TypeRepr, tl: TypeRepr)) => loop(tl, hd.dealias.simplified :: acc) case other => acc } loop(tp, Nil).reverse } - val tps = unpackTuple(Type.of[T]) + val tps = unpackTuple(TypeRepr.of[T]) Varargs(tps.map(x => Expr(x.show))) } } diff --git a/tests/run-macros/tasty-typeof/Macro_1.scala b/tests/run-macros/tasty-typeof/Macro_1.scala index 29590decc988..036cf3f6e65c 100644 --- a/tests/run-macros/tasty-typeof/Macro_1.scala +++ b/tests/run-macros/tasty-typeof/Macro_1.scala @@ -7,25 +7,25 @@ object Macros { private def testTypeOfImpl(using qctx: QuoteContext) : Expr[Unit] = { import qctx.reflect._ '{ - assert(${Expr(Type.of[Unit] =:= Type.of[Unit])}, "Unit") - assert(${Expr(Type.of[Byte] =:= Type.of[Byte])}, "Byte") - assert(${Expr(Type.of[Short] =:= Type.of[Short])}, "Short") - assert(${Expr(Type.of[Int] =:= Type.of[Int])}, "Int") - assert(${Expr(Type.of[Long] =:= Type.of[Long])}, "Long") - assert(${Expr(Type.of[Float] =:= Type.of[Float])}, "Float") - assert(${Expr(Type.of[Double] =:= Type.of[Double])}, "Double") - assert(${Expr(Type.of[Char] =:= Type.of[Char])}, "Char") - assert(${Expr(Type.of[String] =:= Type.of[String])}, "String") + assert(${Expr(TypeRepr.of[Unit] =:= TypeRepr.of[Unit])}, "Unit") + assert(${Expr(TypeRepr.of[Byte] =:= TypeRepr.of[Byte])}, "Byte") + assert(${Expr(TypeRepr.of[Short] =:= TypeRepr.of[Short])}, "Short") + assert(${Expr(TypeRepr.of[Int] =:= TypeRepr.of[Int])}, "Int") + assert(${Expr(TypeRepr.of[Long] =:= TypeRepr.of[Long])}, "Long") + assert(${Expr(TypeRepr.of[Float] =:= TypeRepr.of[Float])}, "Float") + assert(${Expr(TypeRepr.of[Double] =:= TypeRepr.of[Double])}, "Double") + assert(${Expr(TypeRepr.of[Char] =:= TypeRepr.of[Char])}, "Char") + assert(${Expr(TypeRepr.of[String] =:= TypeRepr.of[String])}, "String") - assert(${Expr(Type.of[Any] =:= Type.of[Any])}, "Any") - assert(${Expr(Type.of[AnyRef] =:= Type.of[AnyRef])}, "AnyRef") - assert(${Expr(Type.of[AnyVal] =:= Type.of[AnyVal])}, "AnyVal") - assert(${Expr(Type.of[Object] =:= Type.of[Object])}, "Object") - assert(${Expr(Type.of[Nothing] =:= Type.of[Nothing])}, "Nothing") + assert(${Expr(TypeRepr.of[Any] =:= TypeRepr.of[Any])}, "Any") + assert(${Expr(TypeRepr.of[AnyRef] =:= TypeRepr.of[AnyRef])}, "AnyRef") + assert(${Expr(TypeRepr.of[AnyVal] =:= TypeRepr.of[AnyVal])}, "AnyVal") + assert(${Expr(TypeRepr.of[Object] =:= TypeRepr.of[Object])}, "Object") + assert(${Expr(TypeRepr.of[Nothing] =:= TypeRepr.of[Nothing])}, "Nothing") - println(${Expr(Type.of[List[Int]].show)}) - println(${Expr(Type.of[Macros].show)}) - println(${Expr(Type.of[Macros.type].show)}) + println(${Expr(TypeRepr.of[List[Int]].show)}) + println(${Expr(TypeRepr.of[Macros].show)}) + println(${Expr(TypeRepr.of[Macros.type].show)}) } }