mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #85707 from eeckstein/embedded-witness-method-specialization
embedded: change the function representation of directly called witness methods
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
// REQUIRES: optimized_stdlib
|
||||
// REQUIRES: swift_feature_Embedded
|
||||
|
||||
// For some reason integer hashing results in an undefined symbol "arc4random_buf" linker error on linux
|
||||
// REQUIRES: OS=macosx
|
||||
|
||||
public class C {
|
||||
public var x: Int {
|
||||
_read {
|
||||
@@ -21,6 +24,25 @@ public class C {
|
||||
var y: Int = 27
|
||||
}
|
||||
|
||||
public protocol P {
|
||||
var d: [Int : WrappedBool] { get set }
|
||||
}
|
||||
|
||||
extension P {
|
||||
mutating func set(key: Int) {
|
||||
d[key]?.b = true
|
||||
}
|
||||
}
|
||||
|
||||
public struct WrappedBool {
|
||||
public var b: Bool = true
|
||||
}
|
||||
|
||||
public class S: P {
|
||||
public var d: [Int : WrappedBool] = [:]
|
||||
public func foo() {}
|
||||
}
|
||||
|
||||
@main
|
||||
struct Main {
|
||||
static func main() {
|
||||
@@ -33,5 +55,11 @@ struct Main {
|
||||
|
||||
print("2") // CHECK: 2
|
||||
print("")
|
||||
|
||||
var handler = S()
|
||||
handler.d[27] = WrappedBool(b: false)
|
||||
handler.set(key: 27)
|
||||
// CHECK: true
|
||||
print(handler.d[27]!.b ? "true" : "false")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user