Can public classes be subclassed in non-defining modules?

Apple's doc says: " classes with public access , or any more restrictive access level, can be subclassed only within the module where they're defined "

However, Apple's doc also says: " Open access and public access enable entities to be used within any source file from their defining module, and also in a source file from another module that imports the defining module. "

These two sentences seem to be contradictory. One is saying that a public class can only be subclassed within its defining module. The other one is implying that a public class can be subclassed within non-defining modules that import the defining module.

So I'm wondering which one is correct? Are these 2 quotes contradictory? How should I interpret these 2 quotes?

Thanks for the answers in advance.

A class that is public instead of open can be used but not subclassed outside of its own module. That’s the whole point of distinguishing public from open.

“Use” here does not include subclassing. It refers to calling the implementations provided for the class’s members rather than (and in contradistinction to) writing your own implementations of them.

3 Likes

Thanks a lot! I get it now