Files
swift-mirror/test/SILOptimizer/moveonly_computed_property.swift
Joe Groff cb23187209 SILGen: Emit move-only bases for lvalues in a borrow scope.
Normally, if we project from a mutable class ivar or global variable, we'll
load a copy in a tight access scope and then project from the copy, in order to
minimize the potential for exclusivity violations while working with classes and
copyable values. However, this is undesirable when a value is move-only, since
copying is not allowed; borrowing the value in place is the expected and only possible
behavior. rdar://105794506
2023-04-19 14:50:34 -07:00

22 lines
456 B
Swift

// RUN: %target-swift-frontend -emit-sil -verify %s
// Applying a computed property to a move-only field in a class should occur
// entirely within a formal access to the class property. rdar://105794506
@_moveOnly
struct FileDescriptor {
private let desc: Int
var empty: Bool { return desc == Int.min }
}
final class Wrapper {
private var val: FileDescriptor
func isEmpty_bug() -> Bool {
return val.empty
}
init() { fatalError() }
}