address a nasty protected[pkg] class regression

Shows up in combination with default args.

Review by @paulp for the code, and by @adriaanm for my wildly optimistic target branch.