File tree 2 files changed +13
-2
lines changed
compiler/src/dotty/tools/dotc/transform/patmat
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -534,16 +534,15 @@ class SpaceEngine(using Context) extends SpaceLogic {
534
534
val mt : MethodType = unapp.widen match {
535
535
case mt : MethodType => mt
536
536
case pt : PolyType =>
537
- inContext(ctx.fresh.setExploreTyperState()) {
538
537
val tvars = pt.paramInfos.map(newTypeVar(_))
539
538
val mt = pt.instantiate(tvars).asInstanceOf [MethodType ]
540
539
scrutineeTp <:< mt.paramInfos(0 )
541
540
// force type inference to infer a narrower type: could be singleton
542
541
// see tests/patmat/i4227.scala
543
542
mt.paramInfos(0 ) <:< scrutineeTp
543
+ instantiateSelected(mt, tvars)
544
544
isFullyDefined(mt, ForceDegree .all)
545
545
mt
546
- }
547
546
}
548
547
549
548
// Case unapply:
Original file line number Diff line number Diff line change
1
+ // scalac: -Werror
2
+ sealed trait Nat
3
+ case class Zero () extends Nat
4
+ case class Succ [N <: Nat ](n : N ) extends Nat
5
+
6
+ class Test :
7
+ def foo (n : Nat ): Int = n match
8
+ case Zero () => 0
9
+ case Succ (Zero ()) => 1
10
+ case _ => 2 // was: warning for this line
11
+
12
+ def test = foo(Succ (Succ (Zero ()))) // evaluates to 2
You can’t perform that action at this time.
0 commit comments