Skip to content

Commit

Permalink
feature: remove more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre committed May 13, 2024
1 parent 167e256 commit e458fa4
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 83 deletions.
14 changes: 10 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ lazy val specs2Settings = Seq(
organization := "org.specs2",
GlobalScope / scalazVersion := "7.2.32",
specs2ShellPrompt,
ThisBuild / scalaVersion := "2.13.10",
ThisBuild / scalaVersion := "2.13.14",
SettingKey[Boolean]("ide-skip-project").withRank(KeyRanks.Invisible) := platformDepsCrossVersion.value == ScalaNativeCrossVersion.binary,
ThisBuild / crossScalaVersions := Seq("2.13.8", "2.12.17"))
ThisBuild / crossScalaVersions := Seq("2.13.14", "2.12.17"))

lazy val tagName = Def.setting {
s"specs2-${version.value}"
Expand Down Expand Up @@ -424,7 +424,13 @@ lazy val compilationSettings = Seq(
"-Xlint",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-deprecation:false", "-Xcheckinit", "-unchecked", "-feature", "-language:_"),
"-deprecation:false",
"-Xcheckinit",
"-unchecked",
"-feature",
"-language:_",
"-Wunused:-nowarn",
),
Compile / scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
Expand All @@ -449,7 +455,7 @@ lazy val compilationSettings = Seq(
"-Xlint:-byname-implicit")
}
},
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.13.2" cross CrossVersion.full),
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.13.3" cross CrossVersion.full),
Test / scalacOptions += "-Yrangepos",
Compile / doc / scalacOptions ++= Seq("-feature", "-language:_"),
Compile / console / scalacOptions := Seq("-Yrangepos", "-feature", "-language:_"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ case class ExecutionEnv(executorServices: ExecutorServices,
lazy val executionContext = executorServices.executionContext
lazy val scheduler = executorServices.scheduler

implicit lazy val ec = executorServices.executionContext
implicit lazy val ec: ExecutionContext = executorServices.executionContext
}

object ExecutionEnv {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ case class ExecutionEnv(executorServices: ExecutorServices,
lazy val executionContext = executorServices.executionContext
lazy val scheduler = executorServices.scheduler

implicit lazy val ec = executorServices.executionContext
implicit lazy val ec: ExecutionContext = executorServices.executionContext
}

object ExecutionEnv {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.specs2.fp._
import org.specs2.fp.syntax._
import eff._
import interpret._
import SafeInterpretation._

import scala.reflect.ClassTag

Expand Down Expand Up @@ -122,16 +123,16 @@ trait SafeInterpretation extends SafeCreation { outer =>
var error: Option[Throwable] = None

val traversed: T[X] = xs.map {
case FailedFinalizer(t) => failedFinalizers.append(t); ().asInstanceOf[X]
case FailedValue(t) => error = Some(t); ().asInstanceOf[X]
case FailedFinalizer(t) => failedFinalizers.append(t); unitCastTo[X]
case FailedValue(t) => error = Some(t); unitCastTo[X]
case EvaluateValue(v) =>
error match {
case None =>
Either.catchNonFatal(v.value) match {
case Right(a) => a
case Left(t) => error = Some(t); ().asInstanceOf[X]
case Left(t) => error = Some(t); unitCastTo[X]
}
case Some(_) => ().asInstanceOf[X]
case Some(_) => unitCastTo[X]
}
}

Expand All @@ -147,16 +148,16 @@ trait SafeInterpretation extends SafeCreation { outer =>
var error: Option[Throwable] = None

val traversed: T[X] = xs.map {
case FailedFinalizer(t) => { failedFinalizers.append(t); ().asInstanceOf[X] }
case FailedValue(t) => { error = Some(t); ().asInstanceOf[X] }
case FailedFinalizer(t) => { failedFinalizers.append(t); unitCastTo[X] }
case FailedValue(t) => { error = Some(t); unitCastTo[X] }
case EvaluateValue(v) =>
error match {
case None =>
Either.catchNonFatal(v.value) match {
case Right(a) => a
case Left(t) => error = Some(t); ().asInstanceOf[X]
case Left(t) => error = Some(t); unitCastTo[X]
}
case Some(_) => ().asInstanceOf[X]
case Some(_) => unitCastTo[X]
}
}

Expand All @@ -167,6 +168,7 @@ trait SafeInterpretation extends SafeCreation { outer =>
}

}

}


Expand Down Expand Up @@ -235,12 +237,12 @@ trait SafeInterpretation extends SafeCreation { outer =>
val failedValues = new collection.mutable.ListBuffer[FailedValue[X]]

val traversed: T[X] = xs.map {
case FailedFinalizer(t) => ().asInstanceOf[X]
case FailedValue(t) => ().asInstanceOf[X]
case FailedFinalizer(t) => unitCastTo[X]
case FailedValue(t) => unitCastTo[X]
case EvaluateValue(v) =>
Either.catchNonFatal(v.value) match {
case Right(a) => a
case Left(t) => failedValues.append(FailedValue[X](t)); ().asInstanceOf[X]
case Left(t) => failedValues.append(FailedValue[X](t)); unitCastTo[X]
}
}

Expand All @@ -262,12 +264,12 @@ trait SafeInterpretation extends SafeCreation { outer =>
val failedValues = new collection.mutable.ListBuffer[FailedValue[X]]

val traversed: T[X] = xs.map {
case FailedFinalizer(t) => ().asInstanceOf[X]
case FailedValue(t) => ().asInstanceOf[X]
case FailedFinalizer(t) => unitCastTo[X]
case FailedValue(t) => unitCastTo[X]
case EvaluateValue(v) =>
Either.catchNonFatal(v.value) match {
case Right(a) => a
case Left(t) => failedValues.append(FailedValue[X](t)); ().asInstanceOf[X]
case Left(t) => failedValues.append(FailedValue[X](t)); unitCastTo[X]
}
}

Expand Down Expand Up @@ -341,7 +343,11 @@ trait SafeInterpretation extends SafeCreation { outer =>

}

object SafeInterpretation extends SafeInterpretation

object SafeInterpretation extends SafeInterpretation {
@annotation.nowarn
private def unitCastTo[X]: X = ().asInstanceOf[X]
}

/**
* The Safe type is a mix of a ThrowableEither / Eval effect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.specs2.control

import org.specs2._
import io._
import eff._, syntax.all._

class ActionsSpec extends Specification { def is = s2"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.specs2
package reporter

import main._
import control._
import execute._
import io.StringOutput
import org.specs2.specification.{AfterAll, Tables}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class SbtSelectorSpec extends Specification {
private def testName(event: Event): String = {
event.selector() match {
case ts: TestSelector => ts.testName()
case other => s"no test selector found. Got: ${other}"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package org.specs2
package specification
package script

import scala.util.matching.Regex

import util.matching.Regex
import control.{ImplicitParameters, Use}
import control.Exceptions._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package mutable
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global

@annotation.nowarn
class FutureExpectationsImmutableSpec extends org.specs2.Specification { def is = s2"""

A specification can return future results
Expand All @@ -16,14 +17,15 @@ class FutureExpectationsImmutableSpec extends org.specs2.Specification { def is

}

@annotation.nowarn
class FutureExpectationsMutableSpec extends org.specs2.mutable.Specification {

"A specification can return future results" >> {
"For example here" in {
Future.apply(1 === 1)
Future.apply(1 === 1)(global)
}
"For example there" in { withTitle: String =>
Future.apply(withTitle === "For example there")
Future.apply(withTitle === "For example there")(global)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.specs2.main._
* the following specifications should be instantiable from both the JVM and ScalaJS
*/

@annotation.nowarn
class Shared1Spec extends mutable.Specification {
import scala.concurrent.ExecutionContext.Implicits.global
"This must work with the global Execution Context" should {
Expand Down
2 changes: 1 addition & 1 deletion markdown/src/test/scala/org/specs2/text/MarkdownSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.specs2.main.Arguments
import org.specs2.mutable._

class MarkdownSpec extends Spec {
implicit val defaultArgs = Arguments()
implicit val defaultArgs: Arguments = Arguments()

"Emphasized text" >>
{ toHtmlNoPar("_hello_") must_== "<em>hello</em>" }
Expand Down
Loading

0 comments on commit e458fa4

Please sign in to comment.