cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 160 forks source link

Method generic type isn't inferred #672

Open rendaw opened 3 years ago

rendaw commented 3 years ago
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";

}