diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2015-01-19 22:17:33 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2015-01-19 22:44:12 -0500 |
commit | fdbdc63cc56fd2e8d8e45180261be21696f89a8d (patch) | |
tree | 9b305b5838659e0c5686150e67b747dc2fe69ab9 /core/src/com/google/inject | |
parent | a59c18dba735563ebaf1792c4e787552e72374f1 (diff) | |
download | guice-fdbdc63cc56fd2e8d8e45180261be21696f89a8d.tar.gz |
Fix linked binding behavior with requireExplicitBindings() in the parent.
The old behavior was to try to create the binding in the parent,
swallow the error, and create it in the child. This restores that
behavior, as bindings created in the current injector shouldn't be
prohibited.
Diffstat (limited to 'core/src/com/google/inject')
-rw-r--r-- | core/src/com/google/inject/internal/InjectorImpl.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/core/src/com/google/inject/internal/InjectorImpl.java b/core/src/com/google/inject/internal/InjectorImpl.java index be1c4c8b..eef7d98e 100644 --- a/core/src/com/google/inject/internal/InjectorImpl.java +++ b/core/src/com/google/inject/internal/InjectorImpl.java @@ -779,14 +779,16 @@ final class InjectorImpl implements Injector, Lookups { boolean jitDisabled, JitLimitation jitType) throws ErrorsException { // ask the parent to create the JIT binding if (parent != null) { - if (jitDisabled && jitType == JitLimitation.NEW_OR_EXISTING_JIT) { + if (jitType == JitLimitation.NEW_OR_EXISTING_JIT + && jitDisabled && !parent.options.jitDisabled) { + // If the binding would be forbidden here but allowed in a parent, report an error instead throw errors.jitDisabledInParent(key).toException(); - } else { - try { - return parent.createJustInTimeBindingRecursive(key, new Errors(), jitDisabled, - parent.options.jitDisabled ? JitLimitation.NO_JIT : jitType); - } catch (ErrorsException ignored) { - } + } + + try { + return parent.createJustInTimeBindingRecursive(key, new Errors(), jitDisabled, + parent.options.jitDisabled ? JitLimitation.NO_JIT : jitType); + } catch (ErrorsException ignored) { } } |