This is being caused by the plugin's type. The plugin used to reproduce this is currently a Developer plugin, which means it can also run at runtime. If the plugin is changed to be an Editor plugin, it will be able to compile.
Error when using "For Each Selected Actor" in a blutility that was derived from Global Editor Utility Base in C++
Error Message: "LogBlueprint: Error: Cannot use the editor function "ForEachSelectedActor" in this runtime Blueprint. Only for use in Editor Utility Blueprints and Blutilities."
Result: The editor throws an error stating the the current blueprint is a runtime blueprint (see full error in the description)
Expected: The blutility would compile without error
There's no existing public thread on this issue, so head over toAnswerHub just mention UE-73159 in the post.