jsweet icon indicating copy to clipboard operation
jsweet copied to clipboard

Method generic type isn't inferred

Open rendaw opened this issue 4 years ago • 0 comments

public class ThingA {
    public static <T> HashSet<T> x() {
        return new HashSet<>();
    }

    public static void y(HashSet<String> arg) {}

    public static void main(String[] args) {
        y(x());
    }
}

I think Java infers types 1 level deep from call parameters. This should produce ThingA.x<String>() but instead I get:

namespace jsweettest.moda {
    export class ThingA {
        public static x<T>() : java.util.HashSet<T> {
            return <any>(new java.util.HashSet<any>());
        }

        public static y(arg : java.util.HashSet<string>) {
        }

        public static main(args : string[]) {
            ThingA.y(ThingA.x<any>());
        }
    }
    ThingA["__class"] = "jsweettest.moda.ThingA";

}

rendaw avatar Feb 06 '21 18:02 rendaw