Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in wireWith and implicit parameters #125

Closed
e-kolpakov opened this issue Feb 8, 2018 · 2 comments · Fixed by #151
Closed

Bug in wireWith and implicit parameters #125

e-kolpakov opened this issue Feb 8, 2018 · 2 comments · Fixed by #151

Comments

@e-kolpakov
Copy link

Problem description, steps to reproduce and (a bit of) discussion:

https://stackoverflow.com/questions/48657546/macwire-wirewith-and-implicit-parameters.

Minimal example:

import com.softwaremill.macwire._

object A {
  def props(x: Int)(implicit y: String): A = new A(x)
}

class A(x: Int)(implicit y: String) {
   val sum: String = s"$x + $y"
}

object App {
   def main(): Unit = {
     val xVal: Int = 3
     implicit val yVal: String = "5"

     // val aInstance = wire[A] // works
     // val aInstance = A.props(xVal) // works
     val aInstance: A = wireWith(A.props _) // compile error

     println(aInstance.sum)
  }
}

App.main()

Error:

Error:(21, 33) type mismatch; found   : Int required: String
    val aInstance: A = wireWith(A.props _)
@pakaufmann
Copy link

This bugs seems to still be present, if you try to wire a function which has implicit Parameters:

Example:

val double = 1.0

def testWiring[F[_] : Monad](first: Double): F[String] = {
    (first + second).toString.pure[F]
}

val test = wireWith(testWiring[IO] _)

This results in the Generated code Generated code: testWiring[cats.effect.IO](first)(double), which then gives a compile time error, as it tries to apply double to the implicit parameter list for Monad[F].

@adamw
Copy link
Member

adamw commented May 5, 2020

Fixed in 2.3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants