@@ -495,7 +495,8 @@ class LifetimeDependenceChecker {
495495 }
496496
497497 bool isCompatibleWithOwnership (ParsedLifetimeDependenceKind kind, Type type,
498- ValueOwnership ownership) const {
498+ ValueOwnership ownership,
499+ bool isInterfaceFile = false ) const {
499500 if (kind == ParsedLifetimeDependenceKind::Inherit) {
500501 return true ;
501502 }
@@ -508,6 +509,10 @@ class LifetimeDependenceChecker {
508509 ? ownership : getLoweredOwnership (afd);
509510
510511 if (kind == ParsedLifetimeDependenceKind::Borrow) {
512+ if (isInterfaceFile) {
513+ return loweredOwnership == ValueOwnership::Shared ||
514+ loweredOwnership == ValueOwnership::InOut;
515+ }
511516 return loweredOwnership == ValueOwnership::Shared;
512517 }
513518 assert (kind == ParsedLifetimeDependenceKind::Inout);
@@ -639,8 +644,8 @@ class LifetimeDependenceChecker {
639644 case ParsedLifetimeDependenceKind::Inout: {
640645 // @lifetime(borrow x) is valid only for borrowing parameters.
641646 // @lifetime(inout x) is valid only for inout parameters.
642- if (!isCompatibleWithOwnership (parsedLifetimeKind, type,
643- loweredOwnership )) {
647+ if (!isCompatibleWithOwnership (parsedLifetimeKind, type, loweredOwnership,
648+ isInterfaceFile () )) {
644649 diagnose (loc,
645650 diag::lifetime_dependence_cannot_use_parsed_borrow_consuming,
646651 getNameForParsedLifetimeDependenceKind (parsedLifetimeKind),
0 commit comments