@@ -490,7 +490,8 @@ class LifetimeDependenceChecker {
490
490
}
491
491
492
492
bool isCompatibleWithOwnership (ParsedLifetimeDependenceKind kind, Type type,
493
- ValueOwnership ownership) const {
493
+ ValueOwnership ownership,
494
+ bool isInterfaceFile = false ) const {
494
495
if (kind == ParsedLifetimeDependenceKind::Inherit) {
495
496
return true ;
496
497
}
@@ -503,6 +504,10 @@ class LifetimeDependenceChecker {
503
504
? ownership : getLoweredOwnership (afd);
504
505
505
506
if (kind == ParsedLifetimeDependenceKind::Borrow) {
507
+ if (isInterfaceFile) {
508
+ return loweredOwnership == ValueOwnership::Shared ||
509
+ loweredOwnership == ValueOwnership::InOut;
510
+ }
506
511
return loweredOwnership == ValueOwnership::Shared;
507
512
}
508
513
assert (kind == ParsedLifetimeDependenceKind::Inout);
@@ -634,8 +639,8 @@ class LifetimeDependenceChecker {
634
639
case ParsedLifetimeDependenceKind::Inout: {
635
640
// @lifetime(borrow x) is valid only for borrowing parameters.
636
641
// @lifetime(inout x) is valid only for inout parameters.
637
- if (!isCompatibleWithOwnership (parsedLifetimeKind, type,
638
- loweredOwnership )) {
642
+ if (!isCompatibleWithOwnership (parsedLifetimeKind, type, loweredOwnership,
643
+ isInterfaceFile () )) {
639
644
diagnose (loc,
640
645
diag::lifetime_dependence_cannot_use_parsed_borrow_consuming,
641
646
getNameForParsedLifetimeDependenceKind (parsedLifetimeKind),
0 commit comments