Skip to content

Commit ee25abf

Browse files
authored
Backport "Heal stage inconsistent prefixes of type projections" (#18328)
Backports #18239
2 parents 555df53 + e1233d8 commit ee25abf

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class HealType(pos: SrcPos)(using Context) extends TypeMap {
4646
case prefix: TermRef if tp.symbol.isTypeSplice =>
4747
checkNotWildcardSplice(tp)
4848
if level == 0 then tp else getTagRef(prefix)
49-
case _: NamedType | _: ThisType | NoPrefix =>
49+
case _: TermRef | _: ThisType | NoPrefix =>
5050
if levelInconsistentRootOfPath(tp).exists then
5151
tryHeal(tp)
5252
else

tests/pos-macros/i17293.scala

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import scala.quoted.*
2+
3+
trait OuterTrait {
4+
trait X
5+
}
6+
7+
def exampleMacro[T <: OuterTrait: Type](expr: Expr[T])(using Quotes): Expr[OuterTrait#X] = {
8+
'{
9+
val prefix: T = ${ expr }
10+
new prefix.X {}
11+
}
12+
}

tests/pos-macros/i17293b.scala

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import scala.quoted.*
2+
3+
trait OuterTrait { self =>
4+
trait X
5+
6+
def exampleMacro[T <: self.type: Type](expr: Expr[T])(using Quotes): Expr[self.X] = {
7+
'{
8+
val prefix: T = ${ expr }
9+
new prefix.X {}
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)