Skip to content

Commit

Permalink
Keep fallback flag in AOT-generated code
Browse files Browse the repository at this point in the history
Closes gh-33261
  • Loading branch information
snicoll committed Jul 23, 2024
1 parent eda21c4 commit d219362
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ CodeBlock generateCode(RootBeanDefinition beanDefinition) {
CodeBlock.Builder code = CodeBlock.builder();
addStatementForValue(code, beanDefinition, BeanDefinition::isPrimary,
"$L.setPrimary($L)");
addStatementForValue(code, beanDefinition, BeanDefinition::isFallback,
"$L.setFallback($L)");
addStatementForValue(code, beanDefinition, BeanDefinition::getScope,
this::hasScope, "$L.setScope($S)");
addStatementForValue(code, beanDefinition, BeanDefinition::getDependsOn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ void setPrimaryWhenTrue() {
compile((actual, compiled) -> assertThat(actual.isPrimary()).isTrue());
}

@Test
void setFallbackWhenFalse() {
this.beanDefinition.setFallback(false);
compile((actual, compiled) -> {
assertThat(compiled.getSourceFile()).doesNotContain("setFallback");
assertThat(actual.isFallback()).isFalse();
});
}

@Test
void setFallbackWhenTrue() {
this.beanDefinition.setFallback(true);
compile((actual, compiled) -> assertThat(actual.isFallback()).isTrue());
}

@Test
void setScopeWhenEmptyString() {
this.beanDefinition.setScope("");
Expand Down

0 comments on commit d219362

Please sign in to comment.