@@ -932,16 +932,19 @@ class LifetimeDependenceChecker {
932
932
if (!useLazyInference () && afd->getParameters ()->size () > 0 ) {
933
933
return ;
934
934
}
935
- if (!nonEscapableSelf && isBitwiseCopyable (selfTypeInContext, ctx)) {
936
- diagnose (returnLoc,
937
- diag::lifetime_dependence_cannot_infer_bitwisecopyable,
938
- diagnosticQualifier (), " self" );
939
- return ;
940
- }
941
- if (!useLazyInference ()) {
942
- // Do not infer LifetimeDependenceKind::Inherit unless this is an implicit
943
- // getter, which simply returns a stored property.
944
- if (nonEscapableSelf && !isImplicitOrSIL ()) {
935
+ // Allow inference for implicit getters, which simply return a stored,
936
+ // property, and for implicit _read/_modify, which cannot be defined
937
+ // explicitly alongside a regular getter.
938
+ if (!useLazyInference () && !isImplicitOrSIL ()) {
939
+ // Require explicit @_lifetime(borrow self) for UnsafePointer-like self.
940
+ if (!nonEscapableSelf && isBitwiseCopyable (selfTypeInContext, ctx)) {
941
+ diagnose (returnLoc,
942
+ diag::lifetime_dependence_cannot_infer_bitwisecopyable,
943
+ diagnosticQualifier (), " self" );
944
+ return ;
945
+ }
946
+ // Require explicit @_lifetime(copy or borrow) for non-Escapable self.
947
+ if (nonEscapableSelf) {
945
948
diagnose (returnLoc, diag::lifetime_dependence_cannot_infer_kind,
946
949
diagnosticQualifier (), " self" );
947
950
return ;
0 commit comments