Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast is not added when calling overloading method with generic parameter #82

Open
Marcono1234 opened this issue Jan 16, 2020 · 0 comments

Comments

@Marcono1234
Copy link
Contributor

CFR version

0.149-SNAPSHOT (commit 22b3529)

Compiler

javac 11.0.5

Description

It appears a cast is not added when an overloading method with generic parameter is called, resulting in the wrong method being called.

Source:

class GenericParameterMethod {
    static void use(Integer i) {
        System.out.println("use(Integer)");
    }
    static <T> void use(T t) {
        System.out.println("use(T)");
    }
    
    public static void main(String... args) {
        use(1);
        use((Object) 1); // Calls use(T)
    }
}

Decompiled output:

class GenericParameterMethod {
    GenericParameterMethod() {
    }

    static void use(Integer n) {
        System.out.println("use(Integer)");
    }

    static <T> void use(T t) {
        System.out.println("use(T)");
    }

    public static void main(String ... arrstring) {
        GenericParameterMethod.use(1);
        GenericParameterMethod.use(1);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant