diff --git a/bench/tests/power-macro/PowerMacro.scala b/bench/tests/power-macro/PowerMacro.scala index 3a18f97e980e..a228467e4885 100644 --- a/bench/tests/power-macro/PowerMacro.scala +++ b/bench/tests/power-macro/PowerMacro.scala @@ -2,7 +2,7 @@ import scala.quoted.Expr object PowerMacro { - transparent def power(transparent n: Long, x: Double) = ~powerCode(n, '(x)) + rewrite def power(transparent n: Long, x: Double) = ~powerCode(n, '(x)) def powerCode(n: Long, x: Expr[Double]): Expr[Double] = if (n == 0) '(1.0) diff --git a/compiler/src/dotty/tools/dotc/CompilationUnit.scala b/compiler/src/dotty/tools/dotc/CompilationUnit.scala index f66313546081..c8355c8a782a 100644 --- a/compiler/src/dotty/tools/dotc/CompilationUnit.scala +++ b/compiler/src/dotty/tools/dotc/CompilationUnit.scala @@ -5,7 +5,7 @@ import core.Types.Type // Do not remove me #3383 import util.SourceFile import ast.{tpd, untpd} import tpd.{ Tree, TreeTraverser } -import typer.PrepareTransparent.InlineAccessors +import typer.PrepareInlineable.InlineAccessors import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.SymDenotations.ClassDenotation import dotty.tools.dotc.core.Symbols._ diff --git a/compiler/src/dotty/tools/dotc/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index 6316ad9399ac..d30b2808fcde 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -16,7 +16,7 @@ import scala.io.Codec import util.{Set => _, _} import reporting.Reporter import transform.TreeChecker -import rewrite.Rewrites +import rewrites.Rewrites import java.io.{BufferedWriter, OutputStreamWriter} import profile.Profiler diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 3b27999cad35..1104ecb9230e 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -815,6 +815,23 @@ object desugar { makeOp(right, left, Position(op.pos.start, right.pos.end)) } + /** Translate tuple expressions of arity <= 22 + * + * () ==> () + * (t) ==> t + * (t1, ..., tN) ==> TupleN(t1, ..., tN) + */ + def smallTuple(tree: Tuple)(implicit ctx: Context): Tree = { + val ts = tree.trees + val arity = ts.length + assert(arity <= Definitions.MaxTupleArity) + def tupleTypeRef = defn.TupleType(arity) + if (arity == 1) ts.head + else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleTypeRef), ts) + else if (arity == 0) unitLiteral + else Apply(ref(tupleTypeRef.classSymbol.companionModule.termRef), ts) + } + /** Make closure corresponding to function. * params => body * ==> @@ -1141,16 +1158,6 @@ object desugar { case PrefixOp(op, t) => val nspace = if (ctx.mode.is(Mode.Type)) tpnme else nme Select(t, nspace.UNARY_PREFIX ++ op.name) - case Tuple(ts) => - val arity = ts.length - def tupleTypeRef = defn.TupleType(arity) - if (arity > Definitions.MaxTupleArity) { - ctx.error(TupleTooLong(ts), tree.pos) - unitLiteral - } else if (arity == 1) ts.head - else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleTypeRef), ts) - else if (arity == 0) unitLiteral - else Apply(ref(tupleTypeRef.classSymbol.companionModule.termRef), ts) case WhileDo(cond, body) => // {