Avatar
Avatar
kntk
@swift-5.3.3 @swift-5.10 protocol P { } extension P { static func value(_ a: Bool) { } } struct A: P { var string: String } extension Optional: P where Wrapped: P { } extension A { static var value: A? { A(string: "A") } } let a: A? = .value print(a) (edited)
swift510 BOT 4/7/2024 10:14 AM
Optional(main.A(string: "A"))<stdin>:17:7: warning: expression implicitly coerced from 'A?' to 'Any' print(a) ^ <stdin>:17:7: note: provide a default value to avoid this warning print(a) ^ ?? <#default value#> <stdin>:17:7: note: force-unwrap the value to avoid this warning print(a) ^ ! <stdin>:17:7: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(a) ^ as Any