wrong constructor is being picked up
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the provided Scala reproduction and the wire[Target] entry point, then compare constructor selection with and without the explicit Target result type. The issue is resolved when the annotated constructor is selected without requiring val sa: Target and the reproduction no longer produces the ambiguity errors.
Written by the indexing model from the issue text.
Description
In below code I am trying to construct Target object. Target class has 3 constructors but only one is preffered (the one annotated). This results in compilation error because wire[Target] picks up wrong constructor. I've intentionally provided to much eligible values here in order to show the naughty behaviour:
trait A
trait B
trait C
class Target(a: A) {
def this(b: B) = this(new A{})
@javax.inject.Inject
def this(c: C) = this(new A{})
}
val a: A = new A {}
val a1: A = new A {}
val b: B = new B {}
val b1: B = new B {}
val c = new C {}
val sa = wire[Target]
Error:(24, 16) Found multiple values of type [com.softwaremill.macwire.macwireakka.Demo.A]: [List(a, a1)]
val sa = wire[Target]
Error:(24, 16) ambiguous reference to overloaded definition,
both constructor Target in class Target of type (c: com.softwaremill.macwire.macwireakka.Demo.C)com.softwaremill.macwire.macwireakka.Demo.Target
and constructor Target in class Target of type (b: com.softwaremill.macwire.macwireakka.Demo.B)com.softwaremill.macwire.macwireakka.Demo.Target
match argument types (Null) and expected result type com.softwaremill.macwire.macwireakka.Demo.Target
val sa = wire[Target]
However if you provide type after sa:
val sa: Target = wire[Target]
it works fine.
- Dominant language
- Scala
- Stars
- 1.3k
- Forks
- 77
- Avg merge
- 9m
- Merged PRs (30d)
- 4
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.
More from softwaremill/macwire
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
softwaremill/macwire#412 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
softwaremill/macwire#391 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
softwaremill/macwire#301 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
softwaremill/macwire#281 · 5 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
softwaremill/macwire#278 · 3 comments ·
All issues in softwaremill/macwire
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ergoplatform/ergodocs#614 ·
-
area:ci enhancement requires-triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/datafusion-comet#6078 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug delta-datalayout flink
Difficulty 2/5 1-3 hours Newbie friendliness 86/100