mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This fixes a bad optimization deficiency for dictionary subscript lookups with default values: there shouldn't be a closure context allocated. rdar://106423763
20 lines
600 B
Swift
20 lines
600 B
Swift
// RUN: %target-swift-frontend %s -O -module-name=test -emit-sil | %FileCheck %s
|
|
|
|
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
|
|
|
|
public struct S {
|
|
var x: Int
|
|
|
|
@inline(never)
|
|
mutating func doSomething() { }
|
|
}
|
|
|
|
// Check that all partial_applys can be optimized away so that no closure context needs to be allocated.
|
|
|
|
// CHECK-LABEL: sil @$s4test6testit_1xySDySiAA1SVGz_SitF :
|
|
// CHECK-NOT: partial_apply
|
|
// CHECK: } // end sil function '$s4test6testit_1xySDySiAA1SVGz_SitF'
|
|
public func testit(_ data: inout [Int: S], x: Int) {
|
|
data[x, default: S(x: x)].doSomething()
|
|
}
|