Skip to content

Commit f23da5e

Browse files
Merge pull request #8698 from dotty-staging/fix-i8690
Fix #8690: the signature for product should come from expected type
2 parents 37006e3 + 41f4cbb commit f23da5e

File tree

13 files changed

+171
-67
lines changed

13 files changed

+171
-67
lines changed

compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ object PickledQuotes {
144144
case tp: TypeRef =>
145145
typeSpliceMap.get(tp.symbol) match
146146
case Some(t) if tp.typeSymbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot) => t
147-
case None => tp
147+
case _ => tp
148148
case _ => tp
149149
}
150150
mapOver(tp1)

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 102 additions & 63 deletions
Large diffs are not rendered by default.

tests/neg-custom-args/isInstanceOf/enum-approx2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ sealed trait Exp[T]
22
case class Fun[A, B](f: Exp[A => B]) extends Exp[A => B]
33

44
class Test {
5-
def eval[T](e: Exp[T]) = e match {
5+
def eval(e: Fun[Int, Int]) = e match {
66
case Fun(x: Fun[Int, Double]) => ??? // error
77
case Fun(x: Exp[Int => String]) => ??? // error
88
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11: Pattern Match Exhaustivity: _: List

tests/patmat/i8690.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class A
2+
class B
3+
4+
def test(x: (A, B) | (B, A)) = x match {
5+
case (u: A, v) => (u, v)
6+
case (u: B, v) => (v, u)
7+
}

tests/patmat/i8690b.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class A
2+
class B
3+
4+
def test(x: (A, B) | (B, A)) = x match {
5+
case (u: A, v: B) => (u, v)
6+
case (u: B, v: A) => (v, u)
7+
}

tests/patmat/i8708.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2: Pattern Match Exhaustivity: Some(_)

tests/patmat/i8708.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object Main {
2+
def foo(x: Option[Int]): Int = x match {
3+
case Some(n) if n % 2 == 0 => n
4+
case None => 0
5+
}
6+
7+
def main(args: Array[String]): Unit = println(foo(Some(1)))
8+
}

tests/patmat/patmatexhaust.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
11: Pattern Match Exhaustivity: Bar(_)
33
23: Pattern Match Exhaustivity: (Qult(), Qult()), (Kult(_), Kult(_))
44
49: Pattern Match Exhaustivity: _: Gp
5+
53: Pattern Match Exhaustivity: _: Gp
56
59: Pattern Match Exhaustivity: Nil
67
75: Pattern Match Exhaustivity: _: B
78
87: Pattern Match Exhaustivity: _: C1

tests/patmat/t11457b.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
sealed trait Command {
2+
type Reply
3+
}
4+
5+
final case class Create() extends Command {
6+
type Reply = CreateReply
7+
val reply: Reply = CreateReply()
8+
}
9+
10+
final case class Set() extends Command {
11+
type Reply = SetReply
12+
val reply: Reply = SetReply()
13+
}
14+
15+
case class CreateReply()
16+
case class SetReply()
17+
18+
def process[R](command: Command { type Reply = R }): R =
19+
command match {
20+
case create: Create => create.reply
21+
case set: Set => set.reply
22+
// ^
23+
// Warning: unreachable code
24+
}

tests/patmat/t11620b.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
sealed abstract class Length
2+
3+
object Length {
4+
case class Num(n: Int) extends Length
5+
case object StateColumn extends Length
6+
}
7+
8+
import Length._
9+
10+
case class Indent[T <: Length](length: T)
11+
12+
def withIndent[T <: Length](indent: => Indent[_]): Unit =
13+
indent match {
14+
case Indent(Num(0)) => println("this")
15+
case x => println(x) // "unreachable"
16+
}

tests/patmat/t7631.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8: Pattern Match Exhaustivity: TestB()
1+
8: Pattern Match Exhaustivity: _: Test

tests/patmat/virtpatmat_apply.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2: Pattern Match Exhaustivity: List(_)
1+
2: Pattern Match Exhaustivity: List(_, _: _*)

0 commit comments

Comments
 (0)