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

Type parameter names or wildcards are used as local variable type #55

Closed
Marcono1234 opened this issue Nov 28, 2019 · 0 comments
Closed

Comments

@Marcono1234
Copy link
Contributor

CFR version

0.149-SNAPSHOT (commit 06539a4)

Description

When decompiling methods which store the result of a generic method in a local variable and there is no further usage of this result, CFR emits the type parameter name or a wildcard, which is invalid code:

public static void main(String[] args) {
    ? o = GenericType.getWildcardInstance().doSomething();
    T o2 = GenericType.getInstance().doSomething();
    GenericType<T> o3 = GenericType.getInstance();
}

Also sorry for this flood of issues, I started poking at CFR a little bit. Let me know if they are too many or if you are not interested in these issues.

Example code

public interface GenericType<T> {
    T doSomething();
    
    static GenericType<?> getWildcardInstance() {
        return null;
    }
    
    static <T> GenericType<T> getInstance() {
        return null;
    }
    
    public static void main(String[] args) {
        Object o = getWildcardInstance().doSomething();
        Object o2 = getInstance().doSomething();
        Object o3 = getInstance();
    }
}
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