From 3413b195fc1a41c61f59445b2826cfae44fd8dd5 Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Sat, 27 Aug 2022 07:31:21 -0700 Subject: [PATCH 1/2] Remove dependency on implicit opening of existentials --- .../SwiftParser/Diagnostics/ParseDiagnosticsGenerator.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftParser/Diagnostics/ParseDiagnosticsGenerator.swift b/Sources/SwiftParser/Diagnostics/ParseDiagnosticsGenerator.swift index 9a8b0bc0582..eacd19a22c9 100644 --- a/Sources/SwiftParser/Diagnostics/ParseDiagnosticsGenerator.swift +++ b/Sources/SwiftParser/Diagnostics/ParseDiagnosticsGenerator.swift @@ -53,7 +53,9 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor { super.init(viewMode: .all) } - public static func diagnostics(for tree: SyntaxProtocol) -> [Diagnostic] { + public static func diagnostics( + for tree: SyntaxType + ) -> [Diagnostic] { let diagProducer = ParseDiagnosticsGenerator() diagProducer.walk(tree) return diagProducer.diagnostics From 52635d1338f7b96d84bb05983a568d553aa08c81 Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Sat, 27 Aug 2022 07:40:32 -0700 Subject: [PATCH 2/2] Add type annotations so Swift 5.5 can build the parser recovery tests --- Tests/SwiftParserTest/RecoveryTests.swift | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Tests/SwiftParserTest/RecoveryTests.swift b/Tests/SwiftParserTest/RecoveryTests.swift index a274885ac04..293f06ec5ca 100644 --- a/Tests/SwiftParserTest/RecoveryTests.swift +++ b/Tests/SwiftParserTest/RecoveryTests.swift @@ -267,10 +267,11 @@ public class RecoveryTests: XCTestCase { var source = """ (first second third struct: Int) """ - let (_, currentToken) = source.withUTF8 { buffer in - var parser = Parser(buffer) - return (parser.parseFunctionSignature(), parser.currentToken) - } + let (_, currentToken): (RawFunctionSignatureSyntax, Lexer.Lexeme) = + source.withUTF8 { buffer in + var parser = Parser(buffer) + return (parser.parseFunctionSignature(), parser.currentToken) + } // The 'struct' keyword should be taken as an indicator that a new decl // starts here, so `parseFunctionSignature` shouldn't eat it. @@ -334,10 +335,11 @@ public class RecoveryTests: XCTestCase { (first second third : Int) """ - let (_, currentToken) = source.withUTF8 { buffer in - var parser = Parser(buffer) - return (parser.parseFunctionSignature(), parser.currentToken) - } + let (_, currentToken): (RawFunctionSignatureSyntax, Lexer.Lexeme) = + source.withUTF8 { buffer in + var parser = Parser(buffer) + return (parser.parseFunctionSignature(), parser.currentToken) + } XCTAssertEqual(currentToken.tokenKind, .colon) }