Fix bytecode generation for SpEL OpPlus
Without this change the plus operator would fail to include a CHECKCAST in generated bytecode when it was compiled in cases where one of the operands has a runtime type of String but a statically declared type that was not String (i.e. Object). Issue: SPR-12426
This commit is contained in:
@@ -1683,12 +1683,41 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
expression = parse("'hello' + 3 + ' spring'");
|
||||
assertEquals("hello3 spring",expression.getValue(new Greeter()));
|
||||
assertCantCompile(expression);
|
||||
|
||||
expression = parse("object + 'a'");
|
||||
assertEquals("objecta",expression.getValue(new Greeter()));
|
||||
assertCanCompile(expression);
|
||||
assertEquals("objecta",expression.getValue(new Greeter()));
|
||||
|
||||
expression = parse("'a'+object");
|
||||
assertEquals("aobject",expression.getValue(new Greeter()));
|
||||
assertCanCompile(expression);
|
||||
assertEquals("aobject",expression.getValue(new Greeter()));
|
||||
|
||||
expression = parse("'a'+object+'a'");
|
||||
assertEquals("aobjecta",expression.getValue(new Greeter()));
|
||||
assertCanCompile(expression);
|
||||
assertEquals("aobjecta",expression.getValue(new Greeter()));
|
||||
|
||||
expression = parse("object+'a'+object");
|
||||
assertEquals("objectaobject",expression.getValue(new Greeter()));
|
||||
assertCanCompile(expression);
|
||||
assertEquals("objectaobject",expression.getValue(new Greeter()));
|
||||
|
||||
expression = parse("object+object");
|
||||
assertEquals("objectobject",expression.getValue(new Greeter()));
|
||||
assertCanCompile(expression);
|
||||
assertEquals("objectobject",expression.getValue(new Greeter()));
|
||||
}
|
||||
|
||||
public static class Greeter {
|
||||
public String getWorld() {
|
||||
return "world";
|
||||
}
|
||||
|
||||
public Object getObject() {
|
||||
return "object";
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user