square/dagger — pull request #279 by cgruber (2013-06-13 22:19:40+00:00)
Title: Rework the default loader into a cleaner, more explicit FallbackLoader

Patched from the google fork

Rework the default loader into a cleaner, more explicit FallbackLoader, and turn the previously chained loaders into ingredients that could be used in this or other loaders.

This has a benefit of throwing fewer exceptions (and incurring stack-trace building costs) during normal expected operation (such as our fallback for supertypes).

Additionally, I think this is cleaner, as the chaining was too-clever and I worked too hard to make the raw logic of loading adapters and creating reflective adapters conform to the Loader API. This change leaves the raw logic in utilities that could be used to build other loaders (reflection only, generated-loading-only, etc.) but without trying to shoehorn things into a common API and handle the interaction between these strategies in a common way. This is simply much cleaner as a "do-this, did it work? No, ok do the other thing. Return what we got in the end." pattern.