Test injection point match for narrow target return type
Issue: SPR-14960
This commit is contained in:
parent
1ae17c27df
commit
845dbf040d
|
@ -609,6 +609,12 @@ public class ConfigurationClassPostProcessorTests {
|
||||||
ctx.getBean("aFoo");
|
ctx.getBean("aFoo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInjectionPointMatchForNarrowTargetReturnType() {
|
||||||
|
ApplicationContext ctx = new AnnotationConfigApplicationContext(FooBarConfiguration.class);
|
||||||
|
assertSame(ctx.getBean(BarImpl.class), ctx.getBean(FooImpl.class).bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1115,7 +1121,7 @@ public class ConfigurationClassPostProcessorTests {
|
||||||
@Configuration
|
@Configuration
|
||||||
public static class A {
|
public static class A {
|
||||||
|
|
||||||
@Autowired(required=true)
|
@Autowired(required = true)
|
||||||
Z z;
|
Z z;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -1221,4 +1227,30 @@ public class ConfigurationClassPostProcessorTests {
|
||||||
abstract DependingFoo createFoo(BarArgument bar);
|
abstract DependingFoo createFoo(BarArgument bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface BarInterface {
|
||||||
|
}
|
||||||
|
|
||||||
|
static class BarImpl implements BarInterface {
|
||||||
|
}
|
||||||
|
|
||||||
|
static class FooImpl {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public BarImpl bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
static class FooBarConfiguration {
|
||||||
|
|
||||||
|
@Bean @DependsOn("bar")
|
||||||
|
public FooImpl foo() {
|
||||||
|
return new FooImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BarInterface bar() {
|
||||||
|
return new BarImpl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue