Skip to content

Commit 06ed818

Browse files
committed
Fix SpEL compilation for non trivial elvis operand
Issue: SPR-17214
1 parent ad54472 commit 06ed818

File tree

2 files changed

+117
-44
lines changed

2 files changed

+117
-44
lines changed

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

Lines changed: 5 additions & 1 deletion
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.
@@ -79,10 +79,12 @@ public boolean isCompilable() {
7979
public void generateCode(MethodVisitor mv, CodeFlow cf) {
8080
// exit type descriptor can be null if both components are literal expressions
8181
computeExitTypeDescriptor();
82+
cf.enterCompilationScope();
8283
this.children[0].generateCode(mv, cf);
8384
String lastDesc = cf.lastDescriptor();
8485
Assert.state(lastDesc != null, "No last descriptor");
8586
CodeFlow.insertBoxIfNecessary(mv, lastDesc.charAt(0));
87+
cf.exitCompilationScope();
8688
Label elseTarget = new Label();
8789
Label endOfIf = new Label();
8890
mv.visitInsn(DUP);
@@ -95,12 +97,14 @@ public void generateCode(MethodVisitor mv, CodeFlow cf) {
9597
mv.visitJumpInsn(IFEQ, endOfIf); // if not empty, drop through to elseTarget
9698
mv.visitLabel(elseTarget);
9799
mv.visitInsn(POP);
100+
cf.enterCompilationScope();
98101
this.children[1].generateCode(mv, cf);
99102
if (!CodeFlow.isPrimitive(this.exitTypeDescriptor)) {
100103
lastDesc = cf.lastDescriptor();
101104
Assert.state(lastDesc != null, "No last descriptor");
102105
CodeFlow.insertBoxIfNecessary(mv, lastDesc.charAt(0));
103106
}
107+
cf.exitCompilationScope();
104108
mv.visitLabel(endOfIf);
105109
cf.pushDescriptor(this.exitTypeDescriptor);
106110
}

0 commit comments

Comments
 (0)