Skip to content

Commit

Permalink
[util-security] throw MatchError when case match is non-exhaustive
Browse files Browse the repository at this point in the history
Problem

Supporting latest https://github.com/scala/scala/releases/tag/v2.12.13 includes
a feature change in the scala compiler that will fail to compile when case
matching is not exhaustive on tuples.

Issues
- scala/bug#10680
- scala/bug#10373
- scala/bug#10019

Resolved
- scala/scala#9163
- scala/scala#9147

Solution
Add `case _ => throw new MatchError` to case matching statement that is
non-exhaustive

JIRA Issues: SCALA-25

Differential Revision: https://phabricator.twitter.biz/D609046
  • Loading branch information
adam-singer authored and jenkins committed Jan 29, 2021
1 parent a5fe349 commit 08ad99b
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -37,7 +37,10 @@ object Credentials {
private[this] val key = "[\\w-]+".r
private[this] val value = ".+".r

def auth: Parser[Tuple2[String, String]] = key ~ ":" ~ value ^^ { case k ~ ":" ~ v => (k, v) }
def auth: Parser[Tuple2[String, String]] = key ~ ":" ~ value ^^ {
case k ~ ":" ~ v => (k, v)
case _ => throw new MatchError
}
def content: Parser[Map[String, String]] = rep(auth) ^^ { auths => Map(auths: _*) }

def apply(in: String): Map[String, String] = {
Expand Down

0 comments on commit 08ad99b

Please sign in to comment.