15 марта анонсирована срезка версии 6.0. https://forums.swift.org/t/swift-6-0-release-process/70220
В Swift 6.0 уже реализованые следующие фичи:
1 SE-0422Expression macro as caller-side default argument
Использование макросов как аргументов по умолчанию в функциях
2 SE-0421Generalize effect polymorphism for AsyncSequence and AsyncIteratorProtocol
Обобщение полиморфизма AsyncSequence и AsyncIteratorProtocol. Добавляется новый ассоциированный тип Failure, поддержка параметров Element и Failure добавляется к методам, например, next()
3. SE-0420Inheritance of actor isolation
Наследование изоляции акторов
#isolated аргументы могут поддерживать опциональный тип
Аргумент по умолчанию #isolated:
4. SE-0418Inferring Sendable for methods and key path literals
Применение Sendable к методам (включая частичные и неимплементированные) и key-path литералам
5. SE-0416Subtyping for keypath literals as functions
Преобразование key-path литералов как функций
Например
В Swift 6.0 уже реализованые следующие фичи:
1 SE-0422Expression macro as caller-side default argument
Использование макросов как аргументов по умолчанию в функциях
// in MyLibrary.swift =======
@freestanding(expression)
macro MyFileID<T: ExpressibleByStringLiteral>() -> T = ...
public func callSiteFile(_ file: String = #MyFileID) { file }
public func declarationSiteFile(_ file: String = (#MyFileID)) { file }
public func alsoDeclarationSiteFile(
file: String = callSiteFile(#MyFileID)
) { file }
// in main.swift ============
print(callSiteFile()) // print main.swift, the current file
print(declarationSiteFile()) // always prints MyLibrary.swift
print(alsoDeclarationSiteFile()) // always prints MyLibrary.swift
2 SE-0421Generalize effect polymorphism for AsyncSequence and AsyncIteratorProtocol
Обобщение полиморфизма AsyncSequence и AsyncIteratorProtocol. Добавляется новый ассоциированный тип Failure, поддержка параметров Element и Failure добавляется к методам, например, next()
@available(SwiftStdlib 5.1, *)
protocol AsyncIteratorProtocol<Element, Failure> {
associatedtype Element
mutating func next() async throws -> Element?
@available(SwiftStdlib 6.0, *)
associatedtype Failure: Error = any Error
@available(SwiftStdlib 6.0, *)
mutating func next(isolation actor: isolated (any Actor)?) async throws(Failure) -> Element?
}
@available(SwiftStdlib 5.1, *)
public protocol AsyncSequence<Element, Failure> {
associatedtype AsyncIterator: AsyncIteratorProtocol
associatedtype Element where AsyncIterator.Element == Element
@available(SwiftStdlib 6.0, *)
associatedtype Failure = AsyncIterator.Failure where AsyncIterator.Failure == Failure
func makeAsyncIterator() -> AsyncIterator
}
3. SE-0420Inheritance of actor isolation
Наследование изоляции акторов
#isolated аргументы могут поддерживать опциональный тип
Аргумент по умолчанию #isolated:
extension AsyncIteratorProtocol {
func next(isolation: isolated (any Actor)? = #isolation) async -> Element {
...
}
}
4. SE-0418Inferring Sendable for methods and key path literals
Применение Sendable к методам (включая частичные и неимплементированные) и key-path литералам
5. SE-0416Subtyping for keypath literals as functions
Преобразование key-path литералов как функций
Например
// You write this:
let f: (User) -> String? = \User.email
// The compiler generates something like this:
let f: (User) -> String? = { kp in { root in root[keyPath: kp] } }(\User.email)
GitHub
swift-evolution/proposals/0422-caller-side-default-argument-macro-expression.md at main · swiftlang/swift-evolution
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swiftlang/swift-evolution