Skip to content

Commit d5884a2

Browse files
authored
Merge pull request #71908 from jckarter/borrow-all-accessor-bases
SILGen: Borrow any move-only or borrow-expr'ed accessor base.
2 parents 81480b5 + 6cb5e17 commit d5884a2

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/SILGen/SILGenLValue.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,12 +3734,6 @@ static bool shouldEmitSelfAsRValue(AccessorDecl *fn, CanType selfType,
37343734
return false;
37353735
case SelfAccessKind::Borrowing:
37363736
case SelfAccessKind::NonMutating:
3737-
// If the accessor is a coroutine, we may want to access the projected
3738-
// value through a borrow of the base. But if it's a regular get/set then
3739-
// there isn't any real benefit to doing so.
3740-
if (!fn->isCoroutine()) {
3741-
return true;
3742-
}
37433737
// Normally we'll copy the base to minimize accesses. But if the base
37443738
// is noncopyable, or we're accessing it in a `borrow` expression, then
37453739
// we want to keep the access nested on the original base.

test/SILOptimizer/moveonly_borrowing_switch.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,3 +342,10 @@ extension ChonkyList {
342342
}
343343
}
344344
}
345+
346+
// https://github.com/apple/swift/issues/71598
347+
struct RangeHolder:~Copyable
348+
{
349+
var r:Range<Int> { fatalError() }
350+
var y:Int { self.r.upperBound }
351+
}

0 commit comments

Comments
 (0)