Skip to content

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

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.

Activity

  1. amelentev commented on Jan 3, 2014

    @amelentev
    OwnerAuthor

    The cast added on TransTypes stage because javac plugin adds a custom method-operator which confused the compiler.
    Fixed by moving desugar to TransTypes stage.

  2. added a commit that references this issue on Jan 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions