Skip to content

Commit 203c94d

Browse files
committed
Fix definition of isGenericTuple by force-widening hard unions
1 parent 70b6f64 commit 203c94d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,12 @@ object PatternMatcher {
336336

337337
if (isSyntheticScala2Unapply(unapp.symbol) && caseAccessors.length == args.length)
338338
def tupleSel(sym: Symbol) = ref(scrutinee).select(sym)
339-
val isGenericTuple = defn.isTupleClass(caseClass) && !defn.isTupleNType(tree.tpe)
339+
val isGenericTuple = defn.isTupleClass(caseClass) && {
340+
val tp = tree.tpe match // widen even hard unions, to see if it's a union of tuples
341+
case tp @ OrType(l, r) => (if tp.isSoft then tp else tp.derivedOrType(l, r, soft = true)).widenUnion
342+
case tp => tp
343+
!defn.isTupleNType(tp)
344+
}
340345
val components = if isGenericTuple then caseAccessors.indices.toList.map(tupleApp(_, ref(scrutinee))) else caseAccessors.map(tupleSel)
341346
matchArgsPlan(components, args, onSuccess)
342347
else if (unapp.tpe <:< (defn.BooleanType))

0 commit comments

Comments
 (0)