It seems like this doesn't rise an error or warning (at least not in Swift 5.6), although it makes little sense to have a public func inside a private struct/class/actor.
The stated reason is that you can design a public type, choosing which members are public or not, while keeping the type itself internal or private while work is in progress, then change only one access modifier to make it public.
The pragmatic reason is that there is no way to spell a member with the same visibility as a containing private type, since private-inside-the-type is less than private-for-the-type, so Swift must allow members inside private types to have higher access modifiers.