@@ -1193,9 +1193,11 @@ namespace {
11931193
11941194 ManagedValue project (SILGenFunction &SGF, SILLocation loc,
11951195 ManagedValue base) && override {
1196- assert (base
1197- && base.getType ().isAddress ()
1198- && " should have an address base to borrow from" );
1196+ // If the base is already loaded, we just need to borrow it.
1197+ if (!base.getType ().isAddress ()) {
1198+ return base.formalAccessBorrow (SGF, loc);
1199+ }
1200+
11991201 // If the base value is address-only then we can borrow from the
12001202 // address in-place.
12011203 if (!base.getType ().isLoadable (SGF.F )) {
@@ -3384,9 +3386,15 @@ void LValue::addNonMemberVarComponent(
33843386 " local var should not be actor isolated!" );
33853387 }
33863388
3387- assert (address.isLValue () &&
3388- " Must have a physical copyable lvalue decl ref that "
3389- " evaluates to an address" );
3389+ if (!address.isLValue ()) {
3390+ assert ((AccessKind == SGFAccessKind::BorrowedObjectRead
3391+ || AccessKind == SGFAccessKind::BorrowedAddressRead)
3392+ && " non-borrow component requires an address base" );
3393+ LV.add <ValueComponent>(address, std::nullopt , typeData,
3394+ /* rvalue*/ true );
3395+ LV.add <BorrowValueComponent>(typeData);
3396+ return ;
3397+ }
33903398
33913399 llvm::Optional<SILAccessEnforcement> enforcement;
33923400 if (!Storage->isLet ()) {
0 commit comments