File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
compiler/src/dotty/tools/dotc/transform/patmat Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -633,6 +633,14 @@ object SpaceEngine {
633
633
// but end up with A1[<?>] and A2[<?>].
634
634
// So we widen (like AppliedType superType does) away
635
635
// non-class type constructors.
636
+ //
637
+ // Can't use `tpOriginal.baseType(cls)` because it causes
638
+ // i15893 to return exhaustivity warnings, because instead of:
639
+ // <== refineUsingParent(N, class Succ, []) = Succ[<? <: NatT>]
640
+ // <== isSub(Succ[<? <: NatT>] <:< Succ[Succ[<?>]]) = true
641
+ // we get
642
+ // <== refineUsingParent(NatT, class Succ, []) = Succ[NatT]
643
+ // <== isSub(Succ[NatT] <:< Succ[Succ[<?>]]) = false
636
644
def getAppliedClass (tp : Type ): Type = tp match
637
645
case tp @ AppliedType (_ : HKTypeLambda , _) => tp
638
646
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