Closed mdekstrand closed 9 years ago
Since this works and fixes the problem I need it to in LensKit, I am going to go ahead and merge. The deficiencies primarily arise in pathological edge cases, and we can improve the error reporting and some linting. Also, I have written it to be conservative and fail more; design changes are most likely to decrease the failure modes, which is a compatible change.
This adds a new flag,
skipIfUnusable
, to default specifications that instructs Grapht to skip that default binding if one of its direct dependencies cannot be resolved. If the direct dependencies can be resolved, but one of their dependencies fails, the injection fails as if the skippable default were not skippable. Skippable defaults will usually fall back to anull
.There are some limitations so far:
Includes pretty full tests, except for the skip flag appearing in META-INF defaults.
The big advantage of this: we can reduce some cases where we were using providers that return
null
in LensKit. Providers returning null is an anti-pattern IMO.