Should not be public because its superclass is internal

Yes, I am confident this is a valid reason to show not only a warning, but an error. Since you won't be able to access foo anywhere outside your module anyway.

A<Foo> may be internal, but if it has a member that doesn't depend on Foo, they will and should be visible in public subclasses of A<Foo> (If they are public as well of course). It is sensible to hide hierarchies, i.e. when you have subclasses built upon a class and its functionality, which you want to keep internal together with the base class. Otherwise, you would have to copy-paste... and protocols won't help with that either.

@John_McCall agrees on this in an old related topic Public classes with private superclass - #7 by Tino

But, yes, you can rephrase this as "enhanced diagnostics". I just don't want the warning to show unless it really bears important information of potential danger, i.e. possible unsafe code.

1 Like