Commit f8acad1
committed
Fix @switch warnings for matches on value classes
Matches on value classes that have an underlying switchable type may be
emitted as tableswitch or lookupswitch, but the shape of the result tree
differs from ordinary switch-compiled matches.
Previously, this caused a spurious warning to be issued if such a match
was annotated with @switch, as none of the result cases were discovered
by the warning logic, and hence the match was warned as having too few cases.
With the warning for too few cases now removed, we have the opposite
issue: in no circumstance is a switch warning issued for @switch
annotated matches on value classes.
This commit attempts to address this issue and restore the @switch
warnings for those matches on value classes where a tableswitch or
lookupswitch is not emitted.
A complicating factor is that the original case types for matches
on value class extractors are not singleton types, and so counting
the number of unique types is not useful for determining the number
of original cases.1 parent e298e21 commit f8acad1
File tree
3 files changed
+36
-1
lines changed- compiler/src/dotty/tools/dotc/transform
- tests
- neg-custom-args/fatal-warnings
- pos-special/fatal-warnings
3 files changed
+36
-1
lines changedLines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
981 | 981 | | |
982 | 982 | | |
983 | 983 | | |
| 984 | + | |
984 | 985 | | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
985 | 989 | | |
986 | 990 | | |
987 | 991 | | |
| |||
990 | 994 | | |
991 | 995 | | |
992 | 996 | | |
993 | | - | |
| 997 | + | |
994 | 998 | | |
995 | 999 | | |
996 | 1000 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
79 | 100 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
36 | 44 | | |
37 | 45 | | |
| 46 | + | |
| 47 | + | |
38 | 48 | | |
39 | 49 | | |
40 | 50 | | |
| |||
0 commit comments