Skip to content

Commit

Permalink
Fix TermRef prefixes not having their type healed (#20102)
Browse files Browse the repository at this point in the history
Fixes #19767

In the minimization from the issue, after the splicing phase we ended up
with a quote with illegal `k1` types, which should have been healed
during the splicing phase:
```scala
'<k1$given2>{
  new ICons[(ICons[k1]#key : k1)](
  //...
```
To fix that, we now map over and heal the prefix of the TermRef as well,
so we end up with:
```scala
'<k1$given2>{
  new ICons[(ICons[k1$given2]#key : k1$given2)](
  //...
```
  • Loading branch information
nicolasstucki authored Apr 5, 2024
2 parents 6a88601 + 8b3dadb commit 617f309
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/staging/HealType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class HealType(pos: SrcPos)(using Context) extends TypeMap {
case tp: TermRef =>
val inconsistentRoot = levelInconsistentRootOfPath(tp)
if inconsistentRoot.exists then levelError(inconsistentRoot, tp, pos)
else tp
else mapOver(tp)
case tp: AnnotatedType =>
derivedAnnotatedType(tp, apply(tp.parent), tp.annot)
case _ =>
Expand Down
7 changes: 7 additions & 0 deletions tests/pos-macros/i19767.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.quoted.*

class ICons[K <: Singleton](val key: K)

def filterX(using Quotes): Unit =
(??? : Expr[Any]) match
case '{ $y : ICons[k1] } => '{ ICons($y.key) }

0 comments on commit 617f309

Please sign in to comment.