Login Sign Up
Advert
Your ad spot
Reserve this exclusive slot for the selected period.
Buy advertising →
Telegram community logo - BW Swift
Added 06 Jan 2025

BW Swift

@bwswift
Number of subscribers: 1 742
Photos: 1,710
Videos: 176
Links: 1,590
Description:
Канал створений для навчання програмування на swift та розробці програм під iOS. Мета проекту - допомогти студентам пройти шлях від розробника-початківця до оплачуваного фахівця. Тут я публікую актуальні та цікаві статті щодо iOS розробки. Адмін: @bws2007
Source

BW Swift | Ось таку багу зловив та зарепортив. Swift компілятор не справляється з...

Telegram community logo - BW Swift BW Swift @bwswift
1 120 Views/Reach 2025-07-21 04:16 Message №1912
🐞 Ось таку багу зловив та зарепортив. Swift компілятор не справляється з generic KeyPath.https://github.com/swiftlang/swift/issues/83197Цілью було отримати компайл тайм сейфті, групування по категоріям та автокомпліт.Навіть в простому варіанті падаєenum Resources { enum Category { }}struct Utils { static func resource<ResourceCategory>(_ type: KeyPath<Resources.Type, ResourceCategory.Type>) -> ResourceCategory.Type { Resources.self[keyPath: type] }}func testResourceGetter() { // 👇 This line crashes the compiler. let resource = Utils.resource(\.Category)} Робочій код був (мав бути) такийstruct Resource { let name: String}enum Resources { enum Category { static let nestedResource = Resource(name: "test") }}struct Utils { static func resource<ResourceCategory>( _ type: KeyPath<Resources.Type, ResourceCategory.Type>, resource: KeyPath<ResourceCategory.Type, Resource> ) -> Resource { ResourceCategory.self[keyPath: resource] }}func testResourceGetter() { // 👇 This line crashes the compiler. let resource = Utils.resource(\.Category, resource: \.nestedResource)}