I know its kind of late and maybe there is more to it but I noticed that UnrealBuildTool recursively creates modules in this order: PublicDependencyModuleNames, PrivateDependencyModuleNames, and then DynamicallyLoadedModuleNames.
Therefore, if your Build.cs file has “UMG” in PublicDependencyModuleNames, but “Engine” is in PrivateDependencyModuleNames the build should fail, as UMG module is dependent on Engine module.