File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1988,8 +1988,10 @@ class Typer extends Namer
1988
1988
case expr =>
1989
1989
if (ctx.mode.is(Mode .QuotedPattern ) && level == 1 ) {
1990
1990
fullyDefinedType(pt, " quoted pattern selector" , tree.span)
1991
+ def spliceOwner (ctx : Context ): Symbol =
1992
+ if (ctx.mode.is(Mode .QuotedPattern )) spliceOwner(ctx.outer) else ctx.owner
1991
1993
val pat = typedPattern(expr, defn.QuotedExprType .appliedTo(pt))(
1992
- spliceContext.retractMode(Mode .QuotedPattern ))
1994
+ spliceContext.retractMode(Mode .QuotedPattern ).withOwner(spliceOwner(ctx)) )
1993
1995
Splice (pat)
1994
1996
}
1995
1997
else
Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+ object Test {
3
+ def res (x : quoted.Expr [Int ]) given tasty .Reflection : quoted.Expr [Int ] = x match {
4
+ case ' { val a : Int = $y; 1 } => y // owner of `y` is `res`
5
+ case _ => ' { val b : Int = $ {val c = 2 ; c.toExpr}; 1 } // owner of `c` is `b`, but that seems to be OK
6
+ }
7
+ }
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ def res (x : quoted.Expr [Int ]) given tasty .Reflection : quoted.Expr [Int ] = x match {
3
+ case ' { val a : Int = $ { Foo (' { val b : Int = $y; b }) }; a } => y // owner of y is res
4
+ }
5
+ object Foo {
6
+ def unapply (x : quoted.Expr [Int ]): Option [quoted.Expr [Int ]] = Some (x)
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments