diff options
author | Som Snytt <som.snytt@gmail.com> | 2015-06-03 16:36:43 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2015-06-03 16:36:43 -0700 |
commit | 79436caa98ba46de644841a67ea9ff103831e574 (patch) | |
tree | 3c4f04bad8624e8ded8155ffd87d8028d5d5f9a7 /src/compiler | |
parent | 70f0b1ded880ec9b3a9478d02f1898fcfeee230c (diff) | |
download | scala-79436caa98ba46de644841a67ea9ff103831e574.tar.gz scala-79436caa98ba46de644841a67ea9ff103831e574.tar.bz2 scala-79436caa98ba46de644841a67ea9ff103831e574.zip |
SI-9343 Xlint less strict on pattern sequences
-Xlint:stars-align warns only if elementarity > 0, that is,
if an extracted sequence is not matched entirely by a pattern
sequence, that is, in SLS 8.1.9 on pattern sequences, n = 1
and that pattern is a pattern sequence.
This is still only triggered if productarity > 0, that is,
a non-pattern-sequence pattern is required for the match.
This is a sensitive area because it borders on exhaustiveness
checking: it would be preferable to verify just that the match
is exhaustive, and to emit this warning only if it is not.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala b/src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala index 2753baa51d..b1783dc81f 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/ScalacPatternExpanders.scala @@ -112,8 +112,10 @@ trait ScalacPatternExpanders { arityError("not enough") else if (elementArity > 0 && !isSeq) arityError("too many") - else if (settings.warnStarsAlign && isSeq && productArity > 0 && (elementArity > 0 || !isStar)) - warn("A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).") + else if (settings.warnStarsAlign && isSeq && productArity > 0 && elementArity > 0) warn { + if (isStar) "Sequence wildcard (_*) does not align with repeated case parameter or extracted sequence; the result may be unexpected." + else "A repeated case parameter or extracted sequence is not matched by a sequence wildcard (_*), and may fail at runtime." + } aligned } |