File tree 3 files changed +55
-3
lines changed
compiler/src/dotty/tools/dotc/transform
3 files changed +55
-3
lines changed Original file line number Diff line number Diff line change @@ -360,13 +360,13 @@ object PatternMatcher {
360
360
.map(ref(unappResult).select(_))
361
361
matchArgsPlan(selectors, args, onSuccess)
362
362
}
363
+ else if (isUnapplySeq && unapplySeqTypeElemTp(unapp.tpe.widen.finalResultType).exists) {
364
+ unapplySeqPlan(unappResult, args)
365
+ }
363
366
else if (isUnapplySeq && isProductSeqMatch(unapp.tpe.widen, args.length, unapp.srcPos)) {
364
367
val arity = productArity(unapp.tpe.widen, unapp.srcPos)
365
368
unapplyProductSeqPlan(unappResult, args, arity)
366
369
}
367
- else if (isUnapplySeq && unapplySeqTypeElemTp(unapp.tpe.widen.finalResultType).exists) {
368
- unapplySeqPlan(unappResult, args)
369
- }
370
370
else if unappResult.info <:< defn.NonEmptyTupleTypeRef then
371
371
val components = (0 until foldApplyTupleType(unappResult.denot.info).length).toList.map(tupleApp(_, ref(unappResult)))
372
372
matchArgsPlan(components, args, onSuccess)
Original file line number Diff line number Diff line change
1
+ object Test :
2
+ class Custom extends scala.Product1 [String ]:
3
+ def length : Int = ???
4
+ def apply (i : Int ): Boolean = ???
5
+ def drop (n : Int ): scala.Seq [Boolean ] = ???
6
+ def toSeq : scala.Seq [Boolean ] = ???
7
+
8
+ def canEqual (that : Any ): Boolean = ???
9
+
10
+ val _1 : String = ???
11
+ val _2 : String = ???
12
+ val _3 : Seq [String ] = ???
13
+
14
+ object A :
15
+ def unapplySeq (i : Int ): Custom = ???
16
+
17
+ val A (a, rest* ) = 1
Original file line number Diff line number Diff line change
1
+ class T1
2
+
3
+ class P1
4
+ final class P2
5
+ class P3
6
+
7
+ class E1
8
+ class E2 extends E1
9
+ class E3 extends E1
10
+
11
+ object VarExt :
12
+ def unapplySeq (t1 : T1 ): U1 = new U1
13
+
14
+ class U1 extends Product1 [P1 ]:
15
+ def canEqual (that : Any ): Boolean = ???
16
+
17
+ val _1 : P1 = new P1
18
+ val _2 : P2 = new P2
19
+ val _3 : Seq [P3 ] = Seq (new P3 )
20
+
21
+ def length : Int = ???
22
+ def apply (i : Int ): E1 = ???
23
+ def drop (n : Int ): Seq [E2 ] = ???
24
+ def toSeq : Seq [E3 ] = ???
25
+
26
+ class Test :
27
+ def m1 (t1 : T1 ): Unit = t1 match
28
+ case VarExt (c1, cs* ) => // CCE: class P1 cannot be cast to class E1
29
+ val e1 : E1 = c1
30
+ val e1s : Seq [E1 ] = cs
31
+
32
+ object Main :
33
+ def main (args : Array [String ]): Unit =
34
+ new Test ().m1(new T1 )
35
+
You can’t perform that action at this time.
0 commit comments