Skip to content

Commit d726452

Browse files
committed
Drop restriction that SuperAccessors should not touch patterns
Not sure why we need to do this, and in any case it's not sure what constitutes a pattern. There are certainly some parts of patterns (e.g. prefixes of unapplies, or their implicit arguments) that should be transformed under SuperAccessors, so the previous condition was too coarse. We include the test case that motivated the restriction. It looks like it works now.
1 parent dab8aa1 commit d726452

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/dotty/tools/dotc/transform/SuperAccessors.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,6 @@ class SuperAccessors extends MacroTransform
155155
else tree
156156

157157
try tree match {
158-
// Don't transform patterns or strange trees will reach the matcher (ticket #4062)
159-
// TODO Query `ctx.mode is Pattern` instead.
160-
case CaseDef(pat, guard, body) =>
161-
cpy.CaseDef(tree)(pat, transform(guard), transform(body))
162-
163158
case impl: Template =>
164159

165160
def transformTemplate = {

tests/pos/t4062.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class A(val f : String)
2+
3+
class B(a : Option[String], f : String) extends A(f) {
4+
a match {
5+
case Some(`f`) => print(f)
6+
}
7+
}

0 commit comments

Comments
 (0)