@@ -495,7 +495,8 @@ class LifetimeDependenceChecker {
495
495
}
496
496
497
497
bool isCompatibleWithOwnership (ParsedLifetimeDependenceKind kind, Type type,
498
- ValueOwnership ownership) const {
498
+ ValueOwnership ownership,
499
+ bool isInterfaceFile = false ) const {
499
500
if (kind == ParsedLifetimeDependenceKind::Inherit) {
500
501
return true ;
501
502
}
@@ -508,6 +509,10 @@ class LifetimeDependenceChecker {
508
509
? ownership : getLoweredOwnership (afd);
509
510
510
511
if (kind == ParsedLifetimeDependenceKind::Borrow) {
512
+ if (isInterfaceFile) {
513
+ return loweredOwnership == ValueOwnership::Shared ||
514
+ loweredOwnership == ValueOwnership::InOut;
515
+ }
511
516
return loweredOwnership == ValueOwnership::Shared;
512
517
}
513
518
assert (kind == ParsedLifetimeDependenceKind::Inout);
@@ -639,8 +644,8 @@ class LifetimeDependenceChecker {
639
644
case ParsedLifetimeDependenceKind::Inout: {
640
645
// @lifetime(borrow x) is valid only for borrowing parameters.
641
646
// @lifetime(inout x) is valid only for inout parameters.
642
- if (!isCompatibleWithOwnership (parsedLifetimeKind, type,
643
- loweredOwnership )) {
647
+ if (!isCompatibleWithOwnership (parsedLifetimeKind, type, loweredOwnership,
648
+ isInterfaceFile () )) {
644
649
diagnose (loc,
645
650
diag::lifetime_dependence_cannot_use_parsed_borrow_consuming,
646
651
getNameForParsedLifetimeDependenceKind (parsedLifetimeKind),
0 commit comments