mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When SimplifyCFG (temporarily) produces an unreachable CFG cycle, some other transformations in SimplifyCFG didn't deal with this situation correctly. Unfortunately I couldn't create a SIL test case for this bug, so I just added a swift test case. https://bugs.swift.org/browse/SR-13650 rdar://problem/69942431
24 lines
430 B
Swift
24 lines
430 B
Swift
// RUN: %target-swift-frontend -O -emit-sil %s | %FileCheck %s
|
|
|
|
// Check that the optimizer does not crash.
|
|
|
|
|
|
public class Base {
|
|
@inline(never)
|
|
final func next() -> Base? {
|
|
return self
|
|
}
|
|
}
|
|
|
|
public class Derived : Base {}
|
|
|
|
// CHECK: sil {{.*}}testit
|
|
public func testit(_ x: Base?) -> Derived? {
|
|
var i: Base? = x
|
|
while (i is Derived) == false && i != nil {
|
|
i = i?.next()
|
|
}
|
|
return i as? Derived
|
|
}
|
|
|