TrigerSoft/jaque

Parsing of a lambda expression promoting char to int fails in one of two ways

tomwhoiscontrary opened this issue · 1 comments

Testing commit 3c1c4ec, built locally. asm version 5.0.3.

This test:

    @Test
    public void canParseAnExpressionWhereCharIsPromotedToIntAsAMethodParameter() throws Exception {
        SerializableFunction<String, Integer> e = s -> Math.abs(s.charAt(0));
        LambdaExpression.parse(e);
    }

Fails like this:

java.lang.ClassCastException: Cannot cast com.trigersoft.jaque.expression.MemberExpression to int
    at java.lang.Class.cast(Class.java:3258)
    at com.trigersoft.jaque.expression.TypeConverter.defaultConvert(TypeConverter.java:65)
    at com.trigersoft.jaque.expression.TypeConverter.defaultConvert(TypeConverter.java:61)
    at com.trigersoft.jaque.expression.TypeConverter.visit(TypeConverter.java:107)
    at com.trigersoft.jaque.expression.TypeConverter.visit(TypeConverter.java:24)
    at com.trigersoft.jaque.expression.MemberExpression.visit(MemberExpression.java:70)
    at com.trigersoft.jaque.expression.Expression.accept(Expression.java:1443)
    at com.trigersoft.jaque.expression.TypeConverter.visit(TypeConverter.java:85)
    at com.trigersoft.jaque.expression.TypeConverter.visit(TypeConverter.java:24)
    at com.trigersoft.jaque.expression.InvocationExpression.visit(InvocationExpression.java:50)
    at com.trigersoft.jaque.expression.Expression.accept(Expression.java:1443)
    at com.trigersoft.jaque.expression.TypeConverter.convert(TypeConverter.java:36)
    at com.trigersoft.jaque.expression.ExpressionMethodVisitor.visitMethodInsn(ExpressionMethodVisitor.java:730)
    at org.objectweb.asm.ClassReader.a(Unknown Source)
    at org.objectweb.asm.ClassReader.b(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at com.trigersoft.jaque.expression.ExpressionClassCracker.parseClass(ExpressionClassCracker.java:177)
    at com.trigersoft.jaque.expression.ExpressionClassCracker.lambda(ExpressionClassCracker.java:81)
    at com.trigersoft.jaque.expression.LambdaExpression.parse(LambdaExpression.java:91)

And this one:

    @Test
    public void canParseAnExpressionWhereCharIsPromotedToIntAsAnOperand() throws Exception {
        SerializableFunction<String, Integer> e = s -> s.charAt(0) + 1;
        LambdaExpression.parse(e);
    }

Fails like this:

java.lang.IllegalArgumentException: char
    at com.trigersoft.jaque.expression.Expression.createNumeric(Expression.java:337)
    at com.trigersoft.jaque.expression.Expression.add(Expression.java:185)
    at com.trigersoft.jaque.expression.ExpressionMethodVisitor.visitInsn(ExpressionMethodVisitor.java:297)
    at org.objectweb.asm.ClassReader.a(Unknown Source)
    at org.objectweb.asm.ClassReader.b(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at com.trigersoft.jaque.expression.ExpressionClassCracker.parseClass(ExpressionClassCracker.java:177)
    at com.trigersoft.jaque.expression.ExpressionClassCracker.lambda(ExpressionClassCracker.java:81)
    at com.trigersoft.jaque.expression.LambdaExpression.parse(LambdaExpression.java:91)