Skip to content

Commit

Permalink
Fix SpEL compilation for non trivial elvis operand
Browse files Browse the repository at this point in the history
Issue: SPR-17214
  • Loading branch information
jhoeller committed Sep 7, 2018
1 parent 8ce9236 commit 6a5d986
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -77,8 +77,10 @@ public boolean isCompilable() {
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);
Expand All @@ -91,10 +93,12 @@ public void generateCode(MethodVisitor mv, CodeFlow cf) {
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);
}
Expand Down
Loading

0 comments on commit 6a5d986

Please sign in to comment.