branch: elpa/swift-mode commit 3f22042ca99f7351d3dae43341f56a064467d837 Author: taku0 <mxxouy6x3m_git...@tatapa.org> Commit: taku0 <mxxouy6x3m_git...@tatapa.org>
Support existential any https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md --- swift-mode-font-lock.el | 4 ++-- swift-mode-lexer.el | 4 ++-- test/swift-files/font-lock/font-lock.swift | 2 ++ test/swift-files/indent/declarations.swift | 17 +++++++++++++++++ test/swift-files/indent/identifiers.swift | 3 +++ 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/swift-mode-font-lock.el b/swift-mode-font-lock.el index c0e1dd7fa6..d0cfefab56 100644 --- a/swift-mode-font-lock.el +++ b/swift-mode-font-lock.el @@ -541,8 +541,8 @@ Return nil otherwise." (defconst swift-mode:declaration-keywords '("associatedtype" "class" "deinit" "enum" "extension" "fileprivate" "func" "import" "init" "inout" "internal" "let" "open" "operator" "private" - "protocol" "public" "some" "static" "struct" "subscript" "typealias" "var" - "actor" "nonisolated" "isolated") + "protocol" "public" "any" "some" "static" "struct" "subscript" "typealias" + "var" "actor" "nonisolated" "isolated") "Keywords used in declarations.") (defconst swift-mode:statement-keywords diff --git a/swift-mode-lexer.el b/swift-mode-lexer.el index 6c91d4b41c..9d25ab34f5 100644 --- a/swift-mode-lexer.el +++ b/swift-mode-lexer.el @@ -431,9 +431,9 @@ Return nil otherwise." ;; Suppress implicit semicolon around keywords that cannot start or end ;; statements. (member (swift-mode:token:text previous-token) - '("some" "inout" "in" "where" "isolated")) + '("any" "some" "inout" "in" "where" "isolated")) (member (swift-mode:token:text next-token) - '("some" "inout" "throws" "rethrows" "in" "where" + '("any" "some" "inout" "throws" "rethrows" "in" "where" "isolated"))) nil) diff --git a/test/swift-files/font-lock/font-lock.swift b/test/swift-files/font-lock/font-lock.swift index a349ddb763..5ba4c3e665 100644 --- a/test/swift-files/font-lock/font-lock.swift +++ b/test/swift-files/font-lock/font-lock.swift @@ -59,3 +59,5 @@ enum Foo: Error { .foo } // #("enum Foo: Error { .foo }" 0 4 (face swift-mode:ke func foo() { // #("func foo() {" 0 4 (face swift-mode:keyword-face) 5 8 (face swift-mode:function-name-face)) foo() // #(" foo()" 4 7 (face swift-mode:function-call-face)) } + +let pq: any P & Q = S() // #("let pq: any P & Q = S()" 0 3 (face swift-mode:keyword-face) 8 11 (face swift-mode:keyword-face) 20 21 (face swift-mode:function-call-face)) diff --git a/test/swift-files/indent/declarations.swift b/test/swift-files/indent/declarations.swift index 30a96363d9..d7515a5850 100644 --- a/test/swift-files/indent/declarations.swift +++ b/test/swift-files/indent/declarations.swift @@ -749,3 +749,20 @@ func foo(f: @escaping (Int, Int) async -> Int, t: (Int, Int)) async { async let c = 1 } + +// any + +let + pq + : + any + P + & + Q + = + S() + +let values: [ + any + Any +] = [] diff --git a/test/swift-files/indent/identifiers.swift b/test/swift-files/indent/identifiers.swift index db87d1a56b..481bf23682 100644 --- a/test/swift-files/indent/identifiers.swift +++ b/test/swift-files/indent/identifiers.swift @@ -106,6 +106,9 @@ func foo() { foo( var: 1 ) + foo( + any: 1 + ) foo( some: 1 )