diff --git a/akka-http-core/src/main/java/akka/http/javadsl/model/headers/CacheDirectives.java b/akka-http-core/src/main/java/akka/http/javadsl/model/headers/CacheDirectives.java index a6662a32cb..5673e1ee5c 100644 --- a/akka-http-core/src/main/java/akka/http/javadsl/model/headers/CacheDirectives.java +++ b/akka-http-core/src/main/java/akka/http/javadsl/model/headers/CacheDirectives.java @@ -32,7 +32,7 @@ public final class CacheDirectives { public static final CacheDirective MUST_REVALIDATE = akka.http.scaladsl.model.headers.CacheDirectives.must$minusrevalidate$.MODULE$; public static CacheDirective NO_CACHE(String... fieldNames) { - return akka.http.scaladsl.model.headers.CacheDirectives.no$minuscache$.MODULE$.apply(fieldNames); + return akka.http.scaladsl.model.headers.CacheDirectives.no$minuscache$.MODULE$.apply(akka.japi.Util.immutableSeq(fieldNames)); } public static final CacheDirective PUBLIC = akka.http.scaladsl.model.headers.CacheDirectives.getPublic(); public static CacheDirective PRIVATE(String... fieldNames) { diff --git a/akka-http-core/src/main/scala/akka/http/scaladsl/model/headers/CacheDirective.scala b/akka-http-core/src/main/scala/akka/http/scaladsl/model/headers/CacheDirective.scala index 0977a5f8a8..b72902bf6f 100644 --- a/akka-http-core/src/main/scala/akka/http/scaladsl/model/headers/CacheDirective.scala +++ b/akka-http-core/src/main/scala/akka/http/scaladsl/model/headers/CacheDirective.scala @@ -68,7 +68,7 @@ object CacheDirectives { // http://tools.ietf.org/html/rfc7234#section-5.2.1.4 case object `no-cache` extends SingletonValueRenderable with RequestDirective with ResponseDirective { - @varargs def apply(fieldNames: String*): `no-cache` = apply(immutable.Seq(fieldNames: _*)) + def apply(fieldNames: String*): `no-cache` = new `no-cache`(immutable.Seq(fieldNames: _*)) } // http://tools.ietf.org/html/rfc7234#section-5.2.1.5 @@ -97,11 +97,11 @@ object CacheDirectives { // http://tools.ietf.org/html/rfc7234#section-5.2.2.6 final case class `private`(fieldNames: immutable.Seq[String]) extends FieldNamesDirective with ResponseDirective object `private` { - @varargs def apply(fieldNames: String*): `private` = apply(immutable.Seq(fieldNames: _*)) + def apply(fieldNames: String*): `private` = new `private`(immutable.Seq(fieldNames: _*)) } /** Java API */ - @varargs def createPrivate(fieldNames: String*): ResponseDirective = `private`.apply(immutable.Seq(fieldNames: _*)) + @varargs def createPrivate(fieldNames: String*): ResponseDirective = new `private`(immutable.Seq(fieldNames: _*)) // http://tools.ietf.org/html/rfc7234#section-5.2.2.7 case object `proxy-revalidate` extends SingletonValueRenderable with ResponseDirective diff --git a/akka-http-core/src/main/scala/akka/http/scaladsl/util/FastFuture.scala b/akka-http-core/src/main/scala/akka/http/scaladsl/util/FastFuture.scala index 3949a902a5..aa5a766035 100644 --- a/akka-http-core/src/main/scala/akka/http/scaladsl/util/FastFuture.scala +++ b/akka-http-core/src/main/scala/akka/http/scaladsl/util/FastFuture.scala @@ -80,6 +80,10 @@ object FastFuture { def isCompleted = true def result(atMost: Duration)(implicit permit: CanAwait) = a def ready(atMost: Duration)(implicit permit: CanAwait) = this + def transform[S](f: scala.util.Try[A] => scala.util.Try[S])(implicit executor: scala.concurrent.ExecutionContext): scala.concurrent.Future[S] = + FastFuture(f(Success(a))) + def transformWith[S](f: scala.util.Try[A] => scala.concurrent.Future[S])(implicit executor: scala.concurrent.ExecutionContext): scala.concurrent.Future[S] = + new FastFuture(this).transformWith(f) } private case class ErrorFuture(error: Throwable) extends Future[Nothing] { def value = Some(Failure(error)) @@ -87,6 +91,10 @@ object FastFuture { def isCompleted = true def result(atMost: Duration)(implicit permit: CanAwait) = throw error def ready(atMost: Duration)(implicit permit: CanAwait) = this + def transform[S](f: scala.util.Try[Nothing] => scala.util.Try[S])(implicit executor: scala.concurrent.ExecutionContext): scala.concurrent.Future[S] = + FastFuture(f(Failure(error))) + def transformWith[S](f: scala.util.Try[Nothing] => scala.concurrent.Future[S])(implicit executor: scala.concurrent.ExecutionContext): scala.concurrent.Future[S] = + new FastFuture(this).transformWith(f) } implicit class EnhancedFuture[T](val future: Future[T]) extends AnyVal { diff --git a/akka-parsing/src/main/scala/akka/parboiled2/support/OpTreeContext.scala b/akka-parsing/src/main/scala/akka/parboiled2/support/OpTreeContext.scala index 7c7b40eb6b..a9f9dfc95c 100644 --- a/akka-parsing/src/main/scala/akka/parboiled2/support/OpTreeContext.scala +++ b/akka-parsing/src/main/scala/akka/parboiled2/support/OpTreeContext.scala @@ -379,33 +379,37 @@ trait OpTreeContext[OpTreeCtx <: ParserMacros.ParserContext] { } } - def Times(base: Tree, rule: OpTree, collector: Collector, separator: Separator = null): OpTree = + def Times(base: Tree, rule: OpTree, collector: Collector, separator: Separator = null): OpTree = { + def handleRange(mn: Tree, mx: Tree, r: Tree) = (mn, mx) match { + case (Literal(Constant(min: Int)), Literal(Constant(max: Int))) ⇒ + if (min <= 0) c.abort(mn.pos, "`min` in `(min to max).times` must be positive") + else if (max <= 0) c.abort(mx.pos, "`max` in `(min to max).times` must be positive") + else if (max < min) c.abort(mx.pos, "`max` in `(min to max).times` must be >= `min`") + else Times(rule, q"val min = $mn; val max = $mx", collector, separator) + case ((Ident(_) | Select(_, _)), (Ident(_) | Select(_, _))) ⇒ + Times(rule, q"val min = $mn; val max = $mx", collector, separator) + case _ ⇒ c.abort(r.pos, "Invalid int range expression for `.times(...)`: " + r) + } + base match { case q"$a.this.int2NTimes($n)" ⇒ n match { case Literal(Constant(i: Int)) ⇒ if (i <= 0) c.abort(base.pos, "`x` in `x.times` must be positive") else if (i == 1) rule else Times(rule, q"val min, max = $n", collector, separator) - case x @ (Ident(_) | Select(_, _)) ⇒ Times(rule, q"val min = $n; val max = min", collector, separator) - case _ ⇒ c.abort(n.pos, "Invalid int base expression for `.times(...)`: " + n) + case x@(Ident(_) | Select(_, _)) ⇒ Times(rule, q"val min = $n; val max = min", collector, separator) + case _ ⇒ c.abort(n.pos, "Invalid int base expression for `.times(...)`: " + n) } case q"$a.this.range2NTimes($r)" ⇒ r match { - case q"scala.this.Predef.intWrapper($mn).to($mx)" ⇒ (mn, mx) match { - case (Literal(Constant(min: Int)), Literal(Constant(max: Int))) ⇒ - if (min <= 0) c.abort(mn.pos, "`min` in `(min to max).times` must be positive") - else if (max <= 0) c.abort(mx.pos, "`max` in `(min to max).times` must be positive") - else if (max < min) c.abort(mx.pos, "`max` in `(min to max).times` must be >= `min`") - else Times(rule, q"val min = $mn; val max = $mx", collector, separator) - case ((Ident(_) | Select(_, _)), (Ident(_) | Select(_, _))) ⇒ - Times(rule, q"val min = $mn; val max = $mx", collector, separator) - case _ ⇒ c.abort(r.pos, "Invalid int range expression for `.times(...)`: " + r) - } - case x @ (Ident(_) | Select(_, _)) ⇒ + case q"scala.Predef.intWrapper($mn).to($mx)" ⇒ handleRange(mn, mx, r) // Scala 2.12 + case q"scala.this.Predef.intWrapper($mn).to($mx)" ⇒ handleRange(mn, mx, r) // Scala 2.11 + case x@(Ident(_) | Select(_, _)) ⇒ Times(rule, q"val r = $r; val min = r.start; val max = r.end", collector, separator) case _ ⇒ c.abort(r.pos, "Invalid range base expression for `.times(...)`: " + r) } case _ ⇒ c.abort(base.pos, "Invalid base expression for `.times(...)`: " + base) } + } case class Times(op: OpTree, init: Tree, collector: Collector, separator: Separator) extends WithSeparator { def withSeparator(sep: Separator) = copy(separator = sep) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 58ba966877..84a6507094 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -33,7 +33,7 @@ object Dependencies { val netty = "io.netty" % "netty" % "3.10.3.Final" // ApacheV2 val scalaStm = Def.setting { "org.scala-stm" %% "scala-stm" % scalaStmVersion.value } // Modified BSD (Scala) - val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.0.1" // Scala License + val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.0.5" // Scala License val scalaReflect = ScalaVersionDependentModuleID.versioned("org.scala-lang" % "scala-reflect" % _) // Scala License val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.16" // MIT @@ -174,7 +174,7 @@ object Dependencies { DependencyHelpers.versionDependentDeps( Dependencies.Compile.scalaReflect % "provided" ), - addCompilerPlugin("org.scalamacros" % "paradise" % "2.0.1" cross CrossVersion.fullMapped(nominalScalaVersion)) + addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.fullMapped(nominalScalaVersion)) ) lazy val httpTestkit = l ++= Seq(