Skip to content

Commit

Permalink
Update to kantan.sbt 2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nrinaudo committed Dec 20, 2019
1 parent 3c05690 commit ae0eb8d
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ trait DecoderInstances {

implicit final def decoderInstances[E, F, T]
: SemigroupK[({ type L[A] = Decoder[E, A, F, T] })#L] with MonadError[({ type L[A] = Decoder[E, A, F, T] })#L, F] =
new SemigroupK[({ type L[A] = Decoder[E, A, F, T] })#L]
with MonadError[({ type L[A] = Decoder[E, A, F, T] })#L, F] {
new SemigroupK[({ type L[A] = Decoder[E, A, F, T] })#L]
with MonadError[({ type L[A] = Decoder[E, A, F, T] })#L, F] {

final def combineK[D](x: Decoder[E, D, F, T], y: Decoder[E, D, F, T]): Decoder[E, D, F, T] = x.orElse(y)

Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/kantan/codecs/Decoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ trait Decoder[Encoded, Decoded, Failure, Tag] extends Serializable {
@SuppressWarnings(Array("org.wartremover.warts.StringPlusAny"))
def unsafeDecode(e: Encoded): Decoded = decode(e).fold(
error => sys.error(s"Failed to decode value $e: $error"),
d => d
d => d
)

// - Composition -----------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ trait ResourceIterator[+A] extends VersionSpecificResourceIterator[A] with java.
else {
if(try {
checkNext
} catch {
}
catch {
case scala.util.control.NonFatal(e) =>
lastError = Some(e)
close()
Expand All @@ -117,7 +118,8 @@ trait ResourceIterator[+A] extends VersionSpecificResourceIterator[A] with java.
val n = readNext()
hasNext
n
} catch {
}
catch {
case e: Throwable =>
close()
throw e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ package kantan.codecs.export

import kantan.codecs.{Decoder, Encoder}
import kantan.codecs.export.DerivedCodecTests.{Just, Maybe, None}
import kantan.codecs.strings.{codecs, DecodeError, StringDecoder, StringEncoder, StringResult}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
import kantan.codecs.strings.{codecs, DecodeError, StringDecoder, StringEncoder, StringResult}

class DerivedCodecTests extends AnyFunSuite with ScalaCheckPropertyChecks with Matchers {
val decode: String => StringResult[Maybe[Int]] = s =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package kantan.codecs.strings.java8

import java.time.{Instant, LocalDate, LocalDateTime, LocalTime, OffsetDateTime, ZoneOffset, ZonedDateTime}
import java.time.{Instant, LocalDate, LocalDateTime, LocalTime, OffsetDateTime, ZonedDateTime}
import java.time.format.DateTimeFormatter
import java.time.temporal.TemporalAccessor
import kantan.codecs.strings.{StringDecoder, StringResult}
Expand Down Expand Up @@ -171,7 +171,8 @@ object Format {
format.formatter
Right(format)

} catch {
}
catch {
case _: Exception => Left(s"Invalid pattern: '$pattern'")
}

Expand All @@ -191,7 +192,7 @@ object Format {
* res2: StringResult[Instant] = Right(2000-01-01T12:00:00Z)
* }}}
*/
val defaultInstantFormat: Format = Format(DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC))
val defaultInstantFormat: Format = Format(DateTimeFormatter.ISO_INSTANT.withZone(java.time.ZoneOffset.UTC))

/** Default `LocalDateTime` format.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package kantan.codecs.strings.java8

import java.time.{Instant, ZonedDateTime, OffsetDateTime, LocalDateTime, LocalDate, LocalTime}
import java.time.{Instant, LocalDate, LocalDateTime, LocalTime, OffsetDateTime, ZonedDateTime}
import kantan.codecs.Decoder
import kantan.codecs.export.Exported
import kantan.codecs.strings.{DecodeError, StringDecoder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ trait CommonArbitraryInstances extends ArbitraryArities {
} yield {
try {
BigDecimal(x, scale, mc)
} catch {
}
catch {
// Handle the case where scale/precision conflict
case _: java.lang.ArithmeticException => BigDecimal(x, scale, UNLIMITED)
}
Expand Down Expand Up @@ -174,7 +175,7 @@ trait CommonArbitraryInstances extends ArbitraryArities {
Arbitrary(
Gen.oneOf(
arb[Exception].map(e => scala.util.Failure(e): Try[A]),
aa.arbitrary.map(a => scala.util.Success(a): Try[A])
aa.arbitrary.map(a => scala.util.Success(a): Try[A])
)
)
}
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
addSbtPlugin("com.nrinaudo" % "kantan.sbt-kantan" % "2.5.1")
addSbtPlugin("com.nrinaudo" % "kantan.sbt-scalajs" % "2.5.1")
addSbtPlugin("com.nrinaudo" % "kantan.sbt-kantan" % "2.6.0")
addSbtPlugin("com.nrinaudo" % "kantan.sbt-scalajs" % "2.6.0")

0 comments on commit ae0eb8d

Please sign in to comment.