Diverging Inject instances
Open
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 5.5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 5
Description
Given this specific case when a type constructor being injected is the right-right part of Coproduct and defined in object.
trait Foo[A]
trait Bar[A]
object Baz {
trait F[A]
}
object Repro {
Inject[Baz.F, Coproduct[Foo, Coproduct[Bar, Baz.F, ?], ?]]
}
It does not compile and I get
Error:(12, 9) diverging implicit expansion for type cats.free.Inject[Baz.F,[γ$0$]cats.data.Coproduct[Foo,[γ$1$]cats.data.Coproduct[Bar,Baz.F,γ$1$],γ$0$]]
starting with method catsFreeReflexiveInjectInstance in class InjectInstances
Inject[Baz.F, Coproduct[Foo, Coproduct[Bar, Baz.F, ?], ?]]
I compiles well if move F out of Baz. But sadly for my case it's not an option.
Contributor guide
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 by running the Scala reproduction with Inject[Baz.F, Coproduct[Foo, Coproduct[Bar, Baz.F, ?], ?]] and inspect cats.free.Inject, Coproduct, and InjectInstances, especially catsFreeReflexiveInjectInstance. Done means the shown object-defined Baz.F case compiles without diverging implicit expansion while the existing Inject behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100