Skip to content

Backport "Heal stage inconsistent prefixes of type projections" #18328

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

Merged
merged 1 commit into from
Aug 9, 2023
Merged
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
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 {}
}
}
}