Skip to content

javac: binary operator adds erroneous cast on 1st operand. #10

Closed
@amelentev

Description

@amelentev

For example when multiplying Vector to Matrix:

class VecMat {
    static class Vec {
        Vec multiply(Mat A) { return this; }
    }
    static class Mat {}
    public static void main(String[] s) {
        Vec a = new Vec();
        Mat A = new Mat();
        System.out.println(a*A);
    }
}

a*A transforms to ((Mat)a).multiply(A)
which causes ClassCastException at runtime.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions