Avoid ambiguous call with BeanInstanceSupplier#withGenerator
Previously, BeanInstanceSupplier had three variants of the `withGenerator` callback, one with a bi function, one with a function, and with a supplier. This could lead to compilation failure when the target type has a method with the same name and a number of arguments that match another variant. It turns out the supplier-based variant is only used a shortcut. This commit deprecates it and update ghe code generation to use the function instead. Closes gh-29278
This commit is contained in:
@@ -186,6 +186,8 @@ class BeanInstanceSupplierTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
@SuppressWarnings("removal")
|
||||
void withGeneratorWhenSupplierIsNullThrowsException() {
|
||||
BeanInstanceSupplier<Object> resolver = BeanInstanceSupplier
|
||||
.forConstructor();
|
||||
@@ -245,6 +247,8 @@ class BeanInstanceSupplierTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
@SuppressWarnings("removal")
|
||||
void getWithGeneratorCallsSupplier() throws Exception {
|
||||
BeanRegistrar registrar = new BeanRegistrar(SingleArgConstructor.class);
|
||||
this.beanFactory.registerSingleton("one", "1");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -223,7 +223,7 @@ class InstanceSupplierCodeGeneratorTests {
|
||||
assertThat(bean).isInstanceOf(Integer.class);
|
||||
assertThat(bean).isEqualTo(42);
|
||||
assertThat(compiled.getSourceFile())
|
||||
.contains("SimpleConfiguration::integerBean");
|
||||
.contains("(registeredBean) -> SimpleConfiguration.integerBean()");
|
||||
});
|
||||
assertThat(getReflectionHints().getTypeHint(SimpleConfiguration.class))
|
||||
.satisfies(hasMethodWithMode(ExecutableMode.INTROSPECT));
|
||||
|
||||
Reference in New Issue
Block a user