Closed eed3si9n closed 3 years ago
/*
* Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>
*/
package play.api.libs
/**
* Provides implicit type classes when you import the package.
*/
package object ws extends WSBodyReadables with WSBodyWritables
/*
* Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>
*/
package play.api.libs.ws
/**
* JSON, XML and Multipart Form Data Readables used for Play-WS bodies.
*/
trait WSBodyReadables extends DefaultBodyReadables with JsonBodyReadables with XMLBodyReadables
object WSBodyReadables extends WSBodyReadables
/*
* Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>
*/
package play.api.libs.ws
import akka.stream.scaladsl.Source
import akka.util.ByteString
import play.api.mvc.MultipartFormData
import play.core.formatters.Multipart
/**
* JSON, XML and Multipart Form Data Writables used for Play-WS bodies.
*/
trait WSBodyWritables extends DefaultBodyWritables with JsonBodyWritables with XMLBodyWritables {
implicit val bodyWritableOf_Multipart: BodyWritable[Source[MultipartFormData.Part[Source[ByteString, _]], _]] = {
val boundary = Multipart.randomBoundary()
val contentType = s"multipart/form-data; boundary=$boundary"
BodyWritable(b => SourceBody(Multipart.transform(b, boundary)), contentType)
}
}
object WSBodyWritables extends WSBodyWritables
It's interesting to think about the semantics of this compilation. Let's say you start from the top.
package.scala
you need WSBodyReadables
and WSBodyWritables
WSBodyReadables.scala
. The trait WSBodyReadables
is inside play.api.libs.ws
package. Does it expose any implicits? We know it does because of WSBodyReadables
, but package.class
doesn't exist yet.This may not be a zinc bug. The circe community build was fixed by https://github.com/sbt/sbt/pull/4949 on my computer.
A potential variant when changing branches in scala/scala - https://gist.github.com/eed3si9n/468c902ea116893c4b86d31b205c489c
I found a reproduction and updated the description of this bug with the details. I'm looking for a fix now.
steps
For example running Play's 2.7.x branch with 1.3.0-RC3 on Community Builds - https://scala-ci.typesafe.com/job/scala-2.12.x-integrate-community-build/4719/console
problem
expectation
Compiles. It works locally on my machine.
notes
See also https://github.com/scala/scala-dev/issues/441
@dwijnand noted
@retronym found a standalone reproduction: