Skip to content

Commit 4253708

Browse files
Merge pull request #8695 from dotty-staging/improve-type-inference-of-quote-pattern-splices
Improve type inference of quote pattern splices
2 parents 44b8353 + d92bf6e commit 4253708

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ trait QuotesAndSplices {
7373
case _ =>
7474
}
7575
if (ctx.mode.is(Mode.QuotedPattern))
76-
if (isFullyDefined(pt, ForceDegree.all)) {
76+
if (isFullyDefined(pt, ForceDegree.flipBottom)) {
7777
def spliceOwner(ctx: Context): Symbol =
7878
if (ctx.mode.is(Mode.QuotedPattern)) spliceOwner(ctx.outer) else ctx.owner
7979
val pat = typedPattern(tree.expr, defn.QuotedExprClass.typeRef.appliedTo(pt))(
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import scala.quoted._
2+
3+
4+
object Macros {
5+
6+
inline def g(inline x: Unit): Unit = ${impl('x)}
7+
8+
private def impl(x: Expr[Any])(using QuoteContext): Expr[Any] = {
9+
x match
10+
case '{ println(f($y)) } => y
11+
}
12+
13+
}
14+
15+
def f[T](x: T): T = x
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Macros._
2+
3+
4+
object Test {
5+
6+
def main(args: Array[String]): Unit = {
7+
g(println(f((5))))
8+
}
9+
10+
}

0 commit comments

Comments
 (0)