@@ -1195,9 +1195,11 @@ namespace {
11951195
11961196 ManagedValue project (SILGenFunction &SGF, SILLocation loc,
11971197 ManagedValue base) && override {
1198- assert (base
1199- && base.getType ().isAddress ()
1200- && " should have an address base to borrow from" );
1198+ // If the base is already loaded, we just need to borrow it.
1199+ if (!base.getType ().isAddress ()) {
1200+ return base.formalAccessBorrow (SGF, loc);
1201+ }
1202+
12011203 // If the base value is address-only then we can borrow from the
12021204 // address in-place.
12031205 if (!base.getType ().isLoadable (SGF.F )) {
@@ -3380,9 +3382,15 @@ void LValue::addNonMemberVarComponent(
33803382 " local var should not be actor isolated!" );
33813383 }
33823384
3383- assert (address.isLValue () &&
3384- " Must have a physical copyable lvalue decl ref that "
3385- " evaluates to an address" );
3385+ if (!address.isLValue ()) {
3386+ assert ((AccessKind == SGFAccessKind::BorrowedObjectRead
3387+ || AccessKind == SGFAccessKind::BorrowedAddressRead)
3388+ && " non-borrow component requires an address base" );
3389+ LV.add <ValueComponent>(address, std::nullopt , typeData,
3390+ /* rvalue*/ true );
3391+ LV.add <BorrowValueComponent>(typeData);
3392+ return ;
3393+ }
33863394
33873395 llvm::Optional<SILAccessEnforcement> enforcement;
33883396 if (!Storage->isLet ()) {
0 commit comments