@@ -932,16 +932,19 @@ class LifetimeDependenceChecker {
932932 if (!useLazyInference () && afd->getParameters ()->size () > 0 ) {
933933 return ;
934934 }
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) {
945948 diagnose (returnLoc, diag::lifetime_dependence_cannot_infer_kind,
946949 diagnosticQualifier (), " self" );
947950 return ;
0 commit comments