Blueprint Nativization & TArray of TSubClassOf error

Description

When a BlueprintCallable function returns a TArray of TSubclassOf(MyType), the nativization tries to manage it as a TArray of UClass*, thus failing to assign it to a variable.

How to reproduce

  • create a new c++ blank project
  • create a new c++ class (i used a StaticMeshActor as parent, but it’s the same)
  • create a new function in the newly reated class as this one:

.h file

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Engine/StaticMeshActor.h"
#include "MyStaticMeshActor.generated.h"

/**
 * 
 */
UCLASS()
class NATIVETESTING_API AMyStaticMeshActor : public AStaticMeshActor
{
	GENERATED_BODY()

	UFUNCTION(BlueprintCallable, Category = "Test")
	TArray<TSubclassOf<AMyStaticMeshActor>> Test();
};

.cpp file

// Fill out your copyright notice in the Description page of Project Settings.

#include "NativeTesting.h"
#include "MyStaticMeshActor.h"

TArray<TSubclassOf<AMyStaticMeshActor>> AMyStaticMeshActor::Test()
{
	return TArray<TSubclassOf<AMyStaticMeshActor>>();
}
  • now create a blueprint with the c++ class as parent, and create these nodes (note the variable type)

  • set nativization as inclusive, and package the project, it will fail.

Explanation

It generates this code

in .h the variable is declared as

TArray<UClass*> bpv__NewVar_0__pf;

Note that the type is wrong.

in the .cpp it tries to assign it with:

b0l__CallFunc_Test_ReturnValue__pf = AMyStaticMeshActor::Test();

that obviously fails.

Expected behaviour

The generated code should remain true to the variable / return type, so use a TArray of TSbuclassOf instead of TArray of UClass*

Hope this helps :slight_smile:

Simone Daminato

Hey

Thank you for the report - I have reproduced this issue and have entered a report for it here: Unreal Engine Issues and Bug Tracker (UE-44511) .

Cheers