Skip to content

Commit

Permalink
Backport "Heal stage inconsistent prefixes of type projections" (#18328)
Browse files Browse the repository at this point in the history
Backports #18239
  • Loading branch information
Kordyjan authored Aug 9, 2023
2 parents 555df53 + e1233d8 commit ee25abf
Show file tree
Hide file tree
Showing 3 changed files with 25 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 @@ -46,7 +46,7 @@ class HealType(pos: SrcPos)(using Context) extends TypeMap {
case prefix: TermRef if tp.symbol.isTypeSplice =>
checkNotWildcardSplice(tp)
if level == 0 then tp else getTagRef(prefix)
case _: NamedType | _: ThisType | NoPrefix =>
case _: TermRef | _: ThisType | NoPrefix =>
if levelInconsistentRootOfPath(tp).exists then
tryHeal(tp)
else
Expand Down
12 changes: 12 additions & 0 deletions tests/pos-macros/i17293.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import scala.quoted.*

trait OuterTrait {
trait X
}

def exampleMacro[T <: OuterTrait: Type](expr: Expr[T])(using Quotes): Expr[OuterTrait#X] = {
'{
val prefix: T = ${ expr }
new prefix.X {}
}
}
12 changes: 12 additions & 0 deletions tests/pos-macros/i17293b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import scala.quoted.*

trait OuterTrait { self =>
trait X

def exampleMacro[T <: self.type: Type](expr: Expr[T])(using Quotes): Expr[self.X] = {
'{
val prefix: T = ${ expr }
new prefix.X {}
}
}
}

0 comments on commit ee25abf

Please sign in to comment.