Should not be public because its superclass is internal

This is correct behavior. Something being public means both that it's okay to share all details of its declaration (if not necessarily its implementation) with clients, and that at the implementation level, all symbols are available. I believe public class B: A<Foo> just barely satisfies the latter today (and wouldn't if Allow Member Lookup to Find Generic Parameters goes through), and doesn't…really…qualify for the first. You'd end up with weird cases like this:

import Lib
let b = B()
let a2: A<Foo> = b // error, can't reference 'Foo'
let a: A = b // okay, generic parameter inferred

As for the compiler allowing it only if the original class doesn't expose any public members that use the type, what happens if A is in a different library, and that library adds a new public member in its next update? That definitely shouldn't be a breaking change.

I'll tweak the JIRA report to say the message should specifically talk about a generic parameter, rather than just "its superclass".

4 Likes