diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index f8944de66174..69e29ed19e6f 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit f8944de661745b4e0a39d0709518b90dc2c7e438 +Subproject commit 69e29ed19e6fe12e9acf6f748d0693bdd957cfd0 diff --git a/community-build/community-projects/sourcecode b/community-build/community-projects/sourcecode index 4ae2049a4d62..1b8fcebec8c9 160000 --- a/community-build/community-projects/sourcecode +++ b/community-build/community-projects/sourcecode @@ -1 +1 @@ -Subproject commit 4ae2049a4d628cf85b9bf556333c9f6edb9deee5 +Subproject commit 1b8fcebec8c9322a06498fd5e1086bfc5abee277 diff --git a/community-build/community-projects/upickle b/community-build/community-projects/upickle index b5fe468f8665..bee9cc1d4276 160000 --- a/community-build/community-projects/upickle +++ b/community-build/community-projects/upickle @@ -1 +1 @@ -Subproject commit b5fe468f8665b12d09a733e7a1b419cf26ad2f88 +Subproject commit bee9cc1d42768f5f578ee8855eb9c1e4d0f70080 diff --git a/community-build/src/scala/dotty/communitybuild/projects.scala b/community-build/src/scala/dotty/communitybuild/projects.scala index 4ec1b5247780..9389074ff50d 100644 --- a/community-build/src/scala/dotty/communitybuild/projects.scala +++ b/community-build/src/scala/dotty/communitybuild/projects.scala @@ -321,7 +321,7 @@ object projects: sbtDocCommand = ";core/doc ;akka/doc ;shapelessScanner/doc" ) - lazy val ScalaPB = SbtCommunityProject( + lazy val scalaPB = SbtCommunityProject( project = "ScalaPB", sbtTestCommand = "dotty-community-build/compile", // aggregateDoc("runtimeJVM")("scalapbc", "grpcRuntime", "compilerPlugin") fails with diff --git a/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala b/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala index 9bfb620ca7af..0154369438a6 100644 --- a/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala +++ b/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala @@ -140,7 +140,7 @@ class CommunityBuildTestB extends CommunityBuildTest: @Test def scodecBits = projects.scodecBits.run() @Test def scalap = projects.scalap.run() @Test def scalaParserCombinators = projects.scalaParserCombinators.run() - @Test def ScalaPB = projects.ScalaPB.run() + @Test def scalaPB = projects.scalaPB.run() @Test def scalaXml = projects.scalaXml.run() @Test def scas = projects.scas.run() @Test def sconfig = projects.sconfig.run() diff --git a/compiler/src-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala index 04606a9a9377..3dbc8c20c6b2 100644 --- a/compiler/src-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala @@ -256,21 +256,22 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler end DefDefTypeTest object DefDef extends DefDefModule: - def apply(symbol: Symbol, rhsFn: List[TypeRepr] => List[List[Term]] => Option[Term]): DefDef = - withDefaultPos(tpd.DefDef(symbol.asTerm, prefss => { - val (tparams, vparamss) = tpd.splitArgs(prefss) - yCheckedOwners(rhsFn(tparams.map(_.tpe))(vparamss), symbol).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, tpd.joinParams(typeParams, paramss), tpt, yCheckedOwners(rhs, original.symbol).getOrElse(tpd.EmptyTree)) - def unapply(ddef: DefDef): (String, List[TypeDef], List[List[ValDef]], TypeTree, Option[Term]) = - (ddef.name.toString, ddef.typeParams, ddef.termParamss, ddef.tpt, optional(ddef.rhs)) + def apply(symbol: Symbol, rhsFn: List[List[Tree]] => Option[Term]): DefDef = + withDefaultPos(tpd.DefDef(symbol.asTerm, prefss => + yCheckedOwners(rhsFn(prefss), symbol).getOrElse(tpd.EmptyTree) + )) + def copy(original: Tree)(name: String, paramss: List[ParamClause], tpt: TypeTree, rhs: Option[Term]): DefDef = + tpd.cpy.DefDef(original)(name.toTermName, paramss, tpt, yCheckedOwners(rhs, original.symbol).getOrElse(tpd.EmptyTree)) + def unapply(ddef: DefDef): (String, List[ParamClause], TypeTree, Option[Term]) = + (ddef.name.toString, ddef.paramss, ddef.tpt, optional(ddef.rhs)) end DefDef given DefDefMethods: DefDefMethods with extension (self: DefDef) - def typeParams: List[TypeDef] = self.leadingTypeParams // TODO: adapt to multiple type parameter clauses - def paramss: List[List[ValDef]] = self.termParamss + def paramss: List[ParamClause] = self.paramss + def leadingTypeParams: List[TypeDef] = self.leadingTypeParams + def trailingParamss: List[ParamClause] = self.trailingParamss + def termParamss: List[TermParamClause] = self.termParamss def returnTpt: TypeTree = self.tpt def rhs: Option[Term] = optional(self.rhs) end extension @@ -750,7 +751,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler tpd.Closure(meth, tss => yCheckedOwners(rhsFn(meth, tss.head.map(withDefaultPos)), meth)) def unapply(tree: Block): Option[(List[ValDef], Term)] = tree match { - case Block((ddef @ DefDef(_, _, params :: Nil, _, Some(body))) :: Nil, Closure(meth, _)) + case Block((ddef @ DefDef(_, TermParamClause(params) :: Nil, _, Some(body))) :: Nil, Closure(meth, _)) if ddef.symbol == meth.symbol => Some((params, body)) case _ => None @@ -1481,6 +1482,56 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler end extension end AlternativesMethods + type ParamClause = tpd.ParamClause + + object ParamClause extends ParamClauseModule + + given ParamClauseMethods: ParamClauseMethods with + extension (self: ParamClause) + def params: List[ValDef] | List[TypeDef] = self + end ParamClauseMethods + + type TermParamClause = List[tpd.ValDef] + + given TermParamClauseTypeTest: TypeTest[ParamClause, TermParamClause] with + def apply(params: List[ValDef]): TermParamClause = params + def unapply(x: ParamClause): Option[TermParamClause & x.type] = x match + case tpd.ValDefs(_) => Some(x.asInstanceOf[TermParamClause & x.type]) + case _ => None + end TermParamClauseTypeTest + + object TermParamClause extends TermParamClauseModule: + def apply(x: List[ValDef]): TermParamClause = x + def unapply(x: TermParamClause): Some[List[ValDef]] = Some(x) + end TermParamClause + + given TermParamClauseMethods: TermParamClauseMethods with + extension (self: TermParamClause) + def params: List[ValDef] = self + def isImplicit: Boolean = + self.nonEmpty && self.head.symbol.is(dotc.core.Flags.Implicit) + end TermParamClauseMethods + + type TypeParamClause = List[tpd.TypeDef] + + given TypeParamClauseTypeTest: TypeTest[ParamClause, TypeParamClause] with + def unapply(x: ParamClause): Option[TypeParamClause & x.type] = x match + case tpd.TypeDefs(_) => Some(x.asInstanceOf[TypeParamClause & x.type]) + case _ => None + end TypeParamClauseTypeTest + + object TypeParamClause extends TypeParamClauseModule: + def apply(params: List[TypeDef]): TypeParamClause = + if params.isEmpty then throw IllegalArgumentException("Empty type parameters") + params + def unapply(x: TypeParamClause): Some[List[TypeDef]] = Some(x) + end TypeParamClause + + given TypeParamClauseMethods: TypeParamClauseMethods with + extension (self: TypeParamClause) + def params: List[TypeDef] = self + end TypeParamClauseMethods + type Selector = untpd.ImportSelector object Selector extends SelectorModule diff --git a/compiler/src-non-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src-non-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala index bac3e59375c5..265a27dc6711 100644 --- a/compiler/src-non-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src-non-bootstrapped/scala/quoted/runtime/impl/QuotesImpl.scala @@ -261,14 +261,14 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler })) 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, tpd.joinParams(typeParams, paramss), tpt, yCheckedOwners(rhs, original.symbol).getOrElse(tpd.EmptyTree)) - def unapply(ddef: DefDef): (String, List[TypeDef], List[List[ValDef]], TypeTree, Option[Term]) = - (ddef.name.toString, ddef.typeParams, ddef.termParamss, ddef.tpt, optional(ddef.rhs)) + // def unapply(ddef: DefDef): (String, List[TypeDef], List[List[ValDef]], TypeTree, Option[Term]) = + // (ddef.name.toString, ddef.typeParams, ddef.termParamss, ddef.tpt, optional(ddef.rhs)) end DefDef given DefDefMethods: DefDefMethods with extension (self: DefDef) def typeParams: List[TypeDef] = self.leadingTypeParams // TODO: adapt to multiple type parameter clauses - def paramss: List[List[ValDef]] = self.termParamss + // def paramss: List[List[ValDef]] = self.termParamss def returnTpt: TypeTree = self.tpt def rhs: Option[Term] = optional(self.rhs) end extension @@ -747,12 +747,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler val meth = dotc.core.Symbols.newSymbol(owner, nme.ANON_FUN, Synthetic | Method, tpe) tpd.Closure(meth, tss => yCheckedOwners(rhsFn(meth, tss.head), meth)) - def unapply(tree: Block): Option[(List[ValDef], Term)] = tree match { - case Block((ddef @ DefDef(_, _, params :: Nil, _, Some(body))) :: Nil, Closure(meth, _)) - if ddef.symbol == meth.symbol => - Some((params, body)) - case _ => None - } + def unapply(tree: Block): Option[(List[ValDef], Term)] = ??? end Lambda type If = tpd.If diff --git a/compiler/src/scala/quoted/runtime/impl/Matcher.scala b/compiler/src/scala/quoted/runtime/impl/Matcher.scala index ec807ff62726..556b7c124836 100644 --- a/compiler/src/scala/quoted/runtime/impl/Matcher.scala +++ b/compiler/src/scala/quoted/runtime/impl/Matcher.scala @@ -206,7 +206,7 @@ object Matcher { }.transformTree(scrutinee)(Symbol.spliceOwner) } val names = args.map { - case Block(List(DefDef("$anonfun", _, _, _, Some(Apply(Ident(name), _)))), _) => name + case Block(List(DefDef("$anonfun", _, _, Some(Apply(Ident(name), _)))), _) => name case arg => arg.symbol.name } val argTypes = args.map(x => x.tpe.widenTermRefExpr) @@ -302,16 +302,19 @@ object Matcher { tpt1 =?= tpt2 &&& treeOptMatches(rhs1, rhs2)(using rhsEnv) /* Match def */ - case (DefDef(_, typeParams1, paramss1, tpt1, Some(rhs1)), DefDef(_, typeParams2, paramss2, tpt2, Some(rhs2))) => + case (DefDef(_, paramss1, tpt1, Some(rhs1)), DefDef(_, paramss2, tpt2, Some(rhs2))) => def rhsEnv = + val paramSyms: List[(Symbol, Symbol)] = + for + (clause1, clause2) <- paramss1.zip(paramss2) + (param1, param2) <- clause1.params.zip(clause2.params) + yield + param1.symbol -> param2.symbol val oldEnv: Env = summon[Env] - val newEnv: List[(Symbol, Symbol)] = - (scrutinee.symbol -> pattern.symbol) :: typeParams1.zip(typeParams2).map((tparam1, tparam2) => tparam1.symbol -> tparam2.symbol) ::: - paramss1.flatten.zip(paramss2.flatten).map((param1, param2) => param1.symbol -> param2.symbol) + val newEnv: List[(Symbol, Symbol)] = (scrutinee.symbol -> pattern.symbol) :: paramSyms oldEnv ++ newEnv - typeParams1 =?= typeParams2 - &&& matchLists(paramss1, paramss2)(_ =?= _) + matchLists(paramss1, paramss2)(_ =?= _) &&& tpt1 =?= tpt2 &&& withEnv(rhsEnv)(rhs1 =?= rhs2) @@ -343,6 +346,14 @@ object Matcher { } end extension + extension (scrutinee: ParamClause) + /** Check that all parameters in the clauses clauses match with =?= and concatenate the results with &&& */ + private def =?= (pattern: ParamClause)(using Env)(using DummyImplicit): Matching = + (scrutinee, pattern) match + case (TermParamClause(params1), TermParamClause(params2)) => matchLists(params1, params2)(_ =?= _) + case (TypeParamClause(params1), TypeParamClause(params2)) => matchLists(params1, params2)(_ =?= _) + case _ => notMatched + /** Does the scrutenne symbol match the pattern symbol? It matches if: * - They are the same symbol * - The scrutinee has is in the environment and they are equivalent @@ -382,7 +393,7 @@ object Matcher { def unapply(args: List[Term]): Option[List[Ident]] = args.foldRight(Option(List.empty[Ident])) { case (id: Ident, Some(acc)) => Some(id :: acc) - case (Block(List(DefDef("$anonfun", Nil, List(params), Inferred(), Some(Apply(id: Ident, args)))), Closure(Ident("$anonfun"), None)), Some(acc)) + case (Block(List(DefDef("$anonfun", TermParamClause(params) :: Nil, Inferred(), Some(Apply(id: Ident, args)))), Closure(Ident("$anonfun"), None)), Some(acc)) if params.zip(args).forall(_.symbol == _.symbol) => Some(id :: acc) case _ => None diff --git a/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala b/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala index 324a9183fd3a..2e9890228a73 100644 --- a/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala +++ b/compiler/src/scala/quoted/runtime/impl/printers/Extractors.scala @@ -117,8 +117,8 @@ object Extractors { this += ", " ++= bindings += ", " += expansion += ")" case ValDef(name, tpt, rhs) => this += "ValDef(\"" += name += "\", " += tpt += ", " += rhs += ")" - case DefDef(name, typeParams, paramss, returnTpt, rhs) => - this += "DefDef(\"" += name += "\", " ++= typeParams += ", " +++= paramss += ", " += returnTpt += ", " += rhs += ")" + case DefDef(name, paramsClauses, returnTpt, rhs) => + this += "DefDef(\"" += name += "\", " ++= paramsClauses += ", " += returnTpt += ", " += rhs += ")" case TypeDef(name, rhs) => this += "TypeDef(\"" += name += "\", " += rhs += ")" case ClassDef(name, constr, parents, derived, self, body) => @@ -256,6 +256,11 @@ object Extractors { else if x.isTypeDef then this += "IsTypeDefSymbol(<" += x.fullName += ">)" else { assert(x.isNoSymbol); this += "NoSymbol()" } + def visitParamClause(x: ParamClause): this.type = + x match + case TermParamClause(params) => this += "TermParamClause(" ++= params += ")" + case TypeParamClause(params) => this += "TypeParamClause(" ++= params += ")" + def +=(x: Boolean): this.type = { sb.append(x); this } def +=(x: Byte): this.type = { sb.append(x); this } def +=(x: Short): this.type = { sb.append(x); this } @@ -301,6 +306,10 @@ object Extractors { def +=(x: Symbol): self.type = { visitSymbol(x); buff } } + private implicit class ParamClauseOps(buff: self.type) { + def ++=(x: List[ParamClause]): self.type = { visitList(x, visitParamClause); buff } + } + private def visitOption[U](opt: Option[U], visit: U => this.type): this.type = opt match { case Some(x) => this += "Some(" diff --git a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala index f1ee10777c7c..3cb5a19d980e 100644 --- a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala +++ b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala @@ -138,7 +138,7 @@ object SourceCode { this += "." printSelectors(selectors) - case cdef @ ClassDef(name, DefDef(_, targs, argss, _, _), parents, derived, self, stats) => + case cdef @ ClassDef(name, DefDef(_, paramss, _, _), parents, derived, self, stats) => printDefAnnotations(cdef) val flags = cdef.symbol.flags @@ -155,12 +155,13 @@ object SourceCode { else if (flags.is(Flags.Abstract)) this += highlightKeyword("abstract class ") += highlightTypeDef(name) else this += highlightKeyword("class ") += highlightTypeDef(name) - val typeParams = stats.collect { case targ: TypeDef => targ }.filter(_.symbol.isTypeParam).zip(targs) if (!flags.is(Flags.Module)) { - printTargsDefs(typeParams) - val it = argss.iterator - while (it.hasNext) - printArgsDefs(it.next()) + for paramClause <- paramss do + paramClause match + case TermParamClause(params) => + printArgsDefs(params) + case TypeParamClause(params) => + printTargsDefs(stats.collect { case targ: TypeDef => targ }.filter(_.symbol.isTypeParam).zip(params)) } val parents1 = parents.filter { @@ -212,8 +213,8 @@ object SourceCode { // Currently the compiler does not allow overriding some of the methods generated for case classes d.symbol.flags.is(Flags.Synthetic) && (d match { - case DefDef("apply" | "unapply" | "writeReplace", _, _, _, _) if d.symbol.owner.flags.is(Flags.Module) => true - case DefDef(n, _, _, _, _) if d.symbol.owner.flags.is(Flags.Case) => + case DefDef("apply" | "unapply" | "writeReplace", _, _, _) if d.symbol.owner.flags.is(Flags.Module) => true + case DefDef(n, _, _, _) if d.symbol.owner.flags.is(Flags.Case) => n == "copy" || n.matches("copy\\$default\\$[1-9][0-9]*") || // default parameters for the copy method n.matches("_[1-9][0-9]*") || // Getters from Product @@ -301,7 +302,7 @@ object SourceCode { printTree(body) } - case ddef @ DefDef(name, targs, argss, tpt, rhs) => + case ddef @ DefDef(name, paramss, tpt, rhs) => printDefAnnotations(ddef) val isConstructor = name == "" @@ -316,10 +317,10 @@ object SourceCode { val name1: String = if (isConstructor) "this" else splicedName(ddef.symbol).getOrElse(name) this += highlightKeyword("def ") += highlightValDef(name1) - printTargsDefs(targs.zip(targs)) - val it = argss.iterator - while (it.hasNext) - printArgsDefs(it.next()) + for clause <- paramss do + clause match + case TermParamClause(params) => printArgsDefs(params) + case TypeParamClause(params) => printTargsDefs(params.zip(params)) if (!isConstructor) { this += ": " printTypeTree(tpt) @@ -1251,7 +1252,7 @@ object SourceCode { private def printDefinitionName(tree: Definition): this.type = tree match { case ValDef(name, _, _) => this += highlightValDef(name) - case DefDef(name, _, _, _, _) => this += highlightValDef(name) + case DefDef(name, _, _, _) => this += highlightValDef(name) case ClassDef(name, _, _, _, _, _) => this += highlightTypeDef(name.stripSuffix("$")) case TypeDef(name, _) => this += highlightTypeDef(name) } diff --git a/library/src-bootstrapped/scala/quoted/Quotes.scala b/library/src-bootstrapped/scala/quoted/Quotes.scala index 1bdadd3e85af..6a7b5537022f 100644 --- a/library/src-bootstrapped/scala/quoted/Quotes.scala +++ b/library/src-bootstrapped/scala/quoted/Quotes.scala @@ -150,6 +150,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => * +- Unapply * +- Alternatives * + * +- ParamClause -+- TypeParamClause + * +- TermParamClause * * +- TypeRepr -+- NamedType -+- TermRef * | +- TypeRef @@ -414,9 +416,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Methods of the module object `val DefDef` */ trait DefDefModule { this: DefDef.type => - 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): (String, List[TypeDef], List[List[ValDef]], TypeTree, Option[Term]) + def apply(symbol: Symbol, rhsFn: List[List[Tree]] => Option[Term]): DefDef + def copy(original: Tree)(name: String, paramss: List[ParamClause], tpt: TypeTree, rhs: Option[Term]): DefDef + def unapply(ddef: DefDef): (String, List[ParamClause], TypeTree, Option[Term]) } /** Makes extension methods on `DefDef` available without any imports */ @@ -425,8 +427,10 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Extension methods of `DefDef` */ trait DefDefMethods: extension (self: DefDef) - def typeParams: List[TypeDef] - def paramss: List[List[ValDef]] + def paramss: List[ParamClause] + def leadingTypeParams: List[TypeDef] + def trailingParamss: List[ParamClause] + def termParamss: List[TermParamClause] def returnTpt: TypeTree def rhs: Option[Term] end extension @@ -1921,6 +1925,78 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => end extension end AlternativesMethods + /** A parameter clause `(x1: X1, ..., xn: Xx)` or `[X1, ..., Xn]` */ + type ParamClause <: AnyRef + + /** Module object of `type ParamClause` */ + val ParamClause: ParamClauseModule + + /** Methods of the module object `val ParamClause` */ + trait ParamClauseModule { this: ParamClause.type => + } + + /** Makes extension methods on `ParamClause` available without any imports */ + given ParamClauseMethods: ParamClauseMethods + + /** Extension methods of `ParamClause` */ + trait ParamClauseMethods: + extension (self: ParamClause) + /** List of parameters of the clause */ + def params: List[ValDef] | List[TypeDef] + end ParamClauseMethods + + /** A term parameter clause `(x1: X1, ..., xn: Xx)` */ + type TermParamClause <: ParamClause + + /** `TypeTest` that allows testing at runtime in a pattern match if a `ParamClause` is a `TermParamClause` */ + given TermParamClauseTypeTest: TypeTest[ParamClause, TermParamClause] + + /** Module object of `type TermParamClause` */ + val TermParamClause: TermParamClauseModule + + /** Methods of the module object `val TermParamClause` */ + trait TermParamClauseModule { this: TermParamClause.type => + def apply(params: List[ValDef]): TermParamClause + def unapply(x: TermParamClause): Some[List[ValDef]] + } + + /** Makes extension methods on `TermParamClause` available without any imports */ + given TermParamClauseMethods: TermParamClauseMethods + + /** Extension methods of `TermParamClause` */ + trait TermParamClauseMethods: + extension (self: TermParamClause) + /** List of parameters of the clause */ + def params: List[ValDef] + /** Is this a given parameter clause `(implicit X1, ..., Xn)`, `(given X1, ..., Xn)` or `(given x1: X1, ..., xn: Xn)` */ + def isImplicit: Boolean + end TermParamClauseMethods + + /** A type parameter clause `[X1, ..., Xn]` */ + type TypeParamClause <: ParamClause + + /** `TypeTest` that allows testing at runtime in a pattern match if a `ParamClause` is a `TypeParamClause` */ + given TypeParamClauseTypeTest: TypeTest[ParamClause, TypeParamClause] + + /** Module object of `type TypeParamClause` */ + val TypeParamClause: TypeParamClauseModule + + /** Methods of the module object `val TypeParamClause` */ + trait TypeParamClauseModule { this: TypeParamClause.type => + def apply(params: List[TypeDef]): TypeParamClause + def unapply(x: TypeParamClause): Some[List[TypeDef]] + } + + /** Makes extension methods on `TypeParamClause` available without any imports */ + given TypeParamClauseMethods: TypeParamClauseMethods + + /** Extension methods of `TypeParamClause` */ + trait TypeParamClauseMethods: + extension (self: TypeParamClause) + /** List of parameters of the clause */ + def params: List[TypeDef] + end TypeParamClauseMethods + ////////////////////// // SELECTORS // ///////////////////// @@ -2618,6 +2694,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Extension methods of `MethodType` */ trait MethodTypeMethods: extension (self: MethodType) + /** Is this the type of given parameter clause `(implicit X1, ..., Xn)`, `(given X1, ..., Xn)` or `(given x1: X1, ..., xn: Xn)` */ def isImplicit: Boolean def isErased: Boolean def param(idx: Int): TypeRepr @@ -3900,9 +3977,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => case vdef @ ValDef(_, tpt, rhs) => val owner = vdef.symbol foldTrees(foldTree(x, tpt)(owner), rhs)(owner) - case ddef @ DefDef(_, tparams, vparamss, tpt, rhs) => + case ddef @ DefDef(_, paramss, tpt, rhs) => val owner = ddef.symbol - foldTrees(foldTree(vparamss.foldLeft(foldTrees(x, tparams)(owner))((acc, y) => foldTrees(acc, y)(owner)), tpt)(owner), rhs)(owner) + foldTrees(foldTree(paramss.foldLeft(x)((acc, y) => foldTrees(acc, y.params)(owner)), tpt)(owner), rhs)(owner) case tdef @ TypeDef(_, rhs) => val owner = tdef.symbol foldTree(x, rhs)(owner) @@ -4011,7 +4088,11 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => ValDef.copy(tree)(tree.name, tpt1, rhs1) case tree: DefDef => val owner = tree.symbol - DefDef.copy(tree)(tree.name, transformSubTrees(tree.typeParams)(owner), tree.paramss mapConserve (x => transformSubTrees(x)(owner)), transformTypeTree(tree.returnTpt)(owner), tree.rhs.map(x => transformTerm(x)(owner))) + val newParamClauses = tree.paramss.mapConserve { + case TypeParamClause(params) => TypeParamClause(transformSubTrees(params)(owner)) + case TermParamClause(params) => TermParamClause(transformSubTrees(params)(owner)) + } + DefDef.copy(tree)(tree.name, newParamClauses, transformTypeTree(tree.returnTpt)(owner), tree.rhs.map(x => transformTerm(x)(owner))) case tree: TypeDef => val owner = tree.symbol TypeDef.copy(tree)(tree.name, transformTree(tree.rhs)(owner)) diff --git a/library/src-non-bootstrapped/scala/quoted/Quotes.scala b/library/src-non-bootstrapped/scala/quoted/Quotes.scala index 60beaacbb966..0bce5e1adf0d 100644 --- a/library/src-non-bootstrapped/scala/quoted/Quotes.scala +++ b/library/src-non-bootstrapped/scala/quoted/Quotes.scala @@ -183,15 +183,17 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => trait DefDefModule { this: DefDef.type => 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): (String, List[TypeDef], List[List[ValDef]], TypeTree, Option[Term]) + def copy(original: Tree)(name: String, paramss: List[ParamClause], tpt: TypeTree, rhs: Option[Term]): DefDef = ??? + // def unapply(ddef: DefDef): (String, List[TypeDef], List[List[ValDef]], TypeTree, Option[Term]) + def unapply(ddef: DefDef): (String, List[ParamClause], TypeTree, Option[Term]) = ??? } given DefDefMethods: DefDefMethods trait DefDefMethods: extension (self: DefDef) + def paramss: List[ParamClause] = ??? def typeParams: List[TypeDef] - def paramss: List[List[ValDef]] def returnTpt: TypeTree def rhs: Option[Term] end extension @@ -1261,6 +1263,37 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => end extension end AlternativesMethods + type ParamClause <: AnyRef + + given ParamClauseMethods: ParamClauseMethods = ??? + + trait ParamClauseMethods: + extension (self: ParamClause) + def params: List[ValDef] | List[TypeDef] + end ParamClauseMethods + + type TermParamClause <: ParamClause + + given TermParamClauseTypeTest: TypeTest[ParamClause, TermParamClause] = ??? + + val TermParamClause: TermParamClauseModule = ??? + + trait TermParamClauseModule { this: TermParamClause.type => + def apply(params: List[ValDef]): TermParamClause + def unapply(x: TermParamClause): Some[List[ValDef]] + } + + type TypeParamClause <: AnyRef + + given TypeParamClauseTypeTest: TypeTest[ParamClause, TypeParamClause] = ??? + + val TypeParamClause: TypeParamClauseModule = ??? + + trait TypeParamClauseModule { this: TypeParamClause.type => + def apply(params: List[TypeDef]): TypeParamClause + def unapply(x: TypeParamClause): Some[List[TypeDef]] + } + type Selector <: AnyRef val Selector: SelectorModule @@ -2517,9 +2550,10 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => case vdef @ ValDef(_, tpt, rhs) => val owner = vdef.symbol foldTrees(foldTree(x, tpt)(owner), rhs)(owner) - case ddef @ DefDef(_, tparams, vparamss, tpt, rhs) => + case ddef @ DefDef(_, paramss, tpt, rhs) => val owner = ddef.symbol - foldTrees(foldTree(vparamss.foldLeft(foldTrees(x, tparams)(owner))((acc, y) => foldTrees(acc, y)(owner)), tpt)(owner), rhs)(owner) + // foldTrees(foldTree(vparamss.foldLeft(foldTrees(x, tparams)(owner))((acc, y) => foldTrees(acc, y)(owner)), tpt)(owner), rhs)(owner) + ??? case tdef @ TypeDef(_, rhs) => val owner = tdef.symbol foldTree(x, rhs)(owner) @@ -2607,7 +2641,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => ValDef.copy(tree)(tree.name, tpt1, rhs1) case tree: DefDef => val owner = tree.symbol - DefDef.copy(tree)(tree.name, transformSubTrees(tree.typeParams)(owner), tree.paramss mapConserve (x => transformSubTrees(x)(owner)), transformTypeTree(tree.returnTpt)(owner), tree.rhs.map(x => transformTerm(x)(owner))) + // DefDef.copy(tree)(tree.name, transformSubTrees(tree.typeParams)(owner), tree.paramss mapConserve (x => transformSubTrees(x)(owner)), transformTypeTree(tree.returnTpt)(owner), tree.rhs.map(x => transformTerm(x)(owner))) + ??? case tree: TypeDef => val owner = tree.symbol TypeDef.copy(tree)(tree.name, transformTree(tree.rhs)(owner)) diff --git a/library/src/scala/quoted/ExprMap.scala b/library/src/scala/quoted/ExprMap.scala index 36d98845453b..6f36a3a473e3 100644 --- a/library/src/scala/quoted/ExprMap.scala +++ b/library/src/scala/quoted/ExprMap.scala @@ -29,7 +29,7 @@ trait ExprMap: ValDef.copy(tree)(tree.name, tree.tpt, rhs1) case tree: DefDef => val owner = tree.symbol - DefDef.copy(tree)(tree.name, tree.typeParams, tree.paramss, tree.returnTpt, tree.rhs.map(x => transformTerm(x, tree.returnTpt.tpe)(owner))) + DefDef.copy(tree)(tree.name, tree.paramss, tree.returnTpt, tree.rhs.map(x => transformTerm(x, tree.returnTpt.tpe)(owner))) case tree: TypeDef => tree case tree: ClassDef => diff --git a/project/Build.scala b/project/Build.scala index 19244bfb36ec..8c6d25f7e2fa 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1337,6 +1337,33 @@ object Build { dependsOn(dottyLibrary(Bootstrapped)). settings(commonBootstrappedSettings). settings( + scalaInstance := { + val externalBootstrappedDeps = externalDependencyClasspath.in(`scala3-doc-bootstrapped`, Compile).value + val scalaLibrary = findArtifact(externalBootstrappedDeps, "scala-library") + + // IMPORTANT: We need to use actual jars to form the ScalaInstance and not + // just directories containing classfiles because sbt maintains a cache of + // compiler instances. This cache is invalidated based on timestamps + // however this is only implemented on jars, directories are never + // invalidated. + val tastyCore = packageBin.in(`tasty-core-bootstrapped`, Compile).value + val dottyLibrary = packageBin.in(`scala3-library-bootstrapped`, Compile).value + val dottyInterfaces = packageBin.in(`scala3-interfaces`, Compile).value + val dottyCompiler = packageBin.in(`scala3-compiler-bootstrapped`, Compile).value + val dottyDoc = packageBin.in(`scala3-doc-bootstrapped`, Compile).value + + val allJars = Seq(tastyCore, dottyLibrary, dottyInterfaces, dottyCompiler, dottyDoc) ++ externalBootstrappedDeps.map(_.data) + + makeScalaInstance( + state.value, + scalaVersion.value, + scalaLibrary, + dottyLibrary, + dottyCompiler, + allJars, + appConfiguration.value + ) + }, prepareCommunityBuild := { (publishLocal in `scala3-sbt-bridge`).value (publishLocal in `scala3-interfaces`).value diff --git a/scala3doc/src/dotty/dokka/tasty/ClassLikeSupport.scala b/scala3doc/src/dotty/dokka/tasty/ClassLikeSupport.scala index b823d6f6d7d7..b3e748a07919 100644 --- a/scala3doc/src/dotty/dokka/tasty/ClassLikeSupport.scala +++ b/scala3doc/src/dotty/dokka/tasty/ClassLikeSupport.scala @@ -45,7 +45,7 @@ trait ClassLikeSupport: .filter(s => s.exists && !s.isHiddenByVisibility) .map( _.tree.asInstanceOf[DefDef]) constr.fold(Nil)( - _.paramss.map(pList => ParametersList(pList.map(mkParameter(_, parameterModifier)), if isUsingModifier(pList) then "using " else "")) + _.termParamss.map(pList => ParametersList(pList.params.map(mkParameter(_, parameterModifier)), if isUsingModifier(pList.params) then "using " else "")) ) if classDef.symbol.flags.is(Flags.Module) then Kind.Object @@ -327,26 +327,25 @@ trait ClassLikeSupport: val paramLists = if emptyParamsList then Nil else if methodSymbol.isExtensionMethod then - val params = method.paramss + val params = method.termParamss if methodSymbol.isLeftAssoc || params.size == 1 then params.tail else params.head :: params.tail.drop(1) - else method.paramss - val genericTypes = if (methodSymbol.isClassConstructor) Nil else method.typeParams - + else method.termParamss + val genericTypes = if (methodSymbol.isClassConstructor) Nil else method.leadingTypeParams val basicKind: Kind.Def = Kind.Def( genericTypes.map(mkTypeArgument), - paramLists.map(pList => ParametersList(pList.map(mkParameter(_, paramPrefix)), if isUsingModifier(pList) then "using " else "")) + paramLists.map(pList => ParametersList(pList.params.map(mkParameter(_, paramPrefix)), if isUsingModifier(pList.params) then "using " else "")) ) val methodKind = if methodSymbol.isClassConstructor then Kind.Constructor(basicKind) else if methodSymbol.flags.is(Flags.Implicit) then extractImplicitConversion(method.returnTpt.tpe) match - case Some(conversion) if paramLists.size == 0 || (paramLists.size == 1 && paramLists.head.size == 0) => + case Some(conversion) if paramLists.size == 0 || (paramLists.size == 1 && paramLists.head.params.size == 0) => Kind.Implicit(basicKind, Some(conversion)) - case None if paramLists.size == 1 && paramLists(0).size == 1 => + case None if paramLists.size == 1 && paramLists(0).params.size == 1 => Kind.Implicit(basicKind, Some( ImplicitConversion( - paramLists(0)(0).tpt.tpe.typeSymbol.dri, + paramLists(0).params(0).tpt.tpe.typeSymbol.dri, method.returnTpt.tpe.typeSymbol.dri ) )) diff --git a/scala3doc/src/dotty/dokka/tasty/SymOps.scala b/scala3doc/src/dotty/dokka/tasty/SymOps.scala index ab851e94bf1f..97664f510cbb 100644 --- a/scala3doc/src/dotty/dokka/tasty/SymOps.scala +++ b/scala3doc/src/dotty/dokka/tasty/SymOps.scala @@ -102,9 +102,9 @@ class SymOps[Q <: Quotes](val q: Q): def extendedSymbol: Option[ValDef] = Option.when(sym.isExtensionMethod){ - val params = sym.tree.asInstanceOf[DefDef].paramss - if isLeftAssoc(sym) || params.size == 1 then params(0)(0) - else params(1)(0) + val termParamss = sym.tree.asInstanceOf[DefDef].termParamss + if isLeftAssoc(sym) || termParamss.size == 1 then termParamss(0).params(0) + else termParamss(1).params(0) } // TODO #22 make sure that DRIs are unique plus probably reuse semantic db code? diff --git a/scala3doc/src/dotty/dokka/tasty/SyntheticSupport.scala b/scala3doc/src/dotty/dokka/tasty/SyntheticSupport.scala index 7e923b5007a9..6b467829299c 100644 --- a/scala3doc/src/dotty/dokka/tasty/SyntheticSupport.scala +++ b/scala3doc/src/dotty/dokka/tasty/SyntheticSupport.scala @@ -46,9 +46,9 @@ trait SyntheticsSupport: def constructorWithoutParamLists(c: ClassDef): Boolean = !isValidPos(c.constructor.pos) || { val end = c.constructor.pos.end - val typesEnd = c.constructor.typeParams.lastOption.fold(end - 1)(_.pos.end) + val typesEnd = c.constructor.leadingTypeParams.lastOption.fold(end - 1)(_.pos.end) val classDefTree = c.constructor.show - c.constructor.typeParams.nonEmpty && end <= typesEnd + 1 + c.constructor.leadingTypeParams.nonEmpty && end <= typesEnd + 1 } // TODO: #49 Remove it after TASTY-Reflect release with published flag Extension diff --git a/tests/neg-staging/i5941/macro_1.scala b/tests/neg-staging/i5941/macro_1.scala index 150c3c7d5b12..19e40205e10c 100644 --- a/tests/neg-staging/i5941/macro_1.scala +++ b/tests/neg-staging/i5941/macro_1.scala @@ -24,7 +24,7 @@ object Lens { case Inlined( None, Nil, Block( - DefDef(_, Nil, (param :: Nil) :: Nil, _, Some(Select(o, field))) :: Nil, + DefDef(_, TermParamClause(param :: Nil) :: Nil, _, Some(Select(o, field))) :: Nil, Lambda(meth, _) ) ) if o.symbol == param.symbol => diff --git a/tests/pos-special/i7592/Macros_1.scala b/tests/pos-special/i7592/Macros_1.scala index 6a528ca073ba..4794c704c61f 100644 --- a/tests/pos-special/i7592/Macros_1.scala +++ b/tests/pos-special/i7592/Macros_1.scala @@ -12,7 +12,7 @@ def compileImpl[T](expr : Expr[T])(using Quotes) : Expr[T] = { case s : (Select|Ident) => { if( s.symbol.isDefDef ) { s.symbol.tree match { - case DefDef(name, typeParams, params, returnTp, Some(rhs)) => proc(rhs) + case DefDef(name, paramss, returnTp, Some(rhs)) => proc(rhs) } } else { ??? diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-2.check b/tests/run-custom-args/Yretain-trees/tasty-definitions-2.check index bb713fb9d303..3c2b67edfde0 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-2.check +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-2.check @@ -1,3 +1,3 @@ -DefDef("foo", Nil, Nil, TypeIdent("Int"), Some(Apply(Select(Literal(IntConstant(1)), "+"), List(Literal(IntConstant(2)))))) +DefDef("foo", Nil, TypeIdent("Int"), Some(Apply(Select(Literal(IntConstant(1)), "+"), List(Literal(IntConstant(2)))))) ValDef("bar", TypeIdent("Int"), Some(Apply(Select(Literal(IntConstant(2)), "+"), List(Literal(IntConstant(3)))))) Bind("x", Ident("_")) diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-3.check b/tests/run-custom-args/Yretain-trees/tasty-definitions-3.check index 11668d95952e..3cdc1b6b29f7 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-3.check +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-3.check @@ -1,3 +1,3 @@ -DefDef("foo", Nil, Nil, Inferred(), None) +DefDef("foo", Nil, Inferred(), None) ValDef("bar", Inferred(), None) Bind("x", Ident("_")) diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check index 5e16ce08121f..678febe7dce2 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners.check @@ -2,10 +2,10 @@ foo ValDef("macro", Inferred(), None) bar -DefDef("foo", Nil, Nil, Inferred(), None) +DefDef("foo", Nil, Inferred(), None) bar2 -DefDef("foo", Nil, Nil, Inferred(), None) +DefDef("foo", Nil, Inferred(), None) foo2 ValDef("macro", Inferred(), None) @@ -17,11 +17,11 @@ baz2 ValDef("foo2", Inferred(), None) -ClassDef("A", DefDef("", Nil, List(Nil), Inferred(), None), List(Inferred()), Nil, None, List(TypeDef("B", TypeBoundsTree(Inferred(), Inferred())), DefDef("b", Nil, Nil, Inferred(), None), ValDef("b2", Inferred(), None))) +ClassDef("A", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Inferred()), Nil, None, List(TypeDef("B", TypeBoundsTree(Inferred(), Inferred())), DefDef("b", Nil, Inferred(), None), ValDef("b2", Inferred(), None))) b -ClassDef("A", DefDef("", Nil, List(Nil), Inferred(), None), List(Inferred()), Nil, None, List(TypeDef("B", TypeBoundsTree(Inferred(), Inferred())), DefDef("b", Nil, Nil, Inferred(), None), ValDef("b2", Inferred(), None))) +ClassDef("A", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Inferred()), Nil, None, List(TypeDef("B", TypeBoundsTree(Inferred(), Inferred())), DefDef("b", Nil, Inferred(), None), ValDef("b2", Inferred(), None))) b2 -ClassDef("A", DefDef("", Nil, List(Nil), Inferred(), None), List(Inferred()), Nil, None, List(TypeDef("B", TypeBoundsTree(Inferred(), Inferred())), DefDef("b", Nil, Nil, Inferred(), None), ValDef("b2", Inferred(), None))) +ClassDef("A", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Inferred()), Nil, None, List(TypeDef("B", TypeBoundsTree(Inferred(), Inferred())), DefDef("b", Nil, Inferred(), None), ValDef("b2", Inferred(), None))) diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala index da28a2616e8e..11be6e926a5f 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala @@ -22,7 +22,7 @@ object Macros { import quotes.reflect._ override def traverseTree(tree: Tree)(owner: Symbol): Unit = { tree match { - case tree @ DefDef(name, _, _, _, _) => + case tree @ DefDef(name, _, _, _) => buff.append(name) buff.append("\n") buff.append(tree.symbol.owner.tree.show(using Printer.TreeStructure)) diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check index 92665686d040..e66a336fb836 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1.check @@ -1,2 +1,2 @@ -DefDef("foo", Nil, Nil, TypeIdent("Int"), Some(Apply(Select(Literal(IntConstant(1)), "+"), List(Literal(IntConstant(2)))))) +DefDef("foo", Nil, TypeIdent("Int"), Some(Apply(Select(Literal(IntConstant(1)), "+"), List(Literal(IntConstant(2)))))) ValDef("bar", TypeIdent("Int"), Some(Apply(Select(Literal(IntConstant(2)), "+"), List(Literal(IntConstant(3)))))) diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check index 6030480e8861..70f474a9e253 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2.check @@ -1,2 +1,2 @@ -DefDef("foo", Nil, Nil, Inferred(), None) +DefDef("foo", Nil, Inferred(), None) ValDef("bar", Inferred(), None) diff --git a/tests/run-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala b/tests/run-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala index 4c89008b3618..73f71a0f7dd4 100644 --- a/tests/run-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala +++ b/tests/run-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala @@ -11,7 +11,7 @@ class TastyInterpreter extends TastyInspector { override def traverseTree(tree: Tree)(owner: Symbol): Unit = tree match { // TODO: check the correct sig and object enclosement for main - case DefDef("main", _, _, _, Some(rhs)) => + case DefDef("main", _, _, Some(rhs)) => val interpreter = new jvm.Interpreter interpreter.eval(rhs)(using Map.empty) diff --git a/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala b/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala index 0118575ac861..73badb893599 100644 --- a/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala +++ b/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala @@ -28,7 +28,7 @@ abstract class TreeInterpreter[Q <: Quotes & Singleton](using val q: Q) { // withLocalValue(`this`, inst) { sym.tree match case ddef: DefDef => - val syms = ddef.paramss.headOption.getOrElse(Nil).map(_.symbol) + val syms = ddef.termParamss.headOption.map(_.params).getOrElse(Nil).map(_.symbol) withLocalValues(syms, args.map(LocalValue.valFrom(_))) { eval(ddef.rhs.get) } @@ -45,7 +45,7 @@ abstract class TreeInterpreter[Q <: Quotes & Singleton](using val q: Q) { val evaluatedArgs = argss.flatten.map(arg => LocalValue.valFrom(eval(arg))) fn.symbol.tree match case ddef: DefDef => - val syms = ddef.paramss.headOption.getOrElse(Nil).map(_.symbol) + val syms = ddef.termParamss.headOption.map(_.params).getOrElse(Nil).map(_.symbol) withLocalValues(syms, evaluatedArgs) { eval(ddef.rhs.get) } @@ -75,7 +75,7 @@ abstract class TreeInterpreter[Q <: Quotes & Singleton](using val q: Q) { else LocalValue.valFrom(evalRhs) accEnv.updated(stat.symbol, evalRef) - case DefDef(_, _, _, _, _) => + case DefDef(_, _, _, _) => // TODO: record the environment for closure purposes accEnv case stat => diff --git a/tests/run-macros/exports.check b/tests/run-macros/exports.check index 4f4fc1f0e360..f17ea798db1c 100644 --- a/tests/run-macros/exports.check +++ b/tests/run-macros/exports.check @@ -11,6 +11,6 @@ reflection show: () } reflection show extractors: -Inlined(None, Nil, Block(List(ValDef("Observer", TypeIdent("Observer$"), Some(Apply(Select(New(TypeIdent("Observer$")), ""), Nil))), ClassDef("Observer$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Observer")), None)), List(Export(Ident("Messages"), List(SimpleSelector(count))), DefDef("count", Nil, Nil, Inferred(), Some(Select(Ident("Messages"), "count")))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ValDef("Observer", TypeIdent("Observer$"), Some(Apply(Select(New(TypeIdent("Observer$")), ""), Nil))), ClassDef("Observer$", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Observer")), None)), List(Export(Ident("Messages"), List(SimpleSelector(count))), DefDef("count", Nil, Inferred(), Some(Select(Ident("Messages"), "count")))))), Literal(UnitConstant()))) visited exports with splice visited exports with splice inverted diff --git a/tests/run-macros/i6988/FirstArg_1.scala b/tests/run-macros/i6988/FirstArg_1.scala index a2a44c507bad..d3f9176456df 100644 --- a/tests/run-macros/i6988/FirstArg_1.scala +++ b/tests/run-macros/i6988/FirstArg_1.scala @@ -19,7 +19,7 @@ object Macros { if owner.isClassDef then owner.tree match case tdef: ClassDef => - tdef.constructor.paramss map { _ map {_.symbol }} + tdef.constructor.paramss map { _.params map {_.symbol }} else enclosingParamList(owner.owner) def literal(value: String): Expr[String] = diff --git a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala index 594ca3ba6589..7d6f234bf35d 100644 --- a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala @@ -70,7 +70,7 @@ object UnsafeExpr { } private def paramsAndBody[R](using Quotes)(f: Expr[Any]): (List[quotes.reflect.ValDef], Expr[R]) = { import quotes.reflect._ - val Block(List(DefDef("$anonfun", Nil, List(params), _, Some(body))), Closure(Ident("$anonfun"), None)) = f.asTerm.etaExpand(Symbol.spliceOwner) + val Block(List(DefDef("$anonfun", List(TermParamClause(params)), _, Some(body))), Closure(Ident("$anonfun"), None)) = f.asTerm.etaExpand(Symbol.spliceOwner) (params, body.asExpr.asInstanceOf[Expr[R]]) } diff --git a/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala index 9d9c33931e70..e8570c48cc3f 100644 --- a/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala @@ -83,7 +83,7 @@ object UnsafeExpr { } private def paramsAndBody[R](using Quotes)(f: Expr[Any]): (List[quotes.reflect.ValDef], Expr[R]) = { import quotes.reflect._ - val Block(List(DefDef("$anonfun", Nil, List(params), _, Some(body))), Closure(Ident("$anonfun"), None)) = f.asTerm.etaExpand(Symbol.spliceOwner) + val Block(List(DefDef("$anonfun", List(TermParamClause(params)), _, Some(body))), Closure(Ident("$anonfun"), None)) = f.asTerm.etaExpand(Symbol.spliceOwner) (params, body.asExpr.asInstanceOf[Expr[R]]) } diff --git a/tests/run-macros/quote-matching-open/Macro_1.scala b/tests/run-macros/quote-matching-open/Macro_1.scala index 1b8bd6975101..b01f8e5a1e72 100644 --- a/tests/run-macros/quote-matching-open/Macro_1.scala +++ b/tests/run-macros/quote-matching-open/Macro_1.scala @@ -34,7 +34,7 @@ object UnsafeExpr { } private def paramsAndBody[R](using Quotes)(f: Expr[Any]): (List[quotes.reflect.ValDef], Expr[R]) = { import quotes.reflect._ - val Block(List(DefDef("$anonfun", Nil, List(params), _, Some(body))), Closure(Ident("$anonfun"), None)) = f.asTerm.etaExpand(Symbol.spliceOwner) + val Block(List(DefDef("$anonfun", List(TermParamClause(params)), _, Some(body))), Closure(Ident("$anonfun"), None)) = f.asTerm.etaExpand(Symbol.spliceOwner) (params, body.asExpr.asInstanceOf[Expr[R]]) } 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 07345177c562..ecfed89ded8a 100644 --- a/tests/run-macros/tasty-create-method-symbol/Macro_1.scala +++ b/tests/run-macros/tasty-create-method-symbol/Macro_1.scala @@ -18,11 +18,10 @@ object Macros { assert(sym1.name == "sym1") val sym1Statements : List[Statement] = List( DefDef(sym1, { - case List() => { case List(List(a, b)) => Some('{ ${ a.asExpr.asInstanceOf[Expr[Int]] } - ${ b.asExpr.asInstanceOf[Expr[Int]] } }.asTerm) } - }), + ), '{ assert(${ Apply(Ref(sym1), List(Literal(IntConstant(2)), Literal(IntConstant(3)))).asExpr.asInstanceOf[Expr[Int]] } == -1) }.asTerm) // test for no argument list (no Apply node) @@ -34,11 +33,10 @@ object Macros { assert(sym2.name == "sym2") val sym2Statements : List[Statement] = List( DefDef(sym2, { - case List() => { case List() => Some(Literal(IntConstant(2))) } - }), + ), '{ assert(${ Ref(sym2).asExpr.asInstanceOf[Expr[Int]] } == 2) }.asTerm) // test for multiple argument lists @@ -54,11 +52,10 @@ object Macros { assert(sym3.name == "sym3") val sym3Statements : List[Statement] = List( DefDef(sym3, { - case List() => { - case List(List(a), List(b)) => + case List(List(a: Term), List(b)) => Some(a) } - }), + ), '{ assert(${ Apply(Apply(Ref(sym3), List(Literal(IntConstant(3)))), List(Literal(IntConstant(3)))).asExpr.asInstanceOf[Expr[Int]] } == 3) }.asTerm) // test for recursive references @@ -72,7 +69,6 @@ object Macros { assert(sym4.name == "sym4") val sym4Statements : List[Statement] = List( DefDef(sym4, { - case List() => { case List(List(x)) => Some('{ if ${ x.asExpr.asInstanceOf[Expr[Int]] } == 0 @@ -80,7 +76,7 @@ object Macros { else ${ Apply(Ref(sym4), List('{ ${ x.asExpr.asInstanceOf[Expr[Int]] } - 1 }.asTerm)).asExpr.asInstanceOf[Expr[Int]] } }.asTerm) } - }), + ), '{ assert(${ Apply(Ref(sym4), List(Literal(IntConstant(4)))).asExpr.asInstanceOf[Expr[Int]] } == 0) }.asTerm) // test for nested functions (one symbol is the other's parent, and we use a Closure) @@ -94,7 +90,6 @@ object Macros { assert(sym5.name == "sym5") val sym5Statements : List[Statement] = List( DefDef(sym5, { - case List() => { case List(List(x)) => Some { val sym51 : Symbol = Symbol.newMethod( @@ -106,15 +101,14 @@ object Macros { Block( List( DefDef(sym51, { - case List() => { case List(List(xx)) => Some('{ ${ x.asExpr.asInstanceOf[Expr[Int]] } - ${ xx.asExpr.asInstanceOf[Expr[Int]] } }.asTerm) } - })), + )), Closure(Ref(sym51), None)) } } - }), + ), '{ assert(${ Apply(Ref(sym5), List(Literal(IntConstant(5)))).asExpr.asInstanceOf[Expr[Int=>Int]] }(4) == 1) }.asTerm) // test mutually recursive definitions @@ -136,7 +130,6 @@ object Macros { assert(sym6_2.name == "sym6_2") val sym6Statements : List[Statement] = List( DefDef(sym6_1, { - case List() => { case List(List(x)) => Some { '{ @@ -147,9 +140,8 @@ object Macros { }.asTerm } } - }), + ), DefDef(sym6_2, { - case List() => { case List(List(x)) => Some { '{ @@ -161,7 +153,7 @@ object Macros { } } - }), + ), '{ assert(${ Apply(Ref(sym6_2), List(Literal(IntConstant(6)))).asExpr.asInstanceOf[Expr[Int]] } == 0) }.asTerm) // test polymorphic methods by synthesizing an identity method @@ -177,11 +169,10 @@ object Macros { assert(sym7.name == "sym7") val sym7Statements : List[Statement] = List( DefDef(sym7, { - case List(t) => { - case List(List(x)) => - Some(Typed(x, Inferred(t))) + case List(List(t: TypeTree), List(x: Term)) => + Some(Typed(x, t)) } - }), + ), '{ assert(${ Apply(TypeApply(Ref(sym7), List(Inferred(TypeRepr.of[Int]))), List(Literal(IntConstant(7)))).asExpr.asInstanceOf[Expr[Int]] } == 7) }.asTerm) Block( diff --git a/tests/run-macros/tasty-extractors-1.check b/tests/run-macros/tasty-extractors-1.check index 7d8d642dad85..b233da95fa6e 100644 --- a/tests/run-macros/tasty-extractors-1.check +++ b/tests/run-macros/tasty-extractors-1.check @@ -91,30 +91,30 @@ TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") Inlined(None, Nil, Block(List(ValDef("b", TypeIdent("Int"), Some(Literal(IntConstant(3))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f1", Nil, Nil, TypeIdent("Int"), Some(Literal(IntConstant(3))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(DefDef("f1", Nil, TypeIdent("Int"), Some(Literal(IntConstant(3))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f2", Nil, Nil, TypeIdent("Int"), Some(Return(Literal(IntConstant(4)), IsDefDefSymbol())))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(DefDef("f2", Nil, TypeIdent("Int"), Some(Return(Literal(IntConstant(4)), IsDefDefSymbol())))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f3", Nil, List(List(ValDef("i", TypeIdent("Int"), None))), TypeIdent("Int"), Some(Ident("i")))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(DefDef("f3", List(TermParamClause(List(ValDef("i", TypeIdent("Int"), None)))), TypeIdent("Int"), Some(Ident("i")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f4", Nil, List(List(ValDef("i", TypeIdent("Int"), None)), List(ValDef("j", TypeIdent("Int"), None))), TypeIdent("Int"), Some(Apply(Select(Ident("i"), "+"), List(Ident("j")))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(DefDef("f4", List(TermParamClause(List(ValDef("i", TypeIdent("Int"), None))), TermParamClause(List(ValDef("j", TypeIdent("Int"), None)))), TypeIdent("Int"), Some(Apply(Select(Ident("i"), "+"), List(Ident("j")))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f5", Nil, List(List(ValDef("i", TypeIdent("Int"), None))), TypeIdent("Int"), Some(Ident("i"))), DefDef("f5$default$1", Nil, Nil, Inferred(), Some(Literal(IntConstant(9))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(DefDef("f5", List(TermParamClause(List(ValDef("i", TypeIdent("Int"), None)))), TypeIdent("Int"), Some(Ident("i"))), DefDef("f5$default$1", Nil, Inferred(), Some(Literal(IntConstant(9))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f6", List(TypeDef("T", TypeBoundsTree(Inferred(), Inferred()))), List(List(ValDef("x", TypeIdent("T"), None))), TypeIdent("T"), Some(Ident("x")))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(DefDef("f6", List(TypeParamClause(List(TypeDef("T", TypeBoundsTree(Inferred(), Inferred())))), TermParamClause(List(ValDef("x", TypeIdent("T"), None)))), TypeIdent("T"), Some(Ident("x")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f7", List(TypeDef("T", TypeBoundsTree(Inferred(), Inferred()))), List(List(ValDef("x", TypeIdent("T"), None))), Singleton(Ident("x")), Some(Ident("x")))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(DefDef("f7", List(TypeParamClause(List(TypeDef("T", TypeBoundsTree(Inferred(), Inferred())))), TermParamClause(List(ValDef("x", TypeIdent("T"), None)))), Singleton(Ident("x")), Some(Ident("x")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("f8", Nil, List(List(ValDef("i", Annotated(Applied(Inferred(), List(TypeIdent("Int"))), Apply(Select(New(Inferred()), ""), Nil)), None))), TypeIdent("Int"), Some(Literal(IntConstant(9))))), Apply(Ident("f8"), List(Typed(Repeated(List(Literal(IntConstant(1)), Literal(IntConstant(2)), Literal(IntConstant(3))), Inferred()), Inferred()))))) +Inlined(None, Nil, Block(List(DefDef("f8", List(TermParamClause(List(ValDef("i", Annotated(Applied(Inferred(), List(TypeIdent("Int"))), Apply(Select(New(Inferred()), ""), Nil)), None)))), TypeIdent("Int"), Some(Literal(IntConstant(9))))), Apply(Ident("f8"), List(Typed(Repeated(List(Literal(IntConstant(1)), Literal(IntConstant(2)), Literal(IntConstant(3))), Inferred()), Inferred()))))) TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "")), "scala"), "Int") -Inlined(None, Nil, Block(List(DefDef("f9", Nil, List(List(ValDef("i", ByName(TypeIdent("Int")), None))), TypeIdent("Int"), Some(Ident("i")))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(DefDef("f9", List(TermParamClause(List(ValDef("i", ByName(TypeIdent("Int")), None)))), TypeIdent("Int"), Some(Ident("i")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") diff --git a/tests/run-macros/tasty-extractors-2.check b/tests/run-macros/tasty-extractors-2.check index 6a8173dd5571..a5a3c806c923 100644 --- a/tests/run-macros/tasty-extractors-2.check +++ b/tests/run-macros/tasty-extractors-2.check @@ -1,7 +1,7 @@ Inlined(None, Nil, Block(List(ValDef("x", Inferred(), Some(Literal(IntConstant(1))))), Assign(Ident("x"), Literal(IntConstant(2))))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(DefDef("$anonfun", Nil, List(List(ValDef("x", TypeIdent("Int"), None))), Inferred(), Some(Ident("x")))), Closure(Ident("$anonfun"), None))) +Inlined(None, Nil, Block(List(DefDef("$anonfun", List(TermParamClause(List(ValDef("x", TypeIdent("Int"), None)))), Inferred(), Some(Ident("x")))), Closure(Ident("$anonfun"), None))) AppliedType(TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Function1"), List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "")), "scala"), "Int"), TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "")), "scala"), "Int"))) Inlined(None, Nil, Ident("???")) @@ -22,10 +22,10 @@ AndType(TypeRef(ThisType(TypeRef(NoPrefix(), "")), "Foo"), TypeRef(ThisTy Inlined(None, Nil, Typed(Literal(IntConstant(1)), Applied(TypeIdent("|"), List(TypeIdent("Int"), TypeIdent("String"))))) OrType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "")), "scala"), "Int"), TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "scala")), "Predef"), "String")) -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, Nil)), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, Nil)), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ValDef("Foo", TypeIdent("Foo$"), Some(Apply(Select(New(TypeIdent("Foo$")), ""), Nil))), ClassDef("Foo$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo")), None)), Nil)), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ValDef("Foo", TypeIdent("Foo$"), Some(Apply(Select(New(TypeIdent("Foo$")), ""), Nil))), ClassDef("Foo$", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo")), None)), Nil)), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") Inlined(None, Nil, Block(List(TypeDef("Foo", TypeBoundsTree(Inferred(), Inferred()))), Literal(UnitConstant()))) @@ -37,69 +37,69 @@ TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") Inlined(None, Nil, Block(List(TypeDef("Foo", TypeBoundsTree(TypeIdent("Null"), TypeIdent("Object")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(0)))), DefDef("a_=", Nil, List(List(ValDef("x$1", Inferred(), None))), Inferred(), Some(Literal(UnitConstant())))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(0)))), DefDef("a_=", List(TermParamClause(List(ValDef("x$1", Inferred(), None)))), Inferred(), Some(Literal(UnitConstant())))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, Inferred(), Some(Literal(IntConstant(0))))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Inferred(), Some(Literal(IntConstant(0))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, Inferred(), Some(Literal(IntConstant(0))))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Inferred(), Some(Literal(IntConstant(0))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, Inferred(), Some(Literal(IntConstant(0))))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Inferred(), Some(Literal(IntConstant(0))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil), TypeSelect(Select(Ident("_root_"), "scala"), "Product"), TypeSelect(Select(Ident("_root_"), "scala"), "Serializable")), Nil, None, List(DefDef("copy", Nil, List(Nil), Inferred(), Some(Apply(Select(New(Inferred()), ""), Nil))))), ValDef("Foo", TypeIdent("Foo$"), Some(Apply(Select(New(TypeIdent("Foo$")), ""), Nil))), ClassDef("Foo$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo")), None)), List(DefDef("apply", Nil, List(Nil), Inferred(), Some(Apply(Select(New(Inferred()), ""), Nil))), DefDef("unapply", Nil, List(List(ValDef("x$1", Inferred(), None))), Singleton(Literal(BooleanConstant(true))), Some(Literal(BooleanConstant(true)))), DefDef("toString", Nil, Nil, Inferred(), Some(Literal(StringConstant("Foo"))))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil), TypeSelect(Select(Ident("_root_"), "scala"), "Product"), TypeSelect(Select(Ident("_root_"), "scala"), "Serializable")), Nil, None, List(DefDef("copy", List(TermParamClause(Nil)), Inferred(), Some(Apply(Select(New(Inferred()), ""), Nil))))), ValDef("Foo", TypeIdent("Foo$"), Some(Apply(Select(New(TypeIdent("Foo$")), ""), Nil))), ClassDef("Foo$", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo")), None)), List(DefDef("apply", List(TermParamClause(Nil)), Inferred(), Some(Apply(Select(New(Inferred()), ""), Nil))), DefDef("unapply", List(TermParamClause(List(ValDef("x$1", Inferred(), None)))), Singleton(Literal(BooleanConstant(true))), Some(Literal(BooleanConstant(true)))), DefDef("toString", Nil, Inferred(), Some(Literal(StringConstant("Foo"))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo1", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None)))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo1", DefDef("", List(TermParamClause(List(ValDef("a", TypeIdent("Int"), None)))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None)))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo2", DefDef("", Nil, List(List(ValDef("b", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("b", Inferred(), None)))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo2", DefDef("", List(TermParamClause(List(ValDef("b", TypeIdent("Int"), None)))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("b", Inferred(), None)))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo3", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None))), ValDef("Foo3", TypeIdent("Foo3$"), Some(Apply(Select(New(TypeIdent("Foo3$")), ""), Nil))), ClassDef("Foo3$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo3")), None)), List(DefDef("$lessinit$greater$default$1", Nil, Nil, Inferred(), Some(Literal(IntConstant(5))))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo3", DefDef("", List(TermParamClause(List(ValDef("a", TypeIdent("Int"), None)))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None))), ValDef("Foo3", TypeIdent("Foo3$"), Some(Apply(Select(New(TypeIdent("Foo3$")), ""), Nil))), ClassDef("Foo3$", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo3")), None)), List(DefDef("$lessinit$greater$default$1", Nil, Inferred(), Some(Literal(IntConstant(5))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo4", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None)), List(ValDef("b", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None)))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo4", DefDef("", List(TermParamClause(List(ValDef("a", TypeIdent("Int"), None))), TermParamClause(List(ValDef("b", TypeIdent("Int"), None)))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None)))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo5", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None)), List(ValDef("b", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None))), ValDef("Foo5", TypeIdent("Foo5$"), Some(Apply(Select(New(TypeIdent("Foo5$")), ""), Nil))), ClassDef("Foo5$", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo5")), None)), List(DefDef("$lessinit$greater$default$2", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), Some(Ident("a")))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo5", DefDef("", List(TermParamClause(List(ValDef("a", TypeIdent("Int"), None))), TermParamClause(List(ValDef("b", TypeIdent("Int"), None)))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None))), ValDef("Foo5", TypeIdent("Foo5$"), Some(Apply(Select(New(TypeIdent("Foo5$")), ""), Nil))), ClassDef("Foo5$", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, Some(ValDef("_", Singleton(Ident("Foo5")), None)), List(DefDef("$lessinit$greater$default$2", List(TermParamClause(List(ValDef("a", TypeIdent("Int"), None)))), Inferred(), Some(Ident("a")))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo6", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None)), List(ValDef("b", Singleton(Ident("a")), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None)))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo6", DefDef("", List(TermParamClause(List(ValDef("a", TypeIdent("Int"), None))), TermParamClause(List(ValDef("b", Singleton(Ident("a")), None)))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), ValDef("b", Inferred(), None)))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo7", DefDef("", Nil, List(List(ValDef("a", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), DefDef("", Nil, List(Nil), Inferred(), Some(Block(List(Apply(Select(This(Some("Foo7")), ""), List(Literal(IntConstant(6))))), Literal(UnitConstant()))))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo7", DefDef("", List(TermParamClause(List(ValDef("a", TypeIdent("Int"), None)))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), None), DefDef("", List(TermParamClause(Nil)), Inferred(), Some(Block(List(Apply(Select(This(Some("Foo7")), ""), List(Literal(IntConstant(6))))), Literal(UnitConstant()))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo8", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(Apply(Ident("println"), List(Literal(IntConstant(0))))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo8", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(Apply(Ident("println"), List(Literal(IntConstant(0))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo10", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(9))))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo10", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(9))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo11", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(10)))), DefDef("a_=", Nil, List(List(ValDef("x$1", Inferred(), None))), Inferred(), Some(Literal(UnitConstant())))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo11", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(10)))), DefDef("a_=", List(TermParamClause(List(ValDef("x$1", Inferred(), None)))), Inferred(), Some(Literal(UnitConstant())))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo12", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(11))))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo12", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("a", Inferred(), Some(Literal(IntConstant(11))))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, Nil), ClassDef("Bar", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(TypeIdent("Foo")), ""), Nil)), Nil, None, Nil)), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, Nil), ClassDef("Bar", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(TypeIdent("Foo")), ""), Nil)), Nil, None, Nil)), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo2", DefDef("", Nil, List(Nil), Inferred(), None), List(Inferred()), Nil, None, Nil), ClassDef("Bar", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil), TypeIdent("Foo2")), Nil, None, Nil)), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo2", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Inferred()), Nil, None, Nil), ClassDef("Bar", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil), TypeIdent("Foo2")), Nil, None, Nil)), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(List(ValDef("i", TypeIdent("Int"), None))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("i", Inferred(), None))), ClassDef("Bar", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(TypeIdent("Foo")), ""), List(Literal(IntConstant(1))))), Nil, None, Nil)), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", List(TermParamClause(List(ValDef("i", TypeIdent("Int"), None)))), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(ValDef("i", Inferred(), None))), ClassDef("Bar", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(TypeIdent("Foo")), ""), List(Literal(IntConstant(1))))), Nil, None, Nil)), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(TypeDef("X", TypeIdent("Int")))), DefDef("f", Nil, List(List(ValDef("a", TypeIdent("Foo"), None))), TypeSelect(Ident("a"), "X"), Some(Ident("???")))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(TypeDef("X", TypeIdent("Int")))), DefDef("f", List(TermParamClause(List(ValDef("a", TypeIdent("Foo"), None)))), TypeSelect(Ident("a"), "X"), Some(Ident("???")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(TypeDef("X", TypeBoundsTree(Inferred(), Inferred())))), DefDef("f", Nil, List(List(ValDef("a", Refined(TypeIdent("Foo"), List(TypeDef("X", TypeIdent("Int")))), None))), TypeSelect(Ident("a"), "X"), Some(Ident("???")))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ClassDef("Foo", DefDef("", List(TermParamClause(Nil)), Inferred(), None), List(Apply(Select(New(Inferred()), ""), Nil)), Nil, None, List(TypeDef("X", TypeBoundsTree(Inferred(), Inferred())))), DefDef("f", List(TermParamClause(List(ValDef("a", Refined(TypeIdent("Foo"), List(TypeDef("X", TypeIdent("Int")))), None)))), TypeSelect(Ident("a"), "X"), Some(Ident("???")))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit") -Inlined(None, Nil, Block(List(ValDef("lambda", Applied(Inferred(), List(TypeIdent("Int"), TypeIdent("Int"))), Some(Block(List(DefDef("$anonfun", Nil, List(List(ValDef("x", Inferred(), None))), Inferred(), Some(Ident("x")))), Closure(Ident("$anonfun"), None))))), Literal(UnitConstant()))) +Inlined(None, Nil, Block(List(ValDef("lambda", Applied(Inferred(), List(TypeIdent("Int"), TypeIdent("Int"))), Some(Block(List(DefDef("$anonfun", List(TermParamClause(List(ValDef("x", Inferred(), None)))), Inferred(), Some(Ident("x")))), Closure(Ident("$anonfun"), None))))), Literal(UnitConstant()))) TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit")