DECLARE_FUNCTION and Interface Casting issues in 4.18 / 4.19

Hey there. We switched to 4.19 yesterday and nothing works anymore, as expected :stuck_out_tongue:

We use a lot of DECLARE_FUNCTION and CustomThunk in our project for custom UProperty serialization, however DECLARE_FUNCTION now operates statically and instead seems to pass an context UObject instead.
I though it would be as easy as simply casting the UObject to the appropriate class but the cast crashes. The DECLARE_FUNCTION is within an IInterface class, which the Context object in fact inherits from, but both Cast<> and even ImplementsInterface both crash. They don’t return false, they crash…

So yeah,
DECLARE_FUNCTION in an IInterface… Anyone any experience with this?

I am doing some research at the moment what is causing it, and something really weird is emerging. I can inspect the Context value and it contains all the data expected and inherits the Interface class, however when casting, the GetClass() on that UObject returns some suuuuuper unrelated Animation-Object class?! What the heck is going on there? Context->GetClass() returns “(Name=0x0000013c776e1040 “/Game/Audience/People/Lily/Animations/Reactions/Negative/HeadShake/Lily_Reactions_Negative_HeadShake_H_01”_2)”, that’s some random animation from our app. The UObject itself is of USEUser, the primary user class… I doubt I could thing of two things less related in our app. Really weird.

When inspecting the Context UObject in Visual Studio before the cast, it has two UObjectBaseUtility implementations, one on the top level, that refers to that weird animation class (and also has a lot of “Invalid” params in it?!) and one that roots back the usual way, UYourClass (USEUser in my case) → UObject → UObjectBaseUtility, where PrivateClass is actually the proper class…

Thanks a lot!

Got a workaround by simply doing an C-style cast instead… Would still like to know why this is happening though. The same code works fine for DECLARE_FUNCTION and Cast<> in non-interface implementations.