Skip to content

Commit 9a26f44

Browse files
committed
Use some enums in compiler
1 parent 3c99306 commit 9a26f44

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,9 @@ object desugar {
3939
*/
4040
val CheckIrrefutable: Property.Key[MatchCheck] = new Property.StickyKey
4141

42-
/** What static check should be applied to a Match (none, irrefutable, exhaustive) */
43-
class MatchCheck(val n: Int) extends AnyVal
44-
object MatchCheck {
45-
val None = new MatchCheck(0)
46-
val Exhaustive = new MatchCheck(1)
47-
val IrrefutablePatDef = new MatchCheck(2)
48-
val IrrefutableGenFrom = new MatchCheck(3)
42+
/** What static check should be applied to a Match? */
43+
enum MatchCheck {
44+
case None, Exhaustive, IrrefutablePatDef, IrrefutableGenFrom
4945
}
5046

5147
/** Info of a variable in a pattern: The named tree and its type */

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,11 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
123123
class XMLBlock(stats: List[Tree], expr: Tree)(implicit @constructorOnly src: SourceFile) extends Block(stats, expr)
124124

125125
/** An enum to control checking or filtering of patterns in GenFrom trees */
126-
class GenCheckMode(val x: Int) extends AnyVal
127-
object GenCheckMode {
128-
val Ignore = new GenCheckMode(0) // neither filter nor check since filtering was done before
129-
val Check = new GenCheckMode(1) // check that pattern is irrefutable
130-
val FilterNow = new GenCheckMode(2) // filter out non-matching elements since we are not in -strict
131-
val FilterAlways = new GenCheckMode(3) // filter out non-matching elements since pattern is prefixed by `case`
126+
enum GenCheckMode {
127+
case Ignore // neither filter nor check since filtering was done before
128+
case Check // check that pattern is irrefutable
129+
case FilterNow //filter out non-matching elements since we are not in -strict
130+
case FilterAlways // filter out non-matching elements since pattern is prefixed by `case`
132131
}
133132

134133
// ----- Modifiers -----------------------------------------------------

0 commit comments

Comments
 (0)