File tree Expand file tree Collapse file tree 4 files changed +6
-12
lines changed
compiler/src/dotty/tools/dotc/transform/patmat Expand file tree Collapse file tree 4 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,6 @@ object SpaceEngine {
113
113
def isSubspace (a : Space , b : Space )(using Context ): Boolean = a.isSubspace(b)
114
114
def canDecompose (typ : Typ )(using Context ): Boolean = typ.canDecompose
115
115
def decompose (typ : Typ )(using Context ): List [Typ ] = typ.decompose
116
- def nullSpace (using Context ): Space = Typ (ConstantType (Constant (null )), decomposed = false )
117
116
118
117
/** Simplify space such that a space equal to `Empty` becomes `Empty` */
119
118
def computeSimplify (space : Space )(using Context ): Space = trace(i " simplify( $space) " )(space match {
@@ -904,11 +903,6 @@ object SpaceEngine {
904
903
then project(OrType (selTyp, ConstantType (Constant (null )), soft = false ))
905
904
else project(selTyp)
906
905
)
907
- def projectPat (pat : Tree ): Space =
908
- // Project toplevel wildcard pattern to nullable
909
- if isNullable && isWildcardArg(pat) then Or (project(pat) :: nullSpace :: Nil )
910
- else project(pat)
911
-
912
906
var i = 0
913
907
val len = cases.length
914
908
var prevs = List .empty[Space ]
@@ -917,7 +911,7 @@ object SpaceEngine {
917
911
while (i < len) {
918
912
val CaseDef (pat, guard, _) = cases(i)
919
913
920
- val curr = trace(i " project( $pat) " )(projectPat (pat))
914
+ val curr = trace(i " project( $pat) " )(project (pat))
921
915
922
916
val covered = trace(" covered" )(simplify(intersect(curr, targetSpace)))
923
917
Original file line number Diff line number Diff line change 1
1
6: Pattern Match
2
2
13: Pattern Match
3
- 20: Pattern Match
4
- 21: Match case Unreachable
3
+ 20: Match case Unreachable
4
+ 21: Pattern Match
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ val a = Sum(S(S(Z)),Z) match {
16
16
case Sum (a@ S (b@ S (_)), Z ) => a // warn
17
17
case Sum (a@ S (b@ (S (_))), Z ) => Sum (a,b) // warn unreachable
18
18
case Sum (_,_) => Z // OK
19
- case _ => Z
19
+ case _ => Z // warn unreachable
20
20
}
21
21
22
22
// todo : This should pass in the future
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ object Test {
19
19
case x : Array [String ] => x.size
20
20
case x : Array [AnyRef ] => 5
21
21
case x : Array [? ] => 6
22
- case _ => 7
22
+ case _ => 7 // warn: only null is matched
23
23
}
24
24
def f3 [T ](a : Array [T ]) = a match {
25
25
case x : Array [Int ] => x(0 )
@@ -28,7 +28,7 @@ object Test {
28
28
case x : Array [String ] => x.size
29
29
case x : Array [AnyRef ] => 5
30
30
case x : Array [? ] => 6
31
- case _ => 7
31
+ case _ => 7 // warn: only null is matched
32
32
}
33
33
34
34
You can’t perform that action at this time.
0 commit comments