diff --git a/Sources/Splash/Grammar/SwiftGrammar.swift b/Sources/Splash/Grammar/SwiftGrammar.swift index 40b47d9..87d468d 100644 --- a/Sources/Splash/Grammar/SwiftGrammar.swift +++ b/Sources/Splash/Grammar/SwiftGrammar.swift @@ -52,7 +52,7 @@ private extension SwiftGrammar { "lazy", "subscript", "defer", "inout", "while", "continue", "fallthrough", "repeat", "indirect", "deinit", "is", "#file", "#line", "#function", - "dynamic" + "dynamic", "some" ] as Set).union(accessControlKeywords) static let accessControlKeywords: Set = [ diff --git a/Tests/SplashTests/Tests/DeclarationTests.swift b/Tests/SplashTests/Tests/DeclarationTests.swift index 80df6eb..f7c5f1d 100644 --- a/Tests/SplashTests/Tests/DeclarationTests.swift +++ b/Tests/SplashTests/Tests/DeclarationTests.swift @@ -858,6 +858,31 @@ final class DeclarationTests: SyntaxHighlighterTestCase { ]) } + func testFunctionDeclarationWithOpaqueReturnType() { + let components = highlighter.highlight(#"func make() -> some View { Text("!") }"#) + + XCTAssertEqual(components, [ + .token("func", .keyword), + .whitespace(" "), + .plainText("make()"), + .whitespace(" "), + .plainText("->"), + .whitespace(" "), + .token("some", .keyword), + .whitespace(" "), + .token("View", .type), + .whitespace(" "), + .plainText("{"), + .whitespace(" "), + .token("Text", .type), + .plainText("("), + .token(#""!""#, .string), + .plainText(")"), + .whitespace(" "), + .plainText("}") + ]) + } + func testIndirectEnumDeclaration() { let components = highlighter.highlight(""" indirect enum Content { @@ -934,6 +959,7 @@ extension DeclarationTests { ("testFunctionDeclarationWithPreProcessors", testFunctionDeclarationWithPreProcessors), ("testNonMutatingFunction", testNonMutatingFunction), ("testRethrowingFunctionDeclaration", testRethrowingFunctionDeclaration), + ("testFunctionDeclarationWithOpaqueReturnType", testFunctionDeclarationWithOpaqueReturnType), ("testIndirectEnumDeclaration", testIndirectEnumDeclaration) ] }