Skip to content

Commit 5b0b2c9

Browse files
authored
Skip splice level checking for <refinement> symbols (#22782)
This is safe to skip because <refinement> symbols can only be a part of type refinement self referencing prefix, where it is impossible to splice anything. For some context, this is how the test case looks in typer: ```scala { final class $anon() extends AnyRef() { type T = Unit def make: T = () def take(t: T): Unit = () } new $anon(): {z1 => Object{type T; def make: z1.T; def take(t: z1.T): Unit}} }: Object { type T >: Nothing <: Any def make: <refinement>.this.T def take(t: <refinement>.this.T): Unit } ``` The compiler sometimes instead of creating a recursive type directly (`{z1 => ...}`), creates <refinement> symbols which reference an enclosing refinement, replacing those with recursive types later. Fixes #22648
2 parents 46b584b + e989217 commit 5b0b2c9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-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
@@ -76,7 +76,7 @@ class HealType(pos: SrcPos)(using Context) extends TypeMap {
7676
tp match
7777
case tp @ NamedType(NoPrefix, _) if level > levelOf(tp.symbol) => tp.symbol
7878
case tp: NamedType if !tp.symbol.isStatic => levelInconsistentRootOfPath(tp.prefix)
79-
case tp: ThisType if level > levelOf(tp.cls) => tp.cls
79+
case tp: ThisType if level > levelOf(tp.cls) && !tp.cls.isRefinementClass => tp.cls
8080
case _ => NoSymbol
8181

8282
/** Try to heal reference to type `T` used in a higher level than its definition.

tests/pos/i22648.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import scala.quoted.*
2+
3+
def fooImpl(using Quotes): Expr[Any] =
4+
'{
5+
new AnyRef {
6+
type T = Unit
7+
def make: T = ()
8+
def take(t: T): Unit = ()
9+
}: {
10+
type T
11+
def make: T
12+
def take(t: T): Unit
13+
}
14+
}

0 commit comments

Comments
 (0)