Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .spi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [CodableMacroPlugin, MetaCodable]
- documentation_targets: [MetaCodable, HelperCoders]
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
"editor.unicodeHighlight.allowedCharacters": {
"-": true
},
"swift.disableAutoResolve": true,
"swift.swiftEnvironmentVariables": {
"SWIFT_SYNTAX_EXTENSION_MACRO_FIXED": "true"
},
}
16 changes: 16 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,19 @@ let package = Package(
),
]
)

if Context.environment["SWIFT_SYNTAX_EXTENSION_MACRO_FIXED"] != nil {
package.dependencies.remove(at: 0)
package.dependencies.append(
.package(
url: "https://github.com/soumyamahunt/swift-syntax.git",
branch: "extension-macro-assert-fix"
)
)

package.targets.forEach { target in
var settings = target.swiftSettings ?? []
settings.append(.define("SWIFT_SYNTAX_EXTENSION_MACRO_FIXED"))
target.swiftSettings = settings
}
}
22 changes: 12 additions & 10 deletions Tests/MetaCodableTests/CodableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ final class CodableTests: XCTestCase {
case value = "value"
}
}
"""
""",
conformsTo: ["Codable": ["Decodable"]]
)
}

Expand Down Expand Up @@ -142,7 +143,8 @@ final class CodableTests: XCTestCase {
case value = "value"
}
}
"""
""",
conformsTo: ["Codable": ["Encodable"]]
)
}

Expand Down Expand Up @@ -173,7 +175,8 @@ final class CodableTests: XCTestCase {
func encode(to encoder: Encoder) throws {
}
}
"""
""",
conformsTo: ["Codable": []]
)
}
}
Expand All @@ -182,6 +185,9 @@ func assertMacroExpansion(
_ originalSource: String,
expandedSource: String,
diagnostics: [DiagnosticSpec] = [],
conformsTo conformanceMap: [String: [TypeSyntax]] = [
"Codable": ["Decodable", "Encodable"]
],
testModuleName: String = "TestModule",
testFileName: String = "test.swift",
indentationWidth: Trivia = .spaces(4),
Expand All @@ -204,6 +210,7 @@ func assertMacroExpansion(
"CodingKeys": CodingKeys.self,
"IgnoreCodingInitialized": IgnoreCodingInitialized.self,
],
conformsTo: conformanceMap,
testModuleName: testModuleName, testFileName: testFileName,
indentationWidth: indentationWidth,
file: file, line: line
Expand All @@ -221,14 +228,9 @@ extension DiagnosticSpec {
return .init(
id: MessageID(
domain: "SwiftSyntaxMacroExpansion",
id: "accessorMacroOnVariableWithMultipleBindings"
id: "peerMacroOnVariableWithMultipleBindings"
),
message:
"swift-syntax applies macros syntactically and"
+ " there is no way to represent a variable declaration"
+ " with multiple bindings that have accessors syntactically."
+ " While the compiler allows this expansion,"
+ " swift-syntax cannot represent it and thus disallows it.",
message: "peer macro can only be applied to a single variable",
line: line, column: column
)
}
Expand Down
11 changes: 1 addition & 10 deletions Tests/MetaCodableTests/CodedAtTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,7 @@ final class CodedAtTests: XCTestCase {
}
""",
diagnostics: [
.multiBinding(line: 2, column: 5),
.init(
id: CodedAt.misuseID,
message:
"@CodedAt can't be used with grouped variables declaration",
line: 2, column: 5,
fixIts: [
.init(message: "Remove @CodedAt attribute")
]
),
.multiBinding(line: 2, column: 5)
]
)
}
Expand Down
15 changes: 5 additions & 10 deletions Tests/MetaCodableTests/GroupedMutableVariableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ final class GroupedMutableVariableTests: XCTestCase {
case three = "three"
}
}
""",
diagnostics: [.multiBinding(line: 4, column: 5)]
"""
)
}

Expand Down Expand Up @@ -106,8 +105,7 @@ final class GroupedMutableVariableTests: XCTestCase {
case three = "three"
}
}
""",
diagnostics: [.multiBinding(line: 4, column: 5)]
"""
)
}

Expand Down Expand Up @@ -199,8 +197,7 @@ final class GroupedMutableVariableTests: XCTestCase {
case three = "three"
}
}
""",
diagnostics: [.multiBinding(line: 4, column: 5)]
"""
)
}

Expand Down Expand Up @@ -255,8 +252,7 @@ final class GroupedMutableVariableTests: XCTestCase {
case three = "three"
}
}
""",
diagnostics: [.multiBinding(line: 4, column: 5)]
"""
)
}

Expand Down Expand Up @@ -311,8 +307,7 @@ final class GroupedMutableVariableTests: XCTestCase {
case three = "three"
}
}
""",
diagnostics: [.multiBinding(line: 4, column: 5)]
"""
)
}
}
Expand Down
15 changes: 5 additions & 10 deletions Tests/MetaCodableTests/GroupedVariableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ final class GroupedVariableTests: XCTestCase {
case three = "three"
}
}
""",
diagnostics: [.multiBinding(line: 4, column: 5)]
"""
)
}

Expand Down Expand Up @@ -97,8 +96,7 @@ final class GroupedVariableTests: XCTestCase {
case two = "two"
}
}
""",
diagnostics: [.multiBinding(line: 4, column: 5)]
"""
)
}

Expand Down Expand Up @@ -186,8 +184,7 @@ final class GroupedVariableTests: XCTestCase {
case three = "three"
}
}
""",
diagnostics: [.multiBinding(line: 4, column: 5)]
"""
)
}

Expand Down Expand Up @@ -233,8 +230,7 @@ final class GroupedVariableTests: XCTestCase {
case three = "three"
}
}
""",
diagnostics: [.multiBinding(line: 4, column: 5)]
"""
)
}

Expand Down Expand Up @@ -280,8 +276,7 @@ final class GroupedVariableTests: XCTestCase {
case three = "three"
}
}
""",
diagnostics: [.multiBinding(line: 4, column: 5)]
"""
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"scripts": {
"build": "npm exec --package=swiftylab-ci -- build.js",
"test": "npm exec --package=swiftylab-ci -- test.js",
"test": "SWIFT_SYNTAX_EXTENSION_MACRO_FIXED=true npm exec --package=swiftylab-ci -- test.js",
"archive": "echo implement",
"generate": "echo implement",
"format": "npm exec --package=swiftylab-ci -- format.js",
Expand Down