Skip to content

Commit 5d9cde1

Browse files
Talk about 'protected' in type compatibility page.
1 parent 55d4f85 commit 5d9cde1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pages/Type Compatibility.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,12 @@ a = s; //OK
197197
s = a; //OK
198198
```
199199

200-
## Private members in classes
200+
## Private and protected members in classes
201201

202-
Private members in a class affect their compatibility.
203-
When an instance of a class is checked for compatibility, if it contains a private member, the target type must also contain a private member that originated from the same class.
204-
This allows, for example, a class to be assignment compatible with its super class but not with classes from a different inheritance hierarchy which otherwise have the same shape.
202+
Private and protected members in a class affect their compatibility.
203+
When an instance of a class is checked for compatibility, if the instance contains a private member, then the target type must also contain a private member that originated from the same class.
204+
Likewise, the same applies for an instance with a protected member.
205+
This allows a class to be assignment compatible with its super class, but *not* with classes from a different inheritance hierarchy which otherwise have the same shape.
205206

206207
# Generics
207208

0 commit comments

Comments
 (0)