Skip to content

Commit 66b1cf6

Browse files
authored
Merge pull request #422 from 47degrees/fix/compiler-warnings-2020-01-13
Fix compiler warnings across project
2 parents db771e0 + b214738 commit 66b1cf6

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

fetch-debug/src/main/scala/document.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract class Document {
4242
* Format this document on `writer` and try to set line
4343
* breaks so that the result fits in `width` columns.
4444
*/
45-
def format(width: Int, writer: Writer) {
45+
def format(width: Int, writer: Writer): Unit = {
4646
type FmtState = (Int, Boolean, Document)
4747

4848
def fits(w: Int, state: List[FmtState]): Boolean =
@@ -67,7 +67,7 @@ abstract class Document {
6767
fits(w, (i, false, d) :: z)
6868
}
6969

70-
def spaces(n: Int) {
70+
def spaces(n: Int): Unit = {
7171
var rem = n
7272
while (rem >= 16) { writer write " "; rem -= 16 }
7373
if (rem >= 8) { writer write " "; rem -= 8 }

fetch-examples/src/test/scala/GithubExample.scala

+10-8
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,14 @@ class GithubExample extends AnyWordSpec with Matchers {
8585
val url = GITHUB / "repos" / owner / repo +? ("access_token", ACCESS_TOKEN)
8686
val req = Request[F](Method.GET, url)
8787
for {
88-
result <- c.fetch[Repo](req)({
89-
case Status.Ok(res) =>
90-
res.as[Repo]
91-
case res =>
92-
CF.raiseError(new Exception(res.body.toString))
93-
})
88+
result <- c
89+
.run(req)
90+
.use[F, Repo] {
91+
case Status.Ok(res) =>
92+
res.as[Repo]
93+
case res =>
94+
CF.raiseError(new Exception(res.body.toString))
95+
}
9496
} yield Option(result)
9597
}
9698
}
@@ -228,7 +230,7 @@ class GithubExample extends AnyWordSpec with Matchers {
228230
val GITHUB: Uri = Uri.unsafeFromString("https://api.github.com")
229231

230232
private def fetchCollectionRecursively[F[_], A](c: Client[F], req: Request[F])(implicit
231-
CF: MonadError[F, Throwable],
233+
CF: BracketThrow[F],
232234
E: EntityDecoder[F, List[A]]
233235
): F[List[A]] = {
234236
val REL_NEXT = "rel=\"next\"".r
@@ -256,7 +258,7 @@ class GithubExample extends AnyWordSpec with Matchers {
256258
)
257259

258260
for {
259-
result <- c.fetch[List[A]](req) {
261+
result <- c.run(req).use[F, List[A]] {
260262
case Status.Ok(res) =>
261263
if (hasNext(res)) {
262264
for {

fetch/src/main/scala/fetch.scala

+8-5
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ object `package` {
166166
val newRequest = Batch(combined, ds)
167167
val newResult = CombinationSuspend((r: FetchStatus) =>
168168
r match {
169-
case FetchDone(m: Map[Any, Any]) =>
169+
case FetchDone(preM) =>
170+
val m = preM.asInstanceOf[Map[Any, Any]]
170171
val xResult = m.get(aId).map(FetchDone(_)).getOrElse(FetchMissing())
171172
val yResult = m.get(anotherId).map(FetchDone(_)).getOrElse(FetchMissing())
172173
CombinationBarrier(() => x.result, xResult)
@@ -184,7 +185,8 @@ object `package` {
184185
val newRequest = Batch(combined, ds)
185186
val newResult = CombinationSuspend((r: FetchStatus) =>
186187
r match {
187-
case FetchDone(m: Map[Any, Any]) =>
188+
case FetchDone(preM) =>
189+
val m = preM.asInstanceOf[Map[Any, Any]]
188190
val oneResult = m.get(oneId).map(FetchDone(_)).getOrElse(FetchMissing())
189191
CombinationBarrier(() => x.result, oneResult)
190192
.flatMap(() => y.result)
@@ -201,7 +203,8 @@ object `package` {
201203
val newRequest = Batch(combined, ds)
202204
val newResult = CombinationSuspend((r: FetchStatus) =>
203205
r match {
204-
case FetchDone(m: Map[Any, Any]) =>
206+
case FetchDone(preM) =>
207+
val m = preM.asInstanceOf[Map[Any, Any]]
205208
val oneResult = m.get(oneId).map(FetchDone(_)).getOrElse(FetchMissing())
206209
CombinationBarrier(() => y.result, oneResult)
207210
.flatMap(() => x.result)
@@ -258,8 +261,8 @@ object `package` {
258261

259262
// Fetch Monad
260263

261-
implicit def fetchM[F[_]: Monad]: Monad[Fetch[F, ?]] =
262-
new Monad[Fetch[F, ?]] with StackSafeMonad[Fetch[F, ?]] {
264+
implicit def fetchM[F[_]: Monad]: Monad[Fetch[F, *]] =
265+
new Monad[Fetch[F, *]] with StackSafeMonad[Fetch[F, *]] {
263266
def pure[A](a: A): Fetch[F, A] =
264267
Unfetch(
265268
Monad[F].pure(Done(a))

0 commit comments

Comments
 (0)