mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Merge branch '7.0.x'
This commit is contained in:
@@ -103,6 +103,12 @@ public class Elvis extends SpelNodeImpl {
|
||||
|
||||
@Override
|
||||
public void generateCode(MethodVisitor mv, CodeFlow cf) {
|
||||
// If both elements are literals and the expression was not previously
|
||||
// evaluated in interpreted mode, we may get here without the exit descriptor
|
||||
// having been computed, so we must ensure the exit descriptor has been
|
||||
// computed before proceeding.
|
||||
computeExitTypeDescriptor();
|
||||
|
||||
Label elseTarget = new Label();
|
||||
Label endOfIf = new Label();
|
||||
|
||||
|
||||
+17
@@ -1470,6 +1470,23 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertThat(getAst().getExitDescriptor()).isEqualTo("Ljava/lang/String");
|
||||
}
|
||||
|
||||
@Test
|
||||
void elvisWithImmediateCompilation() {
|
||||
expression = parser.parseExpression("'a' ?: 'b'");
|
||||
// Both literals, so we can compile immediately without having previously
|
||||
// evaluated the expression.
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(String.class)).isEqualTo("a");
|
||||
assertThat(getAst().getExitDescriptor()).isEqualTo("Ljava/lang/String");
|
||||
|
||||
expression = parser.parseExpression("null ?: 'a'");
|
||||
// Both literals, so we can compile immediately without having previously
|
||||
// evaluated the expression.
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(String.class)).isEqualTo("a");
|
||||
assertThat(getAst().getExitDescriptor()).isEqualTo("Ljava/lang/Object");
|
||||
}
|
||||
|
||||
@Test // gh-19758
|
||||
void elvisMiscellaneous() {
|
||||
SpelParserConfiguration configuration = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null);
|
||||
|
||||
Reference in New Issue
Block a user