Public sealed class with protected constructor exposes internal type

Hi all,

I have a public sealed class with a protected constructor that takes an internal class as a parameter, and IntelliJ doesn’t like it. Is this a bug?

internal class Foo

public sealed class Bar protected constructor(foo: Foo) <-- error

Unless I’m misunderstanding something about sealed classes and internal classes, I think this should be fine. The class is public, but it is sealed, so it cannot be extended outside of my module. The primary constructor is protected, so it can only be called by subtypes of this class, and since the class is sealed, the only subtypes would have to be within my module. Ergo, this primary constructor can only be called from within my module, therefore using internal classes as parameters to this primary constructor should be fine, right?

Am I missing something, or is this a bug?

This may be a moot point now as I didn’t realise that sealed classes are abstract and therefore you can’t directly instantiate one; the constructor will only ever be called by subclasses. If I remove the protected constructor keywords, the error goes away. However, I still don’t think the error should occur.