File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -1937,7 +1937,7 @@ class Typer extends Namer
1937
1937
case quoted if quoted.isType =>
1938
1938
typedTypeApply(untpd.TypeApply (untpd.ref(defn.InternalQuoted_typeQuoteR ), quoted :: Nil ), pt)(quoteContext).withSpan(tree.span)
1939
1939
case quoted =>
1940
- if (ctx.mode.is(Mode .Pattern )) {
1940
+ if (ctx.mode.is(Mode .Pattern ) && level == 0 ) {
1941
1941
val exprPt = pt.baseType(defn.QuotedExprClass )
1942
1942
val quotedPt = if (exprPt.exists) exprPt.argTypesHi.head else defn.AnyType
1943
1943
val quoted1 = typedExpr(quoted, quotedPt)(quoteContext.addMode(Mode .QuotedPattern ))
@@ -1989,7 +1989,7 @@ class Typer extends Namer
1989
1989
ctx.warning(" Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ." , tree.sourcePos)
1990
1990
typed(innerExpr, pt)
1991
1991
case expr =>
1992
- if (ctx.mode.is(Mode .QuotedPattern )) {
1992
+ if (ctx.mode.is(Mode .QuotedPattern ) && level == 1 ) {
1993
1993
fullyDefinedType(pt, " quoted pattern selector" , tree.span)
1994
1994
val pat = typedPattern(expr, defn.QuotedExprType .appliedTo(pt))(
1995
1995
spliceContext.retractMode(Mode .QuotedPattern ))
Original file line number Diff line number Diff line change
1
+ object Test {
2
+
3
+ val x = ' {1 + 2 }
4
+
5
+ def f (x : Int ) = x
6
+ def g (x : Int , y : Int ) = x * y
7
+
8
+ x match {
9
+ case ' { val a = ' { println($y) }; 0 } => ??? // error: Not found: y
10
+ case _ =>
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments