Skip to content

Commit 237bf89

Browse files
committed
Fix a bug with QuotePatterns::checkPattern
1 parent fdc9c07 commit 237bf89

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

compiler/src/dotty/tools/dotc/quoted/QuotePatterns.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ object QuotePatterns:
3030
val typevars = new tpd.TreeAccumulator[Set[Symbol]] {
3131
override def apply(typevars: Set[Symbol], tree: tpd.Tree)(using Context): Set[Symbol] = tree match {
3232
case _: SplicePattern => typevars
33-
case tree @ DefDef(_, paramss, _, _) =>
34-
val newTypevars = paramss.flatMap{ params => params match
35-
case TypeDefs(tdefs) => tdefs.map(_.symbol)
36-
case _ => List.empty
37-
}.toSet
38-
foldOver(typevars union newTypevars, tree)
3933
case tdef: TypeDef if tdef.symbol.isClass =>
4034
val kind = if tdef.symbol.is(Module) then "objects" else "classes"
4135
report.error(em"Implementation restriction: cannot match $kind", tree.srcPos)
@@ -47,7 +41,14 @@ object QuotePatterns:
4741
tree.srcPos)
4842
if tree.name.isTermName && !tree.nameSpan.isSynthetic && tree.name != nme.ANON_FUN && tree.name.startsWith("$") then
4943
report.error("Names cannot start with $ quote pattern", tree.namePos)
50-
foldOver(typevars, tree)
44+
val typevars1 = tree match
45+
case tree @ DefDef(_, paramss, _, _) =>
46+
typevars union paramss.flatMap{ params => params match
47+
case TypeDefs(tdefs) => tdefs.map(_.symbol)
48+
case _ => List.empty
49+
}.toSet
50+
case _ => typevars
51+
foldOver(typevars1, tree)
5152
case _: Match =>
5253
report.error("Implementation restriction: cannot match `match` expressions", tree.srcPos)
5354
typevars

0 commit comments

Comments
 (0)