Fix SpEL compilation for non trivial elvis operand
Issue: SPR-17214
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -77,8 +77,10 @@ public class Elvis extends SpelNodeImpl {
|
||||
public void generateCode(MethodVisitor mv, CodeFlow cf) {
|
||||
// exit type descriptor can be null if both components are literal expressions
|
||||
computeExitTypeDescriptor();
|
||||
cf.enterCompilationScope();
|
||||
this.children[0].generateCode(mv, cf);
|
||||
CodeFlow.insertBoxIfNecessary(mv, cf.lastDescriptor().charAt(0));
|
||||
cf.exitCompilationScope();
|
||||
Label elseTarget = new Label();
|
||||
Label endOfIf = new Label();
|
||||
mv.visitInsn(DUP);
|
||||
@@ -91,10 +93,12 @@ public class Elvis extends SpelNodeImpl {
|
||||
mv.visitJumpInsn(IFEQ, endOfIf); // if not empty, drop through to elseTarget
|
||||
mv.visitLabel(elseTarget);
|
||||
mv.visitInsn(POP);
|
||||
cf.enterCompilationScope();
|
||||
this.children[1].generateCode(mv, cf);
|
||||
if (!CodeFlow.isPrimitive(this.exitTypeDescriptor)) {
|
||||
CodeFlow.insertBoxIfNecessary(mv, cf.lastDescriptor().charAt(0));
|
||||
}
|
||||
cf.exitCompilationScope();
|
||||
mv.visitLabel(endOfIf);
|
||||
cf.pushDescriptor(this.exitTypeDescriptor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user