Skip to content

Commit 6a5d986

Browse files
committed
Fix SpEL compilation for non trivial elvis operand
Issue: SPR-17214
1 parent 8ce9236 commit 6a5d986

File tree

2 files changed

+121
-47
lines changed

2 files changed

+121
-47
lines changed

Diff for: spring-expression/src/main/java/org/springframework/expression/spel/ast/Elvis.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -77,8 +77,10 @@ public boolean isCompilable() {
7777
public void generateCode(MethodVisitor mv, CodeFlow cf) {
7878
// exit type descriptor can be null if both components are literal expressions
7979
computeExitTypeDescriptor();
80+
cf.enterCompilationScope();
8081
this.children[0].generateCode(mv, cf);
8182
CodeFlow.insertBoxIfNecessary(mv, cf.lastDescriptor().charAt(0));
83+
cf.exitCompilationScope();
8284
Label elseTarget = new Label();
8385
Label endOfIf = new Label();
8486
mv.visitInsn(DUP);
@@ -91,10 +93,12 @@ public void generateCode(MethodVisitor mv, CodeFlow cf) {
9193
mv.visitJumpInsn(IFEQ, endOfIf); // if not empty, drop through to elseTarget
9294
mv.visitLabel(elseTarget);
9395
mv.visitInsn(POP);
96+
cf.enterCompilationScope();
9497
this.children[1].generateCode(mv, cf);
9598
if (!CodeFlow.isPrimitive(this.exitTypeDescriptor)) {
9699
CodeFlow.insertBoxIfNecessary(mv, cf.lastDescriptor().charAt(0));
97100
}
101+
cf.exitCompilationScope();
98102
mv.visitLabel(endOfIf);
99103
cf.pushDescriptor(this.exitTypeDescriptor);
100104
}

0 commit comments

Comments
 (0)