From 3ecfc57960364d121156f46e3649f0c1bc9f33d8 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 4 Jan 2021 13:43:58 +0100 Subject: [PATCH] Fix #10355: Run PostTyper before Staging PostTyper marks compilation units with `needsStaging` to enable this phase. --- compiler/src/dotty/tools/dotc/transform/Staging.scala | 2 ++ compiler/src/dotty/tools/repl/ReplCompiler.scala | 2 +- compiler/test-resources/repl/i10355 | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 compiler/test-resources/repl/i10355 diff --git a/compiler/src/dotty/tools/dotc/transform/Staging.scala b/compiler/src/dotty/tools/dotc/transform/Staging.scala index aa895fd01021..20183f71fc38 100644 --- a/compiler/src/dotty/tools/dotc/transform/Staging.scala +++ b/compiler/src/dotty/tools/dotc/transform/Staging.scala @@ -35,6 +35,8 @@ class Staging extends MacroTransform { override def phaseName: String = Staging.name + override def runsAfter: Set[String] = Set(PostTyper.name) + override def allowsImplicitSearch: Boolean = true override def checkPostCondition(tree: Tree)(using Context): Unit = diff --git a/compiler/src/dotty/tools/repl/ReplCompiler.scala b/compiler/src/dotty/tools/repl/ReplCompiler.scala index dc5e9b87b715..3580336830be 100644 --- a/compiler/src/dotty/tools/repl/ReplCompiler.scala +++ b/compiler/src/dotty/tools/repl/ReplCompiler.scala @@ -34,8 +34,8 @@ class ReplCompiler extends Compiler { override protected def frontendPhases: List[List[Phase]] = List( List(new REPLFrontEnd), List(new CollectTopLevelImports), + List(new PostTyper), List(new Staging), - List(new PostTyper) ) def newRun(initCtx: Context, state: State): Run = new Run(this, initCtx) { diff --git a/compiler/test-resources/repl/i10355 b/compiler/test-resources/repl/i10355 new file mode 100644 index 000000000000..bfe3af835c87 --- /dev/null +++ b/compiler/test-resources/repl/i10355 @@ -0,0 +1,5 @@ +scala> import scala.quoted._ +scala> def foo(expr: Expr[Any])(using Quotes) = expr match { case '{ $x: t } => '{ $x: Any } } +def foo(expr: quoted.Expr[Any])(using x$2: quoted.Quotes): quoted.Expr[Any] +scala> def bar(expr: Expr[Any])(using Quotes) = expr match { case '{ $x: t } => '{ val a: t = ??? ; ???} } +def bar(expr: quoted.Expr[Any])(using x$2: quoted.Quotes): quoted.Expr[Nothing]