[REQUEST/BUG] Refine C++ (Inherited) Interface System

Thus far, I’ve been able to determine that if you have a C++ interface inheriting from another C++ interface, Unreal C++ will behave inconsistently. Assuming you have a (BlueprintNativeEvent, BlueprintCallable) UFUNCTION present in both the child and parent interfaces and an actor that implements the child interface and both functions, I have ascertained the following:

  • Unreal compiles if you supply the actor to the IChildIntf::Execute_ChildFunc(UObject*) method (yay!)
  • Unreal DOESN’T FAIL to compile if you neglect to implement the interface-mandated function (wat? How is it an interface then? I thought it was mandatory to implement it…)
  • Unreal will fail to compile if you supply the actor to the IParentIntf::Execute_ParentFunc(UObject*) method (oh, so inheritance isn’t supported…)
  • Unreal will compile and return true if you test whether the actor implements the parent interface (ok, now I’m confused…IS it supported?)
  • Unreal will fail to compile if you take a child TScriptInterface, get the object reference (GetObjectW), cast it back to the actor type, and attempt to store it in a parent TScriptInterface, indicating that it doesn’t believe the actor implements the parent interface (Wait, that’s directly contradicting the fact that ImplementsInterface returns true!).

As a bizarre side note, Unreal will compile and run smoothly if two different interfaces supply the exact same function name/signature, an actor implementing both supplies a single function implementation with the same name/signature, and the actor is supplied to the two different interface’s Execute_FuncName methods (I get that it works through a messaging system, but this capacity is dangerous, technically speaking).

The only way I could see inherited interfaces actually “working” would be to have an ActorParent implementing the parent interface and an ActorChild implementing the child interface, and then casting to the appropriate actor type (up or down) when assigning to the corresponding parent or child TScriptInterface, but that would be absolutely horrid coding practice.

I would appreciate it if someone from Epic could be clear about…

  1. why interface methods aren’t mandatory?

  2. what is with these inheritance discrepancies?

  3. are inherited interfaces even meant to be a feature at all down the line, and if so, when will they show up on the roadmap?