Skip to content

Commit 84b1f36

Browse files
committed
Make it clearer why a special-case check for wildcard is needed
1 parent d70ce95 commit 84b1f36

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/src/dotty/tools/dotc/transform/FirstTransform.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
147147
if (tree.isType) {
148148
toTypeTree(tree)
149149
} else if (tree.name != nme.WILDCARD) {
150-
// Constant-foldable wildcards can occur in patterns, for instance as `case _: "a"`
151-
// we avoid constant-folding those as doing so would change the meaning of the pattern
150+
// We want to constant-fold _some_ idents here - for instance, @switch needs to see literals in patterns.
151+
// However, constant-foldable wildcards can occur in patterns, for instance as `case _: "a"`;
152+
// we avoid constant-folding those as doing so would change the meaning of the pattern.
152153
constToLiteral(tree)
153154
} else tree
154155

0 commit comments

Comments
 (0)