// RUN: %empty-directory(%t) // RUN: %target-build-swift -O -module-name=test %s -o %t/a.out // RUN: %target-run %t/a.out | %FileCheck %s // REQUIRES: executable_test,swift_stdlib_no_asserts,optimized_stdlib // REQUIRES: rdar89260664 final class Storage { var v : Int init(_ v : Int) { self.v = v } } struct IntBox { var s : Storage init(_ x : Int) { s = Storage(x) } var value: Int { return s.v } mutating func increment(_ delta: Int = 1) { if (!isKnownUniquelyReferenced(&s)) { // We should never see this message print("## copy on write") s = Storage(s.v) } s.v += delta } } enum E: CustomStringConvertible { case value(IntBox) case none @inline(never) mutating func simpleIncrement() { switch self { case .value(var i): i.increment() self = .value(i) case .none: break } } @inline(never) mutating func incrementWithControlFlow(_ n: Int, _ c: Bool) { switch self { case .value(var i): i.increment() for _ in [0..