From 89a925cf061b9cdaf1242676efbd573cff05f9dc Mon Sep 17 00:00:00 2001 From: LiarPrincess <4982138+LiarPrincess@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:04:47 +0100 Subject: [PATCH 1/2] Fix for Swift 6.1 compatibility with `Foundation.Expression`. --- Sources/Compiler/Implementation/CompilerImpl.swift | 3 +++ Tests/CompilerTests/ASTCreator.swift | 3 +++ Tests/CompilerTests/CompileTestCase.swift | 3 +++ Tests/CompilerTests/SymbolTableTestCase.swift | 3 +++ Tests/RapunzelTests/Lyrics.swift | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Sources/Compiler/Implementation/CompilerImpl.swift b/Sources/Compiler/Implementation/CompilerImpl.swift index f4062a6d8..f899eca0d 100644 --- a/Sources/Compiler/Implementation/CompilerImpl.swift +++ b/Sources/Compiler/Implementation/CompilerImpl.swift @@ -15,6 +15,9 @@ internal final class CompilerImpl: ASTVisitor, StatementVisitor, ExpressionVisit internal typealias StatementResult = Void internal typealias ExpressionResult = Void + // For Swift 6.1 compatibility with Foundation. + internal typealias Expression = VioletParser.Expression + /// Program that we are compiling. private let ast: AST /// Name of the file that this code object was loaded from. diff --git a/Tests/CompilerTests/ASTCreator.swift b/Tests/CompilerTests/ASTCreator.swift index d605fa2f9..155f8166f 100644 --- a/Tests/CompilerTests/ASTCreator.swift +++ b/Tests/CompilerTests/ASTCreator.swift @@ -12,6 +12,9 @@ internal protocol ASTCreator {} extension ASTCreator { + // For Swift 6.1 compatibility with Foundation. + typealias Expression = VioletParser.Expression + private var id: ASTNodeId { // We have to increment 'id', because it is used as a key in 'SymbolTable'. let value = _id diff --git a/Tests/CompilerTests/CompileTestCase.swift b/Tests/CompilerTests/CompileTestCase.swift index 033b10074..3b8456a27 100644 --- a/Tests/CompilerTests/CompileTestCase.swift +++ b/Tests/CompilerTests/CompileTestCase.swift @@ -7,6 +7,9 @@ import VioletBytecode /// Base class for all of the compiler tests internal class CompileTestCase: XCTestCase, ASTCreator { + // For Swift 6.1 compatibility with Foundation. + typealias Expression = VioletParser.Expression + internal var builder = ASTBuilder() // MARK: - Compile diff --git a/Tests/CompilerTests/SymbolTableTestCase.swift b/Tests/CompilerTests/SymbolTableTestCase.swift index 51e5e076b..b23eb6c79 100644 --- a/Tests/CompilerTests/SymbolTableTestCase.swift +++ b/Tests/CompilerTests/SymbolTableTestCase.swift @@ -6,6 +6,9 @@ import VioletParser /// Base class for all of the symbol table tests class SymbolTableTestCase: XCTestCase, ASTCreator { + // For Swift 6.1 compatibility with Foundation. + typealias Expression = VioletParser.Expression + var builder = ASTBuilder() // MARK: - Create diff --git a/Tests/RapunzelTests/Lyrics.swift b/Tests/RapunzelTests/Lyrics.swift index 6cc1dee33..3817c920a 100644 --- a/Tests/RapunzelTests/Lyrics.swift +++ b/Tests/RapunzelTests/Lyrics.swift @@ -9,7 +9,7 @@ typealias Lyrics = [Part] // MARK: - Rapunzel -extension Lyrics: RapunzelConvertible { +extension Lyrics: @retroactive RapunzelConvertible { public var doc: Doc { return self.stack() } From 748880d8973257e6cb70ec07a9f6e327a8960aef Mon Sep 17 00:00:00 2001 From: LiarPrincess <4982138+LiarPrincess@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:09:42 +0100 Subject: [PATCH 2/2] Removed `@retroactive` because github CI does not like it --- Tests/RapunzelTests/Lyrics.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/RapunzelTests/Lyrics.swift b/Tests/RapunzelTests/Lyrics.swift index 3817c920a..9231638e7 100644 --- a/Tests/RapunzelTests/Lyrics.swift +++ b/Tests/RapunzelTests/Lyrics.swift @@ -9,7 +9,7 @@ typealias Lyrics = [Part] // MARK: - Rapunzel -extension Lyrics: @retroactive RapunzelConvertible { +extension Lyrics: RapunzelConvertible { public var doc: Doc { return self.stack() } @@ -51,7 +51,7 @@ extension Lyrics { "And it's warm and real and bright", "And the world has somehow shifted", "All at once everything looks different", - "Now that I see you" + "Now that I see you", ] ), @@ -68,7 +68,7 @@ extension Lyrics { "Now she's here shining in the starlight", "Now she's here suddenly I know", "If she's here it's crystal clear", - "I'm where I'm meant to go" + "I'm where I'm meant to go", ] ), Part( @@ -95,9 +95,9 @@ extension Lyrics { "All at once everything is different", "Now that I see you", - "Now that I see you" + "Now that I see you", ] - ) + ), ] } }