File tree 2 files changed +21
-0
lines changed
compiler/src/dotty/tools/dotc/transform/patmat
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -625,6 +625,14 @@ object SpaceEngine {
625
625
// but end up with A1[<?>] and A2[<?>].
626
626
// So we widen (like AppliedType superType does) away
627
627
// non-class type constructors.
628
+ //
629
+ // Can't use `tpOriginal.baseType(cls)` because it causes
630
+ // i15893 to return exhaustivity warnings, because instead of:
631
+ // <== refineUsingParent(N, class Succ, []) = Succ[<? <: NatT>]
632
+ // <== isSub(Succ[<? <: NatT>] <:< Succ[Succ[<?>]]) = true
633
+ // we get
634
+ // <== refineUsingParent(NatT, class Succ, []) = Succ[NatT]
635
+ // <== isSub(Succ[NatT] <:< Succ[Succ[<?>]]) = false
628
636
def getAppliedClass (tp : Type ): Type = tp match
629
637
case tp @ AppliedType (_ : HKTypeLambda , _) => tp
630
638
case tp @ AppliedType (tycon : TypeRef , _) if tycon.symbol.isClass => tp
Original file line number Diff line number Diff line change
1
+ sealed trait NatT
2
+ case class Zero () extends NatT
3
+ case class Succ [+ N <: NatT ](n : N ) extends NatT
4
+
5
+ type Mod2 [N <: NatT ] <: NatT = N match
6
+ case Zero => Zero
7
+ case Succ [Zero ] => Succ [Zero ]
8
+ case Succ [Succ [predPredN]] => Mod2 [predPredN]
9
+
10
+ def dependentlyTypedMod2 [N <: NatT ](n : N ): Mod2 [N ] = n match
11
+ case Zero (): Zero => Zero () // warn
12
+ case Succ (Zero ()): Succ [Zero ] => Succ (Zero ()) // warn
13
+ case Succ (Succ (predPredN)): Succ [Succ [? ]] => dependentlyTypedMod2(predPredN) // warn
You can’t perform that action at this time.
0 commit comments