There is a strange compile error happening on the script scenario below. Somewhat related to Static array initializer unable to distinguish overloads, but likely a separate issue.
class StrongTypedArray<Class T> { static array<T> From(notnull array<T> values) { return values; } } class ReproduceItem { static ReproduceItem From(array<int> integers) { } static ReproduceItem From(array<float> floats) { } static ReproduceItem From(array<bool> bools) { } } class ReproduceContainer { static ReproduceContainer From(array<ReproduceItem> items) { } } void ReproduceTheIssue() { ReproduceContainer container = ReproduceContainer.From({ ReproduceItem.From(StrongTypedArray<int>.From({1, 2, 3})), ReproduceItem.From(StrongTypedArray<float>.From({1.1, 2.2, 3.3})), }); }
The code above when trying to compile results in:
SCRIPT (E): @"Scripts/Game/test.c,33": Unsafe down-casting, use 'array<ReproduceItem>.Cast' for safe down-casting
It is worth mentioning that the error "disappears" after a code change to this - removing the return value. it also only happens when this strong array type wrapper is used. In other scenarios, I did not experience any problems with the static initializer in general.
class StrongTypedArray<Class T> { static array<T> From(notnull array<T> values) { //return values; } }
Edit:
Adding a typedef or using the exact StrongTypedArray template variant used in the static initializer seems to make the code work as well e.g.
typedef StrongTypedArray<int> a; typedef StrongTypedArray<float> b; ... StrongTypedArray<int> hello(); StrongTypedArray<float> hello2();
This might indicate that the issue is related to the template not being found and thus it tries to init with invalid type and that is why he thinks he needs to cast?