Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/SILGen/SILGenLValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5530,9 +5530,9 @@ RValue SILGenFunction::emitLoadOfLValue(SILLocation loc, LValue &&src,
projection =
emitLoad(loc, projection.getValue(), origFormalType,
substFormalType, rvalueTL, C, IsNotTake, isBaseGuaranteed);
} else if (isReadAccessResultOwned(src.getAccessKind()) &&
!projection.isPlusOneOrTrivial(*this)) {

} else if (!projection.isPlusOneOrTrivial(*this) &&
(!C.isImmediatePlusZeroOk() &&
!(C.isGuaranteedPlusZeroOk() && isBaseGuaranteed))) {
// Before we copy, if we have a move only wrapped value, unwrap the
// value using a guaranteed moveonlywrapper_to_copyable.
if (projection.getType().isMoveOnlyWrapped()) {
Expand Down
26 changes: 26 additions & 0 deletions test/SILGen/borrow_accessor_unit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RUN:%target-swift-frontend -emit-silgen %s -enable-experimental-feature BorrowAndMutateAccessors

// REQUIRES: swift_feature_BorrowAndMutateAccessors

public final class Klass {}

public struct Wrapper {
var _k: Klass

var k: Klass {
borrow {
return _k
}
mutate {
return &_k
}
}
}

@inline(never)
func blackhole<T>(_ t: T) { }

func inoutTest(_ w: inout Wrapper) {
let k = w.k
blackhole(k)
}