Skip to content

Commit f7598a6

Browse files
committed
Propagate type args param bounds proto when in quoted pattern
1 parent 4e7a764 commit f7598a6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,8 +1389,10 @@ class Typer extends Namer
13891389
def typedArg(arg: untpd.Tree, tparam: ParamInfo) = {
13901390
def tparamBounds = tparam.paramInfoAsSeenFrom(tpt1.tpe.appliedTo(tparams.map(_ => TypeBounds.empty)))
13911391
val (desugaredArg, argPt) =
1392-
if (ctx.mode is Mode.Pattern)
1392+
if ctx.mode.is(Mode.Pattern) then
13931393
(if (untpd.isVarPattern(arg)) desugar.patternVar(arg) else arg, tparamBounds)
1394+
else if ctx.mode.is(Mode.QuotedPattern) then
1395+
(arg, tparamBounds)
13941396
else
13951397
(arg, WildcardType)
13961398
if (tpt1.symbol.isClass)
@@ -3030,7 +3032,7 @@ class Typer extends Namer
30303032
tree.tpe.EtaExpand(tp.typeParamSymbols)
30313033
tree.withType(tp1)
30323034
}
3033-
if ((ctx.mode is Mode.Pattern) || tree1.tpe <:< pt) tree1
3035+
if (ctx.mode.is(Mode.Pattern) || ctx.mode.is(Mode.QuotedPattern) || tree1.tpe <:< pt) tree1
30343036
else err.typeMismatch(tree1, pt)
30353037
}
30363038

tests/neg/i7264d.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.quoted._
2+
class Foo {
3+
def f[T2: Type](e: Expr[T2])(given QuoteContext) = e match {
4+
case '{ $x: *:[Int, Any] } => // error: Type argument Any does not conform to upper bound Tuple
5+
6+
}
7+
}

0 commit comments

Comments
 (0)