Skip to content

Commit 6781480

Browse files
Merge pull request #4675 from dotty-staging/fix-tasty-pattern-ref
Fix Tasty reflect patterns with select trees
2 parents 188d4f2 + 193386a commit 6781480

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ object TastyImpl extends scala.tasty.Tasty {
474474
object Value extends ValueExtractor {
475475
def unapply(x: Pattern)(implicit ctx: Context): Option[Term] = x match {
476476
case lit: tpd.Literal @unchecked => Some(lit)
477-
case ident: tpd.Ident @unchecked if ident.isTerm => Some(ident)
477+
case ref: tpd.RefTree @unchecked if ref.isTerm => Some(ref)
478478
case _ => None
479479
}
480480
}

tests/pos/simpleMatchRef.decompiled

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** Decompiled from out/posTestFromTasty/pos/simpleMatchRef/Foo.class */
2+
class Foo() {
3+
val X: scala.Int = scala.Predef.???
4+
def foo(x: scala.Any): scala.Unit = x match {
5+
case this.X =>
6+
scala.Predef.println("a")
7+
case Y =>
8+
scala.Predef.println("b")
9+
}
10+
}
11+
/** Decompiled from out/posTestFromTasty/pos/simpleMatchRef/Y.class */
12+
object Y

tests/pos/simpleMatchRef.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
class Foo {
3+
val X: Int = ???
4+
def foo(x: Any): Unit = x match {
5+
case X => println("a")
6+
case Y => println("b")
7+
}
8+
}
9+
10+
object Y

0 commit comments

Comments
 (0)