diff --git a/compiler/src/dotty/tools/dotc/staging/CrossStageSafety.scala b/compiler/src/dotty/tools/dotc/staging/CrossStageSafety.scala index 98e060488f43..e3928538a183 100644 --- a/compiler/src/dotty/tools/dotc/staging/CrossStageSafety.scala +++ b/compiler/src/dotty/tools/dotc/staging/CrossStageSafety.scala @@ -60,7 +60,7 @@ class CrossStageSafety extends TreeMapWithStages { val healedType = healType(tree.srcPos)(tp1) if healedType == tree.tpe then tree else TypeTree(healedType).withSpan(tree.span) - case _: RefTree if tree.isType => + case _: RefTree | _: SingletonTypeTree if tree.isType => val healedType = healType(tree.srcPos)(tree.tpe) if healedType == tree.tpe then tree else TypeTree(healedType).withSpan(tree.span) diff --git a/tests/neg-macros/i8887.scala b/tests/neg-macros/i8887.scala new file mode 100644 index 000000000000..944544ba33dc --- /dev/null +++ b/tests/neg-macros/i8887.scala @@ -0,0 +1,5 @@ +import scala.quoted._ + +def expr[X](x: Any)(using Quotes): Expr[Any] = + '{ foo[x.type] } // error +def foo[X]: Any = ??? diff --git a/tests/neg-macros/quote-this-a.scala b/tests/neg-macros/quote-this-a.scala index 11621176526b..9f71aca0a7fb 100644 --- a/tests/neg-macros/quote-this-a.scala +++ b/tests/neg-macros/quote-this-a.scala @@ -4,9 +4,7 @@ class Foo { def f(using Quotes): Unit = '{ def bar[T](x: T): T = x - bar[ - this.type // error - ] { + bar[this.type] { this // error } } diff --git a/tests/pos-macros/i8887.scala b/tests/pos-macros/i8887.scala new file mode 100644 index 000000000000..5bfd5501063b --- /dev/null +++ b/tests/pos-macros/i8887.scala @@ -0,0 +1,3 @@ +import scala.quoted._ +inline def foo(x: Any): Any = ${ expr[x.type] } +def expr[X](using Quotes): Expr[Any] = ???