[SR-8538] runtime: isKnownUniquelyReferenced should return false if there's any weak/unowned refs (or offer new function with those semantics) #51057
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Additional Detail from JIRA
md5: b5391a3e7ca4c1d0a2da45e0374809ca
duplicates:
Issue Description:
At the moment,
isKnownUniquelyReferenced
returnstrue
if there's exactly one strong reference, no matter how many weak/unowneds there are.In most cases this is not a huge issue because it's mostly used to check if a value type need's to CoW it's storage class. The class is normally not publicly accessible so there's no way random bits of code could create a
weak
/unowned
reference. On the flip-side however that's a great argument to make it only returnstrue
if there's one strong and no weak/unowned refs whatsoever as it won't change any correct code.Long story short: We should change
isKnownUniquelyReferenced
to returntrue
only iff there's one strong and no weak/unowned references.EDIT: After reading SR-5633, it turns out that the existing behaviour might be useful so maybe we should have a new runtime call which has the semantics I describe here.
The text was updated successfully, but these errors were encountered: