Skip to content

Commit

Permalink
Merge pull request #127 from Matejkob/swift-6
Browse files Browse the repository at this point in the history
Add Support for Swift 6.0
  • Loading branch information
Matejkob authored Nov 30, 2024
2 parents 371c050 + 07ae071 commit 2771a33
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
strategy:
matrix:
xcode:
- '16.1'
- '16.0'
- '15.4'
package:
Expand Down
4 changes: 2 additions & 2 deletions Examples/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax",
"state" : {
"revision" : "303e5c5c36d6a558407d364878df131c3546fad8",
"version" : "510.0.2"
"revision" : "0687f71944021d616d34d922343dcef086855920",
"version" : "600.0.1"
}
}
],
Expand Down
38 changes: 38 additions & 0 deletions Examples/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// swift-tools-version: 6.0

import PackageDescription

let package = Package(
name: "Examples",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
.macCatalyst(.v13),
],
products: [
.library(
name: "Examples",
targets: ["Examples"]
)
],
dependencies: [
.package(name: "swift-spyable", path: "../")
],
targets: [
.target(
name: "Examples",
dependencies: [
.product(name: "Spyable", package: "swift-spyable")
],
path: "Sources"
),
.testTarget(
name: "ExamplesTests",
dependencies: ["Examples"],
path: "Tests"
),
],
swiftLanguageModes: [.v6]
)
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax",
"state" : {
"revision" : "303e5c5c36d6a558407d364878df131c3546fad8",
"version" : "510.0.2"
"revision" : "0687f71944021d616d34d922343dcef086855920",
"version" : "600.0.1"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"601.0.0-prerelease")
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"601.0.0")
],
targets: [
.macro(
Expand Down
47 changes: 47 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// swift-tools-version: 6.0

import CompilerPluginSupport
import PackageDescription

let package = Package(
name: "swift-spyable",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
.macCatalyst(.v13),
],
products: [
.library(
name: "Spyable",
targets: ["Spyable"]
)
],
dependencies: [
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"601.0.0")
],
targets: [
.macro(
name: "SpyableMacro",
dependencies: [
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
]
),
.target(
name: "Spyable",
dependencies: [
"SpyableMacro"
]
),
.testTarget(
name: "SpyableMacroTests",
dependencies: [
"SpyableMacro",
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
]
),
],
swiftLanguageModes: [.v6]
)
4 changes: 4 additions & 0 deletions Sources/SpyableMacro/Extensions/TypeSyntax+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ extension ArrayTypeSyntax: TypeSyntaxSupportingGenerics {
}
}

#if compiler(>=6.0)
extension GenericArgumentClauseSyntax: @retroactive TypeSyntaxProtocol {}
#endif

extension GenericArgumentClauseSyntax: TypeSyntaxSupportingGenerics {
fileprivate var nestedTypeSyntaxes: [TypeSyntax] {
arguments.map { $0.argument }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ import SwiftSyntaxBuilder
/// - Important: The variable declaration must have exactly one binding. Any deviation from this will result in
/// an error diagnostic produced by the macro.
struct VariablesImplementationFactory {
private let accessorRemovalVisitor = AccessorRemovalVisitor()

@MemberBlockItemListBuilder
func variablesDeclarations(
protocolVariableDeclaration: VariableDeclSyntax
Expand All @@ -60,6 +58,7 @@ struct VariablesImplementationFactory {
if binding.typeAnnotation?.type.is(OptionalTypeSyntax.self) == true
|| binding.typeAnnotation?.type.is(ImplicitlyUnwrappedOptionalTypeSyntax.self) == true
{
let accessorRemovalVisitor = AccessorRemovalVisitor()
accessorRemovalVisitor.visit(protocolVariableDeclaration)
/*
var name: String
Expand Down

0 comments on commit 2771a33

Please sign in to comment.