Various style cleanups to BoundFieldModule & test.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=68018366
diff --git a/extensions/testlib/src/com/google/inject/testing/fieldbinder/BoundFieldModule.java b/extensions/testlib/src/com/google/inject/testing/fieldbinder/BoundFieldModule.java
index acb0537..5d98b0a 100644
--- a/extensions/testlib/src/com/google/inject/testing/fieldbinder/BoundFieldModule.java
+++ b/extensions/testlib/src/com/google/inject/testing/fieldbinder/BoundFieldModule.java
@@ -243,10 +243,11 @@
field,
"Fields annotated with both @Bind and @Inject are illegal.");
}
- return Optional.of(new BoundFieldInfo(
- field,
- bindAnnotation,
- containingClassType.getFieldType(field)));
+ return Optional.of(
+ new BoundFieldInfo(
+ field,
+ bindAnnotation,
+ containingClassType.getFieldType(field)));
}
private LinkedBindingBuilder<?> verifyBindingAnnotations(
@@ -356,8 +357,8 @@
// addErrorAndThrow already called addError, so do nothing
}
}
- currentClassType = currentClassType.getSupertype(
- currentClassType.getRawType().getSuperclass());
+ currentClassType =
+ currentClassType.getSupertype(currentClassType.getRawType().getSuperclass());
}
}
}
diff --git a/extensions/testlib/test/com/google/inject/testing/fieldbinder/BoundFieldModuleTest.java b/extensions/testlib/test/com/google/inject/testing/fieldbinder/BoundFieldModuleTest.java
index 8e89ee4..768bf3e 100644
--- a/extensions/testlib/test/com/google/inject/testing/fieldbinder/BoundFieldModuleTest.java
+++ b/extensions/testlib/test/com/google/inject/testing/fieldbinder/BoundFieldModuleTest.java
@@ -123,6 +123,24 @@
assertEquals(testValue, injector.getInstance(Number.class));
}
+ public void testBindingSuperTypeAccessSubType() {
+ final Integer testValue = 1024;
+ Object instance = new Object() {
+ @Bind(to = Number.class) private Integer anInt = testValue;
+ };
+
+ BoundFieldModule module = BoundFieldModule.of(instance);
+ Injector injector = Guice.createInjector(module);
+
+ try {
+ injector.getInstance(Integer.class);
+ } catch (ConfigurationException e) {
+ assertContains(
+ e.getMessage(),
+ "Could not find a suitable constructor in java.lang.Integer");
+ }
+ }
+
public void testBindingIncorrectTypeProviderFails() {
final Integer testValue = 1024;
Object instance = new Object() {
@@ -627,7 +645,7 @@
};
BoundFieldModule module = BoundFieldModule.of(instance);
- Injector injector = Guice.createInjector(module);
+ Guice.createInjector(module);
assertEquals(testValue, testNumberProvider.anInt);
}