If you want to make sure that functions and classes are only matched in the global namespace, you have to put a dot in front of the name. For example, .complex_function_3 will only match the function that outputs hello global.
In the protect.yaml protection definition this looks as follows:
Protection:
- Type: function
Name: .complex_function_3
LicenseListId: 1000
Thus, unlike the previous example, the function complex_function_3 is no longer matched in class A.