diff --git a/autowire/shared/src/main/scala/autowire/Macros.scala b/autowire/shared/src/main/scala/autowire/Macros.scala index d2e1137..e08e11b 100644 --- a/autowire/shared/src/main/scala/autowire/Macros.scala +++ b/autowire/shared/src/main/scala/autowire/Macros.scala @@ -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 { @@ -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) diff --git a/build.sbt b/build.sbt index c2500f1..ac4a863 100644 --- a/build.sbt +++ b/build.sbt @@ -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( @@ -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 ) } )