macwire icon indicating copy to clipboard operation
macwire copied to clipboard

Feature request: wiring abstract classes and traits

Open dsilvasc opened this issue 7 years ago • 0 comments

The following does not compile:

object Foo {
  trait Dep
  abstract class Abs {
    def foo: Dep
  }
  trait T {
    def bar: Dep
  }

  val d: Dep = new Dep {}

  val a: Abs = wire[Abs]
  val t: T = wire[T]

  def main(args: Array[String]): Unit =
    println(s"a.foo ${a.foo}")
}

MacWire says

Error: class Abs is abstract; cannot be instantiated
  val a: Abs = wire[Abs]
Error: Cannot find a public constructor nor a companion object for [Foo.T]
  val t: T = wire[T]

It would be nice if macwire could wire abstract classes and traits when it can satisfy abstract members like it does for constructor args.

dsilvasc avatar Sep 19 '18 19:09 dsilvasc