Skip to content

Commit 73af81e

Browse files
Check level consistency of SingletonTypeTree as a type (#17209)
Fixes #8887
2 parents e940957 + b08729b commit 73af81e

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
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/neg-macros/quote-this-a.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ class Foo {
44

55
def f(using Quotes): Unit = '{
66
def bar[T](x: T): T = x
7-
bar[
8-
this.type // error
9-
] {
7+
bar[this.type] {
108
this // error
119
}
1210
}

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)