@@ -490,7 +490,8 @@ class LifetimeDependenceChecker {
490490 }
491491
492492 bool isCompatibleWithOwnership (ParsedLifetimeDependenceKind kind, Type type,
493- ValueOwnership ownership) const {
493+ ValueOwnership ownership,
494+ bool isInterfaceFile = false ) const {
494495 if (kind == ParsedLifetimeDependenceKind::Inherit) {
495496 return true ;
496497 }
@@ -503,6 +504,10 @@ class LifetimeDependenceChecker {
503504 ? ownership : getLoweredOwnership (afd);
504505
505506 if (kind == ParsedLifetimeDependenceKind::Borrow) {
507+ if (isInterfaceFile) {
508+ return loweredOwnership == ValueOwnership::Shared ||
509+ loweredOwnership == ValueOwnership::InOut;
510+ }
506511 return loweredOwnership == ValueOwnership::Shared;
507512 }
508513 assert (kind == ParsedLifetimeDependenceKind::Inout);
@@ -634,8 +639,8 @@ class LifetimeDependenceChecker {
634639 case ParsedLifetimeDependenceKind::Inout: {
635640 // @lifetime(borrow x) is valid only for borrowing parameters.
636641 // @lifetime(inout x) is valid only for inout parameters.
637- if (!isCompatibleWithOwnership (parsedLifetimeKind, type,
638- loweredOwnership )) {
642+ if (!isCompatibleWithOwnership (parsedLifetimeKind, type, loweredOwnership,
643+ isInterfaceFile () )) {
639644 diagnose (loc,
640645 diag::lifetime_dependence_cannot_use_parsed_borrow_consuming,
641646 getNameForParsedLifetimeDependenceKind (parsedLifetimeKind),
0 commit comments