Skip to content

Commit 3989aa6

Browse files
committed
fix: make the pattern matcher understand this types
1 parent ccde55e commit 3989aa6

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ object PatternMatcher {
482482
onSuccess
483483
)
484484
}
485-
case WildcardPattern() =>
485+
case WildcardPattern() | This(_) =>
486486
onSuccess
487487
case SeqLiteral(pats, _) =>
488488
matchElemsPlan(scrutinee, pats, exact = true, onSuccess)

tests/run/i23875.check

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
true
2+
false
3+
false

tests/run/i23875.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Foo {
2+
override def equals(that : Any) = that match {
3+
case _: this.type => true
4+
case _ => false
5+
}
6+
}
7+
8+
@main def Test =
9+
println(Foo.equals(Foo))
10+
println(Foo.equals(new AnyRef {}))
11+
println(Foo.equals(0))

0 commit comments

Comments
 (0)