Fix compilation error on protected inner classes

This PR fixes #1177.