Merge pull request #19815 from ktoso/wip-fixups-for-2.12.0-M3-ktoso

=htc make HTTP compile under Scala 2.12.0-M3
This commit is contained in:
Konrad Malawski 2016-02-22 17:05:23 +01:00
commit 06e17602ef
5 changed files with 32 additions and 20 deletions

View file

@ -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) {

View file

@ -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

View file

@ -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 {

View file

@ -379,7 +379,18 @@ 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))
@ -390,22 +401,15 @@ trait OpTreeContext[OpTreeCtx <: ParserMacros.ParserContext] {
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 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)

View file

@ -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(