Skip to content

Commit 87b94ef

Browse files
committed
Fix ClassCastException in patmat when using Product1.
1 parent be7c492 commit 87b94ef

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
14431443
// require (nbSubPats > 0 && (!lastIsStar || isSeq))
14441444
protected def subPatRefs(binder: Symbol): List[Tree] = {
14451445
val refs = if (totalArity > 0 && isSeq) subPatRefsSeq(binder)
1446-
else if (totalArity > 1 && !isSeq) productElemsToN(binder, totalArity)
1446+
else if (defn.isProductSubType(binder.info) && !isSeq) productElemsToN(binder, totalArity)
14471447
else ref(binder):: Nil
14481448
refs
14491449
}

tests/run/value-class-extractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object NonNullChar {
66
@inline final val None = new NonNullChar(0.toChar)
77
}
88

9-
final class SomeProduct /*extends Product3[String, Int, List[String]]*/ {
9+
final class SomeProduct extends Product3[String, Int, List[String]] {
1010
def canEqual(x: Any) = x.isInstanceOf[SomeProduct]
1111
def _1 = "abc"
1212
def _2 = 5

0 commit comments

Comments
 (0)