Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 722626e

Browse files
enable unused warnings on Scala 2
I'm also interested in enabling this on Scala 3 eventually, but for now there are too many bugs (but I'm reporting them, one at a time)
1 parent 6c342e7 commit 722626e

File tree

21 files changed

+25
-43
lines changed

21 files changed

+25
-43
lines changed

‎build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ lazy val parserCombinators = crossProject(JVMPlatform, JSPlatform, NativePlatfor
3838

3939
// go nearly warning-free, but only on 2.13, it's too hard across all versions
4040
Compile / scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
41-
case Some((2, 13)) => Seq("-Werror",
41+
case Some((2, 13)) => Seq("-Werror","-Wunused",
4242
// ideally we'd do something about this. `^?` is the responsible method
4343
"-Wconf:site=scala.util.parsing.combinator.Parsers.*&cat=lint-multiarg-infix:i",
4444
// not sure what resolving this would look like? didn't think about it too hard

‎shared/src/main/scala/scala/util/parsing/combinator/PackratParsers.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,14 @@ to update each parser involved in the recursion.
208208

209209
private def lrAnswer[T](p: Parser[T], in: PackratReader[Elem], growable: LR): ParseResult[T] = growable match {
210210
//growable will always be having a head, we can't enter lrAnswer otherwise
211-
case LR(seed ,rule, Some(head)) =>
211+
case LR(seed, _, Some(head)) =>
212212
if(head.getHead != p) /*not head rule, so not growing*/ seed.asInstanceOf[ParseResult[T]]
213213
else {
214214
in.updateCacheAndGet(p, MemoEntry(Right(seed.asInstanceOf[ParseResult[T]])))
215215
seed match {
216216
case f@Failure(_,_) => f
217217
case e@Error(_,_) => e
218-
case s@Success(_,_) => /*growing*/ grow(p, in, head)
218+
case Success(_,_) => /*growing*/ grow(p, in, head)
219219
}
220220
}
221221
case _=> throw new Exception("lrAnswer with no head !!")
@@ -256,7 +256,7 @@ to update each parser involved in the recursion.
256256
/*simple result*/
257257
inMem.updateCacheAndGet(p,MemoEntry(Right(tempRes)))
258258
tempRes
259-
case s@Some(_) =>
259+
case Some(_) =>
260260
/*non simple result*/
261261
base.seed = tempRes
262262
//the base variable has passed equality tests with the cache
@@ -303,7 +303,7 @@ to update each parser involved in the recursion.
303303
case _ => throw new Exception("impossible match")
304304
}
305305
}
306-
case f =>
306+
case _ =>
307307
rest.recursionHeads -= rest.pos
308308
/*rest.updateCacheAndGet(p, MemoEntry(Right(f)));*/oldRes
309309
}

‎shared/src/main/scala/scala/util/parsing/combinator/Parsers.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ trait Parsers {
223223
case s @ Success(result, rest) =>
224224
val failure = selectLastFailure(Some(this), s.lastFailure)
225225
Success(result, rest, failure)
226-
case ns: NoSuccess => if (alt.next.pos < next.pos) this else alt
226+
case _: NoSuccess => if (alt.next.pos < next.pos) this else alt
227227
}
228228
}
229229
}
@@ -316,7 +316,7 @@ trait Parsers {
316316
* @return a `Parser` that -- on success -- returns the result of `q`.
317317
*/
318318
def ~> [U](q: => Parser[U]): Parser[U] = { lazy val p = q // lazy argument
319-
(for(a <- this; b <- p) yield b).named("~>")
319+
(for(_ <- this; b <- p) yield b).named("~>")
320320
}
321321

322322
/** A parser combinator for sequential composition which keeps only the left result.
@@ -330,7 +330,7 @@ trait Parsers {
330330
* @return a `Parser` that -- on success -- returns the result of `p`.
331331
*/
332332
def <~ [U](q: => Parser[U]): Parser[T] = { lazy val p = q // lazy argument
333-
(for(a <- this; b <- p) yield a).named("<~")
333+
(for(a <- this; _ <- p) yield a).named("<~")
334334
}
335335

336336
/**
@@ -372,7 +372,7 @@ trait Parsers {
372372
* The resulting parser fails if either `p` or `q` fails, this failure is fatal.
373373
*/
374374
def ~>! [U](q: => Parser[U]): Parser[U] = { lazy val p = q // lazy argument
375-
OnceParser { (for(a <- this; b <- commit(p)) yield b).named("~>!") }
375+
OnceParser { (for(_ <- this; b <- commit(p)) yield b).named("~>!") }
376376
}
377377

378378
/** A parser combinator for non-back-tracking sequential composition which only keeps the left result.
@@ -385,7 +385,7 @@ trait Parsers {
385385
* The resulting parser fails if either `p` or `q` fails, this failure is fatal.
386386
*/
387387
def <~! [U](q: => Parser[U]): Parser[T] = { lazy val p = q // lazy argument
388-
OnceParser { (for(a <- this; b <- commit(p)) yield a).named("<~!") }
388+
OnceParser { (for(a <- this; _ <- commit(p)) yield a).named("<~!") }
389389
}
390390

391391

@@ -448,7 +448,7 @@ trait Parsers {
448448
*/
449449
def ^^^ [U](v: => U): Parser[U] = new Parser[U] {
450450
lazy val v0 = v // lazy argument
451-
def apply(in: Input) = Parser.this(in) map (x => v0)
451+
def apply(in: Input) = Parser.this(in) map (_ => v0)
452452
}.named(toString+"^^^")
453453

454454
/** A parser combinator for partial function application.
@@ -601,7 +601,7 @@ trait Parsers {
601601
p(in) match{
602602
case s @ Success(_, _) => s
603603
case e @ Error(_, _) => e
604-
case f @Failure(msg, next) => Error(msg, next)
604+
case Failure(msg, next) => Error(msg, next)
605605
}
606606
}
607607

@@ -613,7 +613,7 @@ trait Parsers {
613613
* @param p A predicate that determines which elements match.
614614
* @return
615615
*/
616-
def elem(kind: String, p: Elem => Boolean) = acceptIf(p)(inEl => kind+" expected")
616+
def elem(kind: String, p: Elem => Boolean) = acceptIf(p)(_ => kind+" expected")
617617

618618
/** A parser that matches only the given element `e`.
619619
*
@@ -995,7 +995,7 @@ trait Parsers {
995995
*/
996996
def phrase[T](p: Parser[T]) = new Parser[T] {
997997
def apply(in: Input) = p(in) match {
998-
case s @ Success(out, in1) =>
998+
case s @ Success(_, in1) =>
999999
if (in1.atEnd) s
10001000
else s.lastFailure match {
10011001
case Some(failure) => failure
@@ -1032,9 +1032,9 @@ trait Parsers {
10321032
= OnceParser{ (for(a <- this; b <- commit(p)) yield new ~(a,b)).named("~") }
10331033

10341034
override def ~> [U](p: => Parser[U]): Parser[U]
1035-
= OnceParser{ (for(a <- this; b <- commit(p)) yield b).named("~>") }
1035+
= OnceParser{ (for(_ <- this; b <- commit(p)) yield b).named("~>") }
10361036

10371037
override def <~ [U](p: => Parser[U]): Parser[T]
1038-
= OnceParser{ (for(a <- this; b <- commit(p)) yield a).named("<~") }
1038+
= OnceParser{ (for(a <- this; _ <- commit(p)) yield a).named("<~") }
10391039
}
10401040
}

‎shared/src/main/scala/scala/util/parsing/combinator/lexical/StdLexical.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class StdLexical extends Lexical with StdTokens {
7979
// construct parser for delimiters by |'ing together the parsers for the individual delimiters,
8080
// starting with the longest one -- otherwise a delimiter D will never be matched if there is
8181
// another delimiter that is a prefix of D
82-
def parseDelim(s: String): Parser[Token] = accept(s.toList) ^^ { x => Keyword(s) }
82+
def parseDelim(s: String): Parser[Token] = accept(s.toList) ^^ { _ => Keyword(s) }
8383

8484
val d = new Array[String](delimiters.size)
8585
delimiters.copyToArray(d, 0)

‎shared/src/test/scala/scala/util/parsing/combinator/JavaTokenParsersTest.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
package scala.util.parsing.combinator
1414

15-
import scala.language.implicitConversions
1615
import scala.util.parsing.input.CharArrayReader
1716

1817
import org.junit.Test
@@ -46,7 +45,7 @@ class JavaTokenParsersTest {
4645
def parseFailure(s: String, errorColPos: Int): Unit = {
4746
val parseResult = parseAll(ident, s)
4847
parseResult match {
49-
case Failure(msg, next) =>
48+
case Failure(_, next) =>
5049
val pos = next.pos
5150
assertEquals(1, pos.line)
5251
assertEquals(errorColPos, pos.column)
@@ -85,7 +84,7 @@ class JavaTokenParsersTest {
8584

8685
val parseResult1 = parseAll(p, "start start")
8786
parseResult1 match {
88-
case e @Failure(message, next) =>
87+
case Failure(message, next) =>
8988
assertEquals(next.pos.line, 1)
9089
assertEquals(next.pos.column, 7)
9190
assert(message.endsWith("string matching regex '(?i)AND' expected but 's' found"))

‎shared/src/test/scala/scala/util/parsing/combinator/PackratParsersTest.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import org.junit.Test
1616
import org.junit.Assert.assertEquals
1717
import org.junit.Assert.assertTrue
1818

19-
import scala.language.implicitConversions
2019
import scala.util.parsing.combinator.syntactical.StandardTokenParsers
2120

2221
class PackratParsersTest {

‎shared/src/test/scala/scala/util/parsing/combinator/RegexParsersTest.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
package scala.util.parsing.combinator
1414

15-
import scala.language.implicitConversions
16-
1715
import org.junit.Test
1816
import org.junit.Assert.{ assertEquals, assertTrue }
1917

@@ -63,10 +61,10 @@ class RegexParsersTest {
6361
def halfQuoted = quote ~ string ^^ { case q ~ s => q + s }
6462
}
6563
import parser._
66-
valfailureLq=parseAll(p, "\"asdf").asInstanceOf[Failure]
67-
valfailureRq=parseAll(p, "asdf\"").asInstanceOf[Failure]
68-
valfailureQBacktrackL=parseAll(q | quote, "\"").asInstanceOf[Error]
69-
valfailureQBacktrackR=parseAll(q | halfQuoted, "\"asdf").asInstanceOf[Error]
64+
assertTrue(parseAll(p, "\"asdf").isInstanceOf[Failure])
65+
assertTrue(parseAll(p, "asdf\"").isInstanceOf[Failure])
66+
assertTrue(parseAll(q | quote, "\"").isInstanceOf[Error])
67+
assertTrue(parseAll(q | halfQuoted, "\"asdf").isInstanceOf[Error])
7068

7169
val successP = parseAll(p, "\"asdf\"").get
7270
assertEquals(successP, "asdf")

‎shared/src/test/scala/scala/util/parsing/combinator/gh242.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.junit.Assert.assertEquals
1414
import org.junit.Test
1515

16-
import scala.language.implicitConversions
1716
import scala.util.parsing.combinator.Parsers
1817
import scala.util.parsing.input.CharSequenceReader
1918

‎shared/src/test/scala/scala/util/parsing/combinator/gh29.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ package scala.util.parsing.combinator
1414

1515
import org.junit.Test
1616
import org.junit.Assert.assertEquals
17-
import scala.language.implicitConversions
1817

1918
class gh29 {
2019
object Foo extends JavaTokenParsers {

‎shared/src/test/scala/scala/util/parsing/combinator/gh45.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
package scala.util.parsing.combinator
1414

15-
import scala.language.implicitConversions
1615
import scala.util.parsing.input._
1716

1817
import org.junit.Test

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /