Why can't I upcast UBoxComponent to UPrimitiveComponent?

Hi guys. I try to find out which component overlaps, when the callback is fired. For this I try to compare two components. I want to know, if the overlapping component is the UBoxComponent I am looking for. UBoxComponent inherits from UPrimitiveComponent. But although Visual Studio shows no errors, Unreal Compiler says I can not do this:

void AThirdPersonCharacter::OnTriggerComponentOverlapBegin
	UPrimitiveComponent* OverlappedComp, 
	AActor* OtherActor, 
	UPrimitiveComponent* OtherComp, 
	int32 OtherBodyIndex, 
	bool bFromSweep, 
	const FHitResult& SweepResult
	// Prevent self collision
	if (!OtherActor || (OtherActor == this)) { return; }

		UBoxComponent* Ledge = Trigger->BrachiationLedge;

		if (OverlappedComp == Cast<UPrimitiveComponent>(Ledge))

Shouldn’t it be possible to upcast to the base class?


Nevermind. That unholy IWYU got me. #include “Components/BoxComponent.h” and casting works fine. -_-