Skip to content

Commit 617f309

Browse files
Fix TermRef prefixes not having their type healed (scala#20102)
Fixes scala#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)]( //... ```
2 parents 6a88601 + 8b3dadb commit 617f309

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class HealType(pos: SrcPos)(using Context) extends TypeMap {
3535
case tp: TermRef =>
3636
val inconsistentRoot = levelInconsistentRootOfPath(tp)
3737
if inconsistentRoot.exists then levelError(inconsistentRoot, tp, pos)
38-
else tp
38+
else mapOver(tp)
3939
case tp: AnnotatedType =>
4040
derivedAnnotatedType(tp, apply(tp.parent), tp.annot)
4141
case _ =>

tests/pos-macros/i19767.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.quoted.*
2+
3+
class ICons[K <: Singleton](val key: K)
4+
5+
def filterX(using Quotes): Unit =
6+
(??? : Expr[Any]) match
7+
case '{ $y : ICons[k1] } => '{ ICons($y.key) }

0 commit comments

Comments
 (0)