@@ -609,26 +609,29 @@ class LifetimeDependenceChecker {
609609 ? ownership
610610 : getLoweredOwnership (afd);
611611
612- if (parsedLifetimeKind == ParsedLifetimeDependenceKind::Default) {
612+ switch (parsedLifetimeKind) {
613+ case ParsedLifetimeDependenceKind::Default: {
613614 if (type->isEscapable ()) {
614615 if (loweredOwnership == ValueOwnership::Shared ||
615616 loweredOwnership == ValueOwnership::InOut) {
616617 return LifetimeDependenceKind::Scope;
617- } else {
618- diagnose (
619- loc,
620- diag::lifetime_dependence_cannot_use_default_escapable_consuming,
621- getOwnershipSpelling (loweredOwnership));
622- return std::nullopt ;
623618 }
624- } else if (useLazyInference ()) {
619+ diagnose (
620+ loc,
621+ diag::lifetime_dependence_cannot_use_default_escapable_consuming,
622+ getOwnershipSpelling (loweredOwnership));
623+ return std::nullopt ;
624+ }
625+ if (useLazyInference ()) {
625626 return LifetimeDependenceKind::Inherit;
626627 }
627628 diagnose (loc, diag::lifetime_dependence_cannot_infer_kind,
628629 diagnosticQualifier (), descriptor.getString ());
629630 return std::nullopt ;
630631 }
631632
633+ case ParsedLifetimeDependenceKind::Borrow: LLVM_FALLTHROUGH;
634+ case ParsedLifetimeDependenceKind::Inout: {
632635 // @lifetime(borrow x) is valid only for borrowing parameters.
633636 // @lifetime(inout x) is valid only for inout parameters.
634637 if (!isCompatibleWithOwnership (parsedLifetimeKind, type,
@@ -639,16 +642,17 @@ class LifetimeDependenceChecker {
639642 getOwnershipSpelling (loweredOwnership));
640643 return std::nullopt ;
641644 }
645+ return LifetimeDependenceKind::Scope;
646+ }
647+ case ParsedLifetimeDependenceKind::Inherit:
642648 // @lifetime(copy x) is only invalid for Escapable types.
643- if (parsedLifetimeKind == ParsedLifetimeDependenceKind::Inherit &&
644- type->isEscapable ()) {
649+ if (type->isEscapable ()) {
645650 diagnose (loc, diag::lifetime_dependence_invalid_inherit_escapable_type,
646651 descriptor.getString ());
647652 return std::nullopt ;
648653 }
649- return parsedLifetimeKind == ParsedLifetimeDependenceKind::Inherit
650- ? LifetimeDependenceKind::Inherit
651- : LifetimeDependenceKind::Scope;
654+ return LifetimeDependenceKind::Inherit;
655+ }
652656 }
653657
654658 // Finds the ParamDecl* and its index from a LifetimeDescriptor
0 commit comments