1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
|
// RUN: %target-swift-emit-silgen -enable-experimental-feature ThenStatements %s | %FileCheck %s
// RUN: %target-swift-emit-ir -enable-experimental-feature ThenStatements %s
// Needed for experimental features
// REQUIRES: asserts
func foo() -> Int {
if .random() { 1 } else { 2 }
}
// CHECK-LABEL: sil hidden [ossa] @$s7if_expr3fooSiyF : $@convention(thin) () -> Int
// CHECK: [[RESULT:%[0-9]+]] = alloc_stack $Int
// CHECK: cond_br {{%[0-9]+}}, [[TRUEBB:bb[0-9]+]], [[FALSEBB:bb[0-9]+]]
//
// CHECK: [[TRUEBB]]:
// CHECK: [[ONE_BUILTIN:%[0-9]+]] = integer_literal $Builtin.IntLiteral, 1
// CHECK: [[ONE:%[0-9]+]] = apply {{%[0-9]+}}([[ONE_BUILTIN]], {{%[0-9]+}}) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
// CHECK: store [[ONE]] to [trivial] [[RESULT]] : $*Int
// CHECK: br [[EXITBB:bb[0-9]+]]
//
// CHECK: [[FALSEBB]]:
// CHECK: [[TWO_BUILTIN:%[0-9]+]] = integer_literal $Builtin.IntLiteral, 2
// CHECK: [[TWO:%[0-9]+]] = apply {{%[0-9]+}}([[TWO_BUILTIN]], {{%[0-9]+}}) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
// CHECK: store [[TWO]] to [trivial] [[RESULT]] : $*Int
// CHECK: br [[EXITBB]]
//
// CHECK: [[EXITBB]]:
// CHECK: [[VAL:%[0-9]+]] = load [trivial] [[RESULT]] : $*Int
// CHECK: dealloc_stack [[RESULT]] : $*Int
// CHECK: return [[VAL]] : $Int
class C {}
func bar(_ x: C) -> C {
if .random() { x } else { C() }
}
// CHECK-LABEL: sil hidden [ossa] @$s7if_expr3baryAA1CCADF : $@convention(thin) (@guaranteed C) -> @owned C
// CHECK: bb0([[CPARAM:%[0-9]+]] : @guaranteed $C):
// CHECK: [[RESULT:%[0-9]+]] = alloc_stack $C
// CHECK: cond_br {{%[0-9]+}}, [[TRUEBB:bb[0-9]+]], [[FALSEBB:bb[0-9]+]]
//
// CHECK: [[TRUEBB]]:
// CHECK: [[C:%[0-9]+]] = copy_value [[CPARAM]] : $C
// CHECK: store [[C]] to [init] [[RESULT]] : $*C
// CHECK: br [[EXITBB:bb[0-9]+]]
//
// CHECK: [[FALSEBB]]:
// CHECK: [[CTOR:%[0-9]+]] = function_ref @$s7if_expr1CCACycfC : $@convention(method) (@thick C.Type) -> @owned C
// CHECK: [[C:%[0-9]+]] = apply [[CTOR]]({{%[0-9]+}}) : $@convention(method) (@thick C.Type) -> @owned C
// CHECK: store [[C]] to [init] [[RESULT]] : $*C
// CHECK: br [[EXITBB]]
//
// CHECK: [[EXITBB]]:
// CHECK: [[VAL:%[0-9]+]] = load [take] [[RESULT]] : $*C
// CHECK: dealloc_stack [[RESULT]] : $*C
// CHECK: return [[VAL]] : $C
struct Err: Error {}
func baz() throws -> Int {
if .random() {
0
} else if .random() {
throw Err()
} else {
2
}
}
// CHECK-LABEL: sil hidden [ossa] @$s7if_expr3bazSiyKF : $@convention(thin) () -> (Int, @error any Error)
// CHECK: [[RESULT:%[0-9]+]] = alloc_stack $Int
// CHECK: cond_br {{%[0-9]+}}, [[TRUEBB:bb[0-9]+]], [[FALSEBB:bb[0-9]+]]
//
// CHECK: [[FALSEBB]]:
// CHECK: cond_br {{%[0-9]+}}, [[FALSETRUEBB:bb[0-9]+]], [[FALSEFALSEBB:bb[0-9]+]]
//
// CHECK: [[FALSETRUEBB]]:
// CHECK: throw {{%[0-9]+}} : $any Error
//
// CHECK: [[FALSEFALSEBB]]:
// CHECK: br [[EXITBB:bb[0-9]+]]
//
// CHECK: [[EXITBB]]:
// CHECK: [[VAL:%[0-9]+]] = load [trivial] [[RESULT]] : $*Int
// CHECK: dealloc_stack [[RESULT]] : $*Int
// CHECK: return [[VAL]] : $Int
func qux() throws -> Int {
if .random() { 0 } else { try baz() }
}
// CHECK-LABEL: sil hidden [ossa] @$s7if_expr3quxSiyKF : $@convention(thin) () -> (Int, @error any Error)
// CHECK: [[RESULT:%[0-9]+]] = alloc_stack $Int
// CHECK: cond_br {{%[0-9]+}}, [[TRUEBB:bb[0-9]+]], [[FALSEBB:bb[0-9]+]]
//
// CHECK: [[FALSEBB]]:
// CHECK: try_apply {{%[0-9]+}}() : $@convention(thin) () -> (Int, @error any Error), normal [[NORMALBB:bb[0-9]+]], error [[ERRORBB:bb[0-9]+]]
//
// CHECK: [[NORMALBB]]([[BAZVAL:%[0-9]+]] : $Int):
// CHECK: store [[BAZVAL]] to [trivial] [[RESULT]] : $*Int
// CHECK: br [[EXITBB:bb[0-9]+]]
//
// CHECK: [[EXITBB]]:
// CHECK: [[VAL:%[0-9]+]] = load [trivial] [[RESULT]] : $*Int
// CHECK: dealloc_stack [[RESULT]] : $*Int
// CHECK: return [[VAL]] : $Int
//
// CHECK: [[ERRORBB]]([[ERR:%[0-9]+]] : @owned $any Error):
// CHECK: dealloc_stack [[RESULT]] : $*Int
// CHECK: throw [[ERR]] : $any Error
func optionalVoidCrash() {
func takesClosure<T>(_ x: () -> T) {}
struct S {
func bar() {}
}
var s: S?
takesClosure {
if true {
s?.bar()
} else {
()
}
}
}
func testClosure() throws -> Int {
let fn = {
if .random() {
0
} else {
try baz()
}
}
return try fn()
}
// CHECK-LABEL: sil private [ossa] @$s7if_expr11testClosureSiyKFSiyKcfU_ : $@convention(thin) () -> (Int, @error any Error)
// CHECK: [[RESULT:%[0-9]+]] = alloc_stack $Int
// CHECK: cond_br {{%[0-9]+}}, [[TRUEBB:bb[0-9]+]], [[FALSEBB:bb[0-9]+]]
//
// CHECK: [[FALSEBB]]:
// CHECK: try_apply {{%[0-9]+}}() : $@convention(thin) () -> (Int, @error any Error), normal [[NORMALBB:bb[0-9]+]], error [[ERRORBB:bb[0-9]+]]
//
// CHECK: [[NORMALBB]]([[BAZVAL:%[0-9]+]] : $Int):
// CHECK: store [[BAZVAL]] to [trivial] [[RESULT]] : $*Int
// CHECK: br [[EXITBB:bb[0-9]+]]
//
// CHECK: [[EXITBB]]:
// CHECK: [[VAL:%[0-9]+]] = load [trivial] [[RESULT]] : $*Int
// CHECK: dealloc_stack [[RESULT]] : $*Int
// CHECK: return [[VAL]] : $Int
//
// CHECK: [[ERRORBB]]([[ERR:%[0-9]+]] : @owned $any Error):
// CHECK: dealloc_stack [[RESULT]] : $*Int
// CHECK: throw [[ERR]] : $any Error
func testNested() throws -> Int {
if .random() {
0
} else {
if .random() {
throw Err()
} else {
2
}
}
}
// CHECK-LABEL: sil hidden [ossa] @$s7if_expr10testNestedSiyKF : $@convention(thin) () -> (Int, @error any Error)
// CHECK: [[RESULT:%[0-9]+]] = alloc_stack $Int
// CHECK: cond_br {{%[0-9]+}}, [[TRUEBB:bb[0-9]+]], [[FALSEBB:bb[0-9]+]]
//
// CHECK: [[FALSEBB]]:
// CHECK: cond_br {{%[0-9]+}}, [[FALSETRUEBB:bb[0-9]+]], [[FALSEFALSEBB:bb[0-9]+]]
//
// CHECK: [[FALSETRUEBB]]:
// CHECK: throw {{%[0-9]+}} : $any Error
//
// CHECK: [[FALSEFALSEBB]]:
// CHECK: br [[EXITBB:bb[0-9]+]]
//
// CHECK: [[EXITBB]]:
// CHECK: [[VAL:%[0-9]+]] = load [trivial] [[RESULT]] : $*Int
// CHECK: dealloc_stack [[RESULT]] : $*Int
// CHECK: return [[VAL]] : $Int
func testVar() -> Int {
let x = if .random() { 1 } else { 2 }
return x
}
func testPoundIf1() -> Int {
let x = if .random() {
#if true
1
#else
""
#endif
} else {
#if false
""
#else
2
#endif
}
return x
}
func testPoundIf2() -> Int {
if .random() {
#if false
0
#else
#if true
if .random() { 0 } else { 1 }
#endif
#endif
} else {
#if true
if .random() { 0 } else { 1 }
#endif
}
}
func testCatch() -> Int {
do {
let x = if .random() {
0
} else {
throw Err()
}
return x
} catch {
return 0
}
}
struct TestPropertyInit {
var x = if .random() { 1 } else { 0 }
lazy var y = if .random() { 1 } else { 0 }
}
func testAssignment() {
var x = 0
x = if .random() { 0 } else { 1 }
let fn = {
x = if .random() { 0 } else { 1 }
}
}
func nestedType() throws -> Int {
if .random() {
struct S: Error {}
throw S()
} else {
0
}
}
// MARK: Bindings
enum E {
case e(Int)
}
struct S {
var i: Int
var opt: Int?
var computed: Int {
get { i }
set { i = newValue }
}
var coroutined: Int {
_read { yield i }
_modify { yield &i }
}
subscript(x: Int) -> Int {
get { i }
set { i = newValue }
}
mutating func testAssign1(_ x: E) {
i = if case .e(let y) = x { y } else { 0 }
}
mutating func testAssign2(_ x: E) {
i = if case .e(let y) = x { Int(y) } else { 0 }
}
func testAssign3(_ x: E) {
var i = 0
i = if case .e(let y) = x { y } else { 0 }
_ = i
}
func testAssign4(_ x: E) {
var i = 0
let _ = {
i = if case .e(let y) = x { y } else { 0 }
}
_ = i
}
mutating func testAssign5(_ x: E) {
i = switch Bool.random() {
case true:
if case .e(let y) = x { y } else { 0 }
case let z:
z ? 0 : 1
}
}
mutating func testAssign6(_ x: E) {
i = if case .e(let y) = x {
switch Bool.random() {
case true: y
case false: y
}
} else {
0
}
}
mutating func testAssign7(_ x: E?) {
i = if let x = x {
switch x {
case .e(let y): y
}
} else {
0
}
}
func testReturn1(_ x: E) -> Int {
if case .e(let y) = x { y } else { 0 }
}
func testReturn2(_ x: E) -> Int {
return if case .e(let y) = x { y } else { 0 }
}
func testReturn3(_ x: E) -> Int {
{
if case .e(let y) = x { y } else { 0 }
}()
}
func testReturn4(_ x: E) -> Int {
return {
if case .e(let y) = x { y } else { 0 }
}()
}
func testBinding1(_ x: E) -> Int {
let i = if case .e(let y) = x { y } else { 0 }
return i
}
func testBinding2(_ x: E) -> Int {
let i = {
if case .e(let y) = x { y } else { 0 }
}()
return i
}
}
enum G {
case e(Int)
case f
}
struct TestLValues {
var s: S
var opt: S?
var optopt: S??
mutating func testOptPromote1() {
opt = if .random() { s } else { s }
}
mutating func testOptPromote2() {
optopt = if .random() { s } else { s }
}
mutating func testStored1() {
s.i = if .random() { 1 } else { 0 }
}
mutating func testStored2() throws {
s.i = if .random() { 1 } else { throw Err() }
}
mutating func testComputed1() {
s.computed = if .random() { 1 } else { 0 }
}
mutating func testComputed2() throws {
s.computed = if .random() { 1 } else { throw Err() }
}
mutating func testCoroutined1() {
s.coroutined = if .random() { 1 } else { 0 }
}
mutating func testCoroutined2() throws {
s.coroutined = if .random() { 1 } else { throw Err() }
}
mutating func testOptionalChain1() {
opt?.i = if .random() { 1 } else { 0 }
}
mutating func testOptionalChain2() throws {
opt?.i = if .random() { throw Err() } else { 0 }
}
mutating func testOptionalChain3(_ g: G) {
opt?.i = if case .e(let i) = g { i } else { 0 }
}
mutating func testOptionalChain4(_ g: G) throws {
opt?.i = if case .e(let i) = g { i } else { throw Err() }
}
mutating func testOptionalChain5(_ g: G) throws {
opt?.computed = if case .e(let i) = g { i } else { throw Err() }
}
mutating func testOptionalChain6(_ g: G) throws {
opt?.coroutined = if case .e(let i) = g { i } else { throw Err() }
}
mutating func testOptionalChain7() throws {
optopt??.i = if .random() { 1 } else { throw Err() }
}
mutating func testOptionalChain8() throws {
optopt??.opt = if .random() { 1 } else { throw Err() }
}
mutating func testOptionalChain9() throws {
optopt??.opt? = if .random() { 1 } else { throw Err() }
}
mutating func testOptionalForce1() throws {
opt!.i = if .random() { throw Err() } else { 0 }
}
mutating func testOptionalForce2() throws {
opt!.computed = if .random() { throw Err() } else { 0 }
}
mutating func testOptionalForce3(_ g: G) throws {
opt!.coroutined = if case .e(let i) = g { i } else { throw Err() }
}
mutating func testOptionalForce4() throws {
optopt!!.i = if .random() { 1 } else { throw Err() }
}
mutating func testOptionalForce5() throws {
optopt!!.opt = if .random() { 1 } else { throw Err() }
}
mutating func testOptionalForce6() throws {
optopt!!.opt! = if .random() { 1 } else { throw Err() }
}
mutating func testSubscript1() throws {
s[5] = if .random() { 1 } else { throw Err() }
}
mutating func testSubscript2() throws {
opt?[5] = if .random() { 1 } else { throw Err() }
}
mutating func testSubscript3() throws {
opt![5] = if .random() { 1 } else { throw Err() }
}
mutating func testKeyPath1(_ kp: WritableKeyPath<S, Int>) throws {
s[keyPath: kp] = if .random() { 1 } else { throw Err() }
}
mutating func testKeyPath2(_ kp: WritableKeyPath<S, Int>) throws {
opt?[keyPath: kp] = if .random() { 1 } else { throw Err() }
}
mutating func testKeyPath3(_ kp: WritableKeyPath<S, Int>) throws {
opt![keyPath: kp] = if .random() { 1 } else { throw Err() }
}
}
func testNever1() -> Never {
if case let x = fatalError() { x } else { fatalError() }
}
func testNever2() -> Never {
if .random() { fatalError() } else { fatalError() }
}
func testNever3() -> Int {
if .random() {
fatalError()
} else {
0
}
}
// CHECK-LABEL: sil hidden [ossa] @$s7if_expr10testNever3SiyF : $@convention(thin) () -> Int
// CHECK: [[RESULT:%[0-9]+]] = alloc_stack $Int
// CHECK: cond_br {{%[0-9]+}}, [[BB_TRUE:bb[0-9]+]], [[BB_FALSE:bb[0-9]+]]
//
// CHECK: [[BB_TRUE]]:
// CHECK: function_ref fatalError(_:file:line:)
// CHECK: unreachable
//
// CHECK: [[BB_FALSE]]:
// CHECK: store {{%[0-9]+}} to [trivial] [[RESULT]] : $*Int
// CHECK: [[RET:%[0-9]+]] = load [trivial] [[RESULT]] : $*Int
// CHECK: dealloc_stack [[RESULT]] : $*Int
// CHECK: return [[RET]]
func never() -> Never { fatalError() }
func testNever4() -> Int {
if .random() {
never()
} else {
0
}
}
func neverTuple() -> (Never, Int) { fatalError() }
func testNever5() -> (Never, Int) {
if .random() {
neverTuple()
} else {
(never(), 0)
}
}
// CHECK-LABEL: sil hidden [ossa] @$s7if_expr10testNever5s5NeverO_SityF : $@convention(thin) () -> (Never, Int)
// CHECK: [[RESULT:%[0-9]+]] = alloc_stack $(Never, Int)
// CHECK: cond_br {{%[0-9]+}}, [[BB_TRUE:bb[0-9]+]], [[BB_FALSE:bb[0-9]+]]
//
// CHECK: [[BB_TRUE]]:
// CHECK: [[ELT_0:%[0-9]+]] = tuple_element_addr [[RESULT]] : $*(Never, Int), 0
// CHECK: [[ELT_1:%[0-9]+]] = tuple_element_addr [[RESULT]] : $*(Never, Int), 1
// CHECK: ([[RET_0:%[0-9]+]], [[RET_1:%[0-9]+]]) = destructure_tuple {{%[0-9]+}} : $(Never, Int)
// CHECK: store [[RET_0]] to [trivial] [[ELT_0]] : $*Never
// CHECK: store [[RET_1]] to [trivial] [[ELT_1]] : $*Int
// CHECK: br [[BB_EXIT:bb[0-9]+]]
//
// CHECK: [[BB_FALSE]]:
// CHECK: [[ELT_0:%[0-9]+]] = tuple_element_addr [[RESULT]] : $*(Never, Int), 0
// CHECK: [[ELT_1:%[0-9]+]] = tuple_element_addr [[RESULT]] : $*(Never, Int), 1
// CHECK: store {{%[0-9]+}} to [trivial] [[ELT_0]] : $*Never
// CHECK: store {{%[0-9]+}} to [trivial] [[ELT_1]] : $*Int
// CHECK: br [[BB_EXIT:bb[0-9]+]]
//
// CHECK: [[BB_EXIT]]:
// CHECK: dealloc_stack [[RESULT]] : $*(Never, Int)
// CHECK: [[RET:%[0-9]+]] = tuple ({{%[0-9]+}} : $Never, {{%[0-9]+}} : $Int)
// CHECK: return [[RET]]
func testCaptureList() -> Int {
let fn = { [x = if .random() { 0 } else { 1 }] in x }
return fn()
}
// https://github.com/apple/swift/issues/68764
func testConditionalCast<T>(_ x: Any) -> T? {
if .random() {
x as? T
} else {
nil
}
}
@propertyWrapper
struct Wrapper<T> {
var wrappedValue: T
}
// rdar://119158202 - Make sure we correctly contextualize local bindings.
func testLazyLocal(_ x: Int?) {
// CHECK-LABEL: sil private [lazy_getter] [noinline] [ossa] @$s7if_expr13testLazyLocalyySiSgF1aL_Sivg : $@convention(thin) (@guaranteed { var Optional<Int> }, Optional<Int>) -> Int
lazy var a = if let x { x } else { 0 }
_ = a
// CHECK-LABEL: sil private [lazy_getter] [noinline] [ossa] @$s7if_expr13testLazyLocalyySiSgF1bL_SSvg : $@convention(thin) (@guaranteed { var Optional<String> }) -> @owned String
lazy var b = if .random() {
let x = ""
then x
} else {
""
}
_ = b
// CHECK-LABEL: sil private [lazy_getter] [noinline] [ossa] @$s7if_expr13testLazyLocalyySiSgF1cL_SSvg : $@convention(thin) (@guaranteed { var Optional<String> }) -> @owned String
lazy var c = if .random() {
// CHECK-LABEL: sil private [lazy_getter] [noinline] [ossa] @$s7if_expr13testLazyLocalyySiSgF1cL_SSvg1xL2_SSvg : $@convention(thin) (@guaranteed { var Optional<String> }) -> @owned String
lazy var x = ""
then x
} else {
""
}
_ = c
// CHECK-LABEL: sil private [lazy_getter] [noinline] [ossa] @$s7if_expr13testLazyLocalyySiSgF1dL_Sivg : $@convention(thin) (@guaranteed { var Optional<Int> }, Optional<Int>) -> Int
lazy var d = if .random() {
// CHECK-LABEL: sil private [lazy_getter] [noinline] [ossa] @$s7if_expr13testLazyLocalyySiSgF1dL_Sivg1yL_Sivg : $@convention(thin) (@guaranteed { var Optional<Int> }, Optional<Int>) -> Int
lazy var y = if let x { x } else { 0 }
then y
} else {
0
}
_ = d
// CHECK-LABEL: sil private [lazy_getter] [noinline] [ossa] @$s7if_expr13testLazyLocalyySiSgF1eL_Sivg : $@convention(thin) (@guaranteed { var Optional<Int> }) -> Int
lazy var e = if .random() {
@Wrapper
var x = 0
then x
} else {
0
}
_ = e
}
struct LazyProp {
var a: Int?
// CHECK-LABEL: sil hidden [lazy_getter] [noinline] [ossa] @$s7if_expr8LazyPropV1bSivg : $@convention(method) (@inout LazyProp) -> Int
lazy var b = if let a { a } else { 0 }
// CHECK-LABEL: sil hidden [lazy_getter] [noinline] [ossa] @$s7if_expr8LazyPropV1cSivg : $@convention(method) (@inout LazyProp) -> Int
lazy var c = if .random() {
// CHECK-LABEL: sil private [lazy_getter] [noinline] [ossa] @$s7if_expr8LazyPropV1cSivg1xL_Sivg : $@convention(thin) (@guaranteed { var Optional<Int> }) -> Int
lazy var x = 0
then x
} else {
0
}
// CHECK-LABEL: sil hidden [lazy_getter] [noinline] [ossa] @$s7if_expr8LazyPropV1dSivg : $@convention(method) (@inout LazyProp) -> Int
lazy var d = if .random() {
// CHECK-LABEL: sil private [lazy_getter] [noinline] [ossa] @$s7if_expr8LazyPropV1dSivg1xL_Sivg : $@convention(thin) (@guaranteed { var Optional<Int> }, @inout_aliasable LazyProp) -> Int
lazy var x = if case let a? = a { a } else { 0 }
then x
} else {
0
}
}
|