So I have a function with a pseudo-templated return type, via the “DeterminesOutputType” meta flag, i.e.:
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, meta = (DeterminesOutputType = "SpecializedClass"))
BaseClass* DoSomethingAndGetSpecializedInstance(TSubclassOf<BaseClass> SpecializedClass);
which, if called in Blueprints, will automatically convert the return type to the type specified in “SpecializedClass”, which is neat, and finally brings a little of that C++ template magic to Blueprints.
However, if this function is declared in an interface, and then called in Blueprints via an interface message, then if you try to use the templated return type as is it will give you the compile error:
“COMPILER ERROR: failed building connection with ‘Base Class Reference is not compatible with My Derived Class Reference.’ at Do Something And Get Specialized Instance
Using Interface MyInterface”
If you hover over the Return Value pin of the interface function call it will say that the return type is the expected specialized type and it will let you use that output as the specialized type when making connections and new nodes; however the compiler will disagree.
This is a bit of a problem as we’ve recently been making a big push to use interfaces in Blueprints more to reduce dependencies and load times, but now we’re running into all sorts of limitations with Blueprint interfaces that makes them more trouble than they’re worth.