Avatar
朝出てましたが、Opaque Result Type、if #availableで型分岐できるようになるみたいですね A function returning an opaque result type is allowed to return values of different concrete types from conditionally available if #available branches without any other dynamic conditions, if and only if, all universally available return statements in its body return a value of the same concrete type T. struct Square { func asRectangle() -> some Shape { if #available(macOS 100, *) { return Rectangle(...) // ⭕️ } return self } } https://forums.swift.org/t/se-0360-opaque-result-types-with-limited-availability/57729 (edited)
Hi everyone. The review of SE-0360, Opaque result types with limited availability, begins now and runs through June 14, 2022. Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to the review manager by email or DM. ...