7mind / izumi

Productivity-oriented collection of lightweight fancy stuff for Scala toolchain

Home Page:https://izumi.7mind.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve error message for missing dependency when there are named bindings of the same type or bindings to subtypes

neko-kai opened this issue · comments

commented

Reported on gitter https://gitter.im/7mind/izumi?at=60896bdbb38a713b2fb4a31c

When there's missing dependency error for type X and there exist defined named bindings for the same type such as X @Id("x"), what could happen is that the user made a typo or an forgot the qualifier, to help with these situations, the error message should also list all existing bindings that share the same type such as:

Couldn't find `X @Id("a")` required by refs: A, B, C

Found other bindings the same type (did you forget to add or remove `@Id` annotation?):
  - X
  - X @Id("b")
  - X @Id("c")

As well, the list of related bindings could also feature those with a compatible type (by subtyping comparison), so that the user may find the correct binding for an interface if they tried to request a supertype of an existing binding:

Couldn't find `AnyVal` required by refs: A, B, C

Found other bindings the same type (did you forget to add or remove `@Id` annotation?):
  - AnyVal @Id("other")

Found other bindings for related subtypes (did you mean to summon one of them?):
  - Int
  - Boolean
  - Double @Id("NaN")