Skip to content

Commit da625cd

Browse files
committed
Check level consistency of SingletonTypeTree as a type
Fixes scala#8887
1 parent b0ad1e1 commit da625cd

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

compiler/src/dotty/tools/dotc/staging/CrossStageSafety.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class CrossStageSafety extends TreeMapWithStages {
6060
val healedType = healType(tree.srcPos)(tp1)
6161
if healedType == tree.tpe then tree
6262
else TypeTree(healedType).withSpan(tree.span)
63-
case _: RefTree if tree.isType =>
63+
case _: RefTree | _: SingletonTypeTree if tree.isType =>
6464
val healedType = healType(tree.srcPos)(tree.tpe)
6565
if healedType == tree.tpe then tree
6666
else TypeTree(healedType).withSpan(tree.span)

tests/neg-macros/i8887.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import scala.quoted._
2+
3+
def expr[X](x: Any)(using Quotes): Expr[Any] =
4+
'{ foo[x.type] } // error
5+
def foo[X]: Any = ???

tests/pos-macros/i8887.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import scala.quoted._
2+
inline def foo(x: Any): Any = ${ expr[x.type] }
3+
def expr[X](using Quotes): Expr[Any] = ???

0 commit comments

Comments
 (0)