Skip to content

Commit

Permalink
Make guice build with javac 8.
Browse files Browse the repository at this point in the history
javac 8 is more restrictive about generic type inference in situations
involving raw types, which prevents guice from compiling. This change
allows guice to be compiled with javac 8.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=55855098
  • Loading branch information
cgruber committed Nov 13, 2013
1 parent e1197a9 commit 3382133
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@ public void initialize(InjectorImpl injector, Errors errors) throws ErrorsExcept
providerBinding =
injector.getBindingOrThrow(providerKey, errors, JitLimitation.NEW_OR_EXISTING_JIT);
}

@SuppressWarnings("unchecked")//

public T get(Errors errors, InternalContext context, Dependency dependency, boolean linked)
throws ErrorsException {
checkState(providerBinding != null, "not initialized");

context.pushState(providerKey, providerBinding.getSource());
try {
errors = errors.withSource(providerKey);
Provider provider = providerBinding.getInternalFactory().get(
Provider<? extends T> provider = providerBinding.getInternalFactory().get(
errors, context, dependency, true);
return circularGet(provider, errors, context, dependency, linked, provisionCallback);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public V visit(ConvertedConstantBinding<? extends T> convertedConstantBinding) {
return visitOther(convertedConstantBinding);
}

// javac says it's an error to cast ProviderBinding<? extends T> to Binding<? extends T>
@SuppressWarnings("unchecked")
public V visit(ProviderBinding<? extends T> providerBinding) {
return visitOther((Binding) providerBinding);
// TODO(cushon): remove raw (Binding) cast when we don't care about javac 6 anymore
return visitOther((Binding<? extends T>) (Binding) providerBinding);
}
}

0 comments on commit 3382133

Please sign in to comment.