Skip to content

Commit

Permalink
Add cats-effect's IO monad support
Browse files Browse the repository at this point in the history
  • Loading branch information
joan38 committed Sep 13, 2018
1 parent dba75c4 commit b1770c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions autowire/shared/src/main/scala/autowire/Macros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package autowire
import scala.concurrent.Future
import scala.reflect.macros.Context
import language.experimental.macros
import acyclic.file

import Core._
import cats.effect.IO

object Macros {

Expand All @@ -31,12 +30,13 @@ object Macros {
import c.universe._
def futurize(t: Tree, member: MethodSymbol) = {
if (member.returnType <:< c.typeOf[Future[_]]) t
else if (member.returnType <:< c.typeOf[IO[_]]) q"$t.unsafeToFuture()"
else q"scala.concurrent.Future($t)"
}

def getValsOrMeths(curCls: Type): Iterable[Either[(c.Symbol, MethodSymbol), (c.Symbol, MethodSymbol)]] = {
def isAMemberOfAnyRef(member: Symbol) = weakTypeOf[AnyRef].members.exists(_.name == member.name)
val membersOfBaseAndParents: Iterable[Symbol] = curCls.declarations ++ curCls.baseClasses.map(_.asClass.toType.declarations).flatten
val membersOfBaseAndParents: Iterable[Symbol] = curCls.declarations ++ curCls.baseClasses.flatMap(_.asClass.toType.declarations)
val extractableMembers = for {
member <- membersOfBaseAndParents
if !isAMemberOfAnyRef(member)
Expand Down
17 changes: 9 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ val autowire = crossProject.settings(
autoCompilerPlugins := true,
addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.5"),
libraryDependencies ++= Seq(
"com.lihaoyi" %% "acyclic" % "0.1.5" % "provided",
"com.lihaoyi" %%% "utest" % "0.4.4" % "test",
"com.lihaoyi" %% "acyclic" % "0.1.5" % Provided,
"org.typelevel" %% "cats-effect" % "1.0.0" % Provided,
"com.lihaoyi" %%% "utest" % "0.4.4" % Test,
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"com.lihaoyi" %%% "upickle" % "0.4.4" % "test"
"com.lihaoyi" %%% "upickle" % "0.4.4" % Test
) ++ (
if (!scalaVersion.value.startsWith("2.10.")) Nil
else Seq(
Expand Down Expand Up @@ -52,15 +53,15 @@ val autowire = crossProject.settings(
).jvmSettings(
resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/",
libraryDependencies ++= Seq(
// "org.scala-lang" %% "scala-pickling" % "0.9.1" % "test",
"com.esotericsoftware.kryo" % "kryo" % "2.24.0" % "test"
// "com.typesafe.play" %% "play-json" % "2.4.8" % "test"
// "org.scala-lang" %% "scala-pickling" % "0.9.1" % Test,
"com.esotericsoftware.kryo" % "kryo" % "2.24.0" % Test
// "com.typesafe.play" %% "play-json" % "2.4.8" % Test
),
libraryDependencies ++= {
if (!scalaVersion.value.startsWith("2.11.")) Nil
else Seq(
"org.scala-lang" %% "scala-pickling" % "0.9.1" % "test",
"com.typesafe.play" %% "play-json" % "2.4.8" % "test"
"org.scala-lang" %% "scala-pickling" % "0.9.1" % Test,
"com.typesafe.play" %% "play-json" % "2.4.8" % Test
)
}
)
Expand Down

0 comments on commit b1770c2

Please sign in to comment.