softwaremill / softwaremill/macwire
Feature request: wiring abstract classes and traits
Open
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.3k
- Forks
- 77
- Avg merge
- 9m
- Merged PRs (30d)
- 4
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Scala reproduction in the issue and inspect how macwire currently handles constructor arguments, abstract classes, and traits. Define completion as making both wire[Abs] and wire[T] compile when their abstract members can be satisfied, while preserving the existing error behavior when they cannot.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100