DeterminesOutputType metadata flag does not work correctly with interface message functions

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.

Hi FakeEnema,

I created a simple project to try to reproduce this and did not see the error message that you described. Here is what I did:

  1. Created a code interface and added the function declaration you provided.
  2. Provided an implementation of the Blueprint in code.
  3. Added a message node for the function to be called in a Blueprint.
  4. Compiled the Blueprint.

The Blueprint compiled successfully without any errors. Do you have any more details that you could provide about both the interface, function, and the way you are setting up your Blueprint?

Hi FakeEnema,

We have not heard back from you for a while. Do you still need assistance with this? I will be marking this post as resolved for internal tracking purposes, but please feel free to add a comment and re-open the post at any time if you need any more help.