vineflower
vineflower copied to clipboard
no instance(s) of type variable(s) A exist so that Object conforms to A[]
Version: Quiltflower 1.10.0 (commit d43976c4523bf67344ee61366e997ac43f1927ef)
Original code:
import java.lang.reflect.Array;
import java.util.stream.IntStream;
public class Example {
private static <T> T[] myMethod(Object[] myObjects, Class<T> clazz) {
return IntStream.range(0, myObjects.length).mapToObj(i -> myObjects[i]).toArray(size -> (T[])Array.newInstance(clazz, size));
}
}
Quiltflower output:
import java.lang.reflect.Array;
import java.util.stream.IntStream;
public class Example {
private static <T> T[] myMethod(Object[] myObjects, Class<T> clazz) {
return (T[])IntStream.range(0, myObjects.length).mapToObj(i -> myObjects[i]).toArray(size -> Array.newInstance(clazz, size));
}
}
The output results in this error:
no instance(s) of type variable(s) A exist so that Object conforms to A[]