Skip to content

Fix incorrect wrong staging level error for Singleton type #16237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
if body.isTerm then
// `quoted.runtime.Expr.quote[T](<body>)` --> `quoted.runtime.Expr.quote[T2](<body2>)`
val TypeApply(fun, targs) = quote.fun: @unchecked
val targs2 = targs.map(targ => TypeTree(healTypeOfTerm(quote.fun.srcPos)(targ.tpe)))
val targs2 = targs.map(targ => TypeTree(healType(quote.fun.srcPos)(targ.tpe)))
cpy.Apply(quote)(cpy.TypeApply(quote.fun)(fun, targs2), body2 :: Nil)
else
val quotes = quote.args.mapConserve(transform)
Expand Down Expand Up @@ -209,8 +209,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
case tp: ThisType if level != -1 && level != levelOf(tp.cls) =>
levelError(tp.cls, tp, pos)
case tp: AnnotatedType =>
val newAnnotTree = transform(tp.annot.tree)
derivedAnnotatedType(tp, apply(tp.parent), tp.annot.derivedAnnotation(newAnnotTree))
derivedAnnotatedType(tp, apply(tp.parent), tp.annot)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reasoning to allow us to ignore annotations here?

case _ =>
mapOver(tp)
}
Expand Down
4 changes: 4 additions & 0 deletions tests/pos-macros/i15709.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import quoted.*

inline def foo(s: Singleton): Unit = ${ fooImpl('s) }
def fooImpl(s: Expr[Singleton])(using Quotes) = '{}