Skip to content

Commit 01d6e85

Browse files
authored
Merge pull request #42 from p-x9/feature/swift-syntax-510
Support `swift-syntax` version 510.0.0
2 parents 7988b0e + e8f2247 commit 01d6e85

File tree

4 files changed

+50
-47
lines changed

4 files changed

+50
-47
lines changed

Package.resolved

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
"kind" : "remoteSourceControl",
66
"location" : "https://github.com/p-x9/swift-literal-type-inference.git",
77
"state" : {
8-
"revision" : "d4c97a7e48d3fab0c4575641c9a257602c1d17b7",
9-
"version" : "0.1.0"
8+
"revision" : "4de2706aee972bc87e1723578b75fa403fc779dd",
9+
"version" : "0.2.0"
1010
}
1111
},
1212
{
1313
"identity" : "swift-macro-testing",
1414
"kind" : "remoteSourceControl",
1515
"location" : "https://github.com/pointfreeco/swift-macro-testing.git",
1616
"state" : {
17-
"revision" : "10dcef36314ddfea6f60442169b0b320204cbd35",
18-
"version" : "0.2.2"
17+
"revision" : "5c4a1b9d7c23cd5c08ea50677d8e89080365cb00",
18+
"version" : "0.4.0"
1919
}
2020
},
2121
{
@@ -32,17 +32,17 @@
3232
"kind" : "remoteSourceControl",
3333
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
3434
"state" : {
35-
"revision" : "8e68404f641300bfd0e37d478683bb275926760c",
36-
"version" : "1.15.2"
35+
"revision" : "625ccca8570773dd84a34ee51a81aa2bc5a4f97a",
36+
"version" : "1.16.0"
3737
}
3838
},
3939
{
4040
"identity" : "swift-syntax",
4141
"kind" : "remoteSourceControl",
4242
"location" : "https://github.com/apple/swift-syntax.git",
4343
"state" : {
44-
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
45-
"version" : "509.0.0"
44+
"revision" : "fa8f95c2d536d6620cc2f504ebe8a6167c9fc2dd",
45+
"version" : "510.0.1"
4646
}
4747
}
4848
],

Package.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ let package = Package(
1818
dependencies: [
1919
.package(
2020
url: "https://github.com/apple/swift-syntax.git",
21-
from: "509.0.0"
21+
"509.0.0"..<"511.0.0"
2222
),
2323
.package(
2424
url: "https://github.com/p-x9/swift-literal-type-inference.git",
25-
from: "0.1.0"
25+
from: "0.2.0"
2626
),
2727
.package(
2828
url: "https://github.com/p-x9/swift-object-association.git",
2929
from: "0.5.0"
3030
),
3131
.package(
3232
url: "https://github.com/pointfreeco/swift-macro-testing.git",
33-
from: "0.2.2"
33+
from: "0.3.0"
3434
)
3535

3636
],

Tests/AssociatedObjectTests/AssociatedObjectTests.swift

+20-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import SwiftSyntaxMacros
33
import SwiftSyntaxMacrosTestSupport
44
import MacroTesting
55

6-
#if canImport(AssociatedObjectPlugin)
6+
// Note:
7+
// Prior to version 510, if an initial value was set in AccessorMacro, it was left in place and expanded.
8+
// Therefore, the following test will always fail when run on version 509. Therefore, the following tests are excluded from execution.
9+
#if canImport(AssociatedObjectPlugin) && canImport(SwiftSyntax510)
710
@testable import AssociatedObjectPlugin
811
@testable import AssociatedObject
912

@@ -26,7 +29,7 @@ final class AssociatedObjectTests: XCTestCase {
2629
"""
2730
} expansion: {
2831
"""
29-
var string: String = "text" {
32+
var string: String {
3033
get {
3134
if let value = getAssociatedObject(
3235
self,
@@ -71,7 +74,7 @@ final class AssociatedObjectTests: XCTestCase {
7174
"""
7275
} expansion: {
7376
"""
74-
var int: Int = 5 {
77+
var int: Int {
7578
get {
7679
if let value = getAssociatedObject(
7780
self,
@@ -116,7 +119,7 @@ final class AssociatedObjectTests: XCTestCase {
116119
"""
117120
} expansion: {
118121
"""
119-
var float: Float = 5.0 {
122+
var float: Float {
120123
get {
121124
if let value = getAssociatedObject(
122125
self,
@@ -161,7 +164,7 @@ final class AssociatedObjectTests: XCTestCase {
161164
"""
162165
} expansion: {
163166
"""
164-
var double: Double = 5.0 {
167+
var double: Double {
165168
get {
166169
if let value = getAssociatedObject(
167170
self,
@@ -206,7 +209,7 @@ final class AssociatedObjectTests: XCTestCase {
206209
"""
207210
} expansion: {
208211
"""
209-
var string: String = "text" {
212+
var string: String {
210213
get {
211214
if let value = getAssociatedObject(
212215
self,
@@ -356,7 +359,7 @@ final class AssociatedObjectTests: XCTestCase {
356359
"""
357360
} expansion: {
358361
"""
359-
var string: String? = "hello" {
362+
var string: String? {
360363
get {
361364
if !self.__associated_stringIsSet {
362365
let value: String? = "hello"
@@ -410,7 +413,7 @@ final class AssociatedObjectTests: XCTestCase {
410413
"""
411414
} expansion: {
412415
"""
413-
var bool: Bool = false {
416+
var bool: Bool {
414417
get {
415418
if let value = getAssociatedObject(
416419
self,
@@ -455,7 +458,7 @@ final class AssociatedObjectTests: XCTestCase {
455458
"""
456459
} expansion: {
457460
"""
458-
var intArray: [Int] = [1, 2, 3] {
461+
var intArray: [Int] {
459462
get {
460463
if let value = getAssociatedObject(
461464
self,
@@ -535,7 +538,7 @@ final class AssociatedObjectTests: XCTestCase {
535538
"""
536539
} expansion: {
537540
"""
538-
var dic: [String: String] = ["t": "a"] {
541+
var dic: [String: String] {
539542
get {
540543
if let value = getAssociatedObject(
541544
self,
@@ -585,7 +588,7 @@ final class AssociatedObjectTests: XCTestCase {
585588
"""
586589
} expansion: {
587590
"""
588-
var string: String = "text" {
591+
var string: String {
589592
willSet {
590593
print("willSet: old", string)
591594
print("willSet: new", newValue)
@@ -645,7 +648,7 @@ final class AssociatedObjectTests: XCTestCase {
645648
"""
646649
} expansion: {
647650
"""
648-
var string: String = "text" {
651+
var string: String {
649652
didSet {
650653
print("didSet: old", oldValue)
651654
}
@@ -708,7 +711,7 @@ final class AssociatedObjectTests: XCTestCase {
708711
"""
709712
} expansion: {
710713
"""
711-
var string: String = "text" {
714+
var string: String {
712715
willSet {
713716
print("willSet: old", string)
714717
print("willSet: new", newValue)
@@ -778,7 +781,7 @@ final class AssociatedObjectTests: XCTestCase {
778781
"""
779782
} expansion: {
780783
"""
781-
var string: String = "text" {
784+
var string: String {
782785
willSet(new) {
783786
print("willSet: old", string)
784787
print("willSet: new", new)
@@ -838,7 +841,7 @@ final class AssociatedObjectTests: XCTestCase {
838841
"""
839842
} expansion: {
840843
"""
841-
var string: String = "text" {
844+
var string: String {
842845
didSet(old) {
843846
print("didSet: old", old)
844847
}
@@ -893,7 +896,7 @@ final class AssociatedObjectTests: XCTestCase {
893896
"""
894897
} expansion: {
895898
"""
896-
var string: String = "text" {
899+
var string: String {
897900
get {
898901
if let value = getAssociatedObject(
899902
self,
@@ -1026,7 +1029,7 @@ extension AssociatedObjectTests {
10261029
"""
10271030
} expansion: {
10281031
"""
1029-
var string: String = "text" {
1032+
var string: String {
10301033
get {
10311034
if let value = getAssociatedObject(
10321035
self,

Tests/AssociatedObjectTests/AssociatedTypeDetectionObjectTests.swift

+19-19
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import SwiftSyntaxMacros
1111
import SwiftSyntaxMacrosTestSupport
1212
import MacroTesting
1313

14-
#if canImport(AssociatedObjectPlugin)
14+
#if canImport(AssociatedObjectPlugin) && canImport(SwiftSyntax510)
1515
@testable import AssociatedObjectPlugin
1616
@testable import AssociatedObject
1717

@@ -38,7 +38,7 @@ extension AssociatedTypeDetectionObjectTests {
3838
"""
3939
} expansion: {
4040
"""
41-
var int = 10 {
41+
var int {
4242
get {
4343
if let value = getAssociatedObject(
4444
self,
@@ -83,7 +83,7 @@ extension AssociatedTypeDetectionObjectTests {
8383
"""
8484
} expansion: {
8585
"""
86-
var double = 10.0 {
86+
var double {
8787
get {
8888
if let value = getAssociatedObject(
8989
self,
@@ -128,7 +128,7 @@ extension AssociatedTypeDetectionObjectTests {
128128
"""
129129
} expansion: {
130130
"""
131-
var string = "text" {
131+
var string {
132132
get {
133133
if let value = getAssociatedObject(
134134
self,
@@ -173,7 +173,7 @@ extension AssociatedTypeDetectionObjectTests {
173173
"""
174174
} expansion: {
175175
"""
176-
var bool = false {
176+
var bool {
177177
get {
178178
if let value = getAssociatedObject(
179179
self,
@@ -221,7 +221,7 @@ extension AssociatedTypeDetectionObjectTests {
221221
"""
222222
} expansion: {
223223
"""
224-
var intArray = [1, 2, 3] {
224+
var intArray {
225225
get {
226226
if let value = getAssociatedObject(
227227
self,
@@ -266,7 +266,7 @@ extension AssociatedTypeDetectionObjectTests {
266266
"""
267267
} expansion: {
268268
"""
269-
var doubleArray = [1.0, 2.0, 3.0] {
269+
var doubleArray {
270270
get {
271271
if let value = getAssociatedObject(
272272
self,
@@ -311,7 +311,7 @@ extension AssociatedTypeDetectionObjectTests {
311311
"""
312312
} expansion: {
313313
"""
314-
var doubleArray = [1, 1.0, 2, 2.0, 3, 3.0] {
314+
var doubleArray {
315315
get {
316316
if let value = getAssociatedObject(
317317
self,
@@ -356,7 +356,7 @@ extension AssociatedTypeDetectionObjectTests {
356356
"""
357357
} expansion: {
358358
"""
359-
var boolArray = [true, false] {
359+
var boolArray {
360360
get {
361361
if let value = getAssociatedObject(
362362
self,
@@ -401,7 +401,7 @@ extension AssociatedTypeDetectionObjectTests {
401401
"""
402402
} expansion: {
403403
"""
404-
var stringArray = ["1.0", "2.0", "3.0"] {
404+
var stringArray {
405405
get {
406406
if let value = getAssociatedObject(
407407
self,
@@ -449,7 +449,7 @@ extension AssociatedTypeDetectionObjectTests {
449449
"""
450450
} expansion: {
451451
"""
452-
var optionalIntArray = [1, 1, nil, 2, 3, nil] {
452+
var optionalIntArray {
453453
get {
454454
if let value = getAssociatedObject(
455455
self,
@@ -494,7 +494,7 @@ extension AssociatedTypeDetectionObjectTests {
494494
"""
495495
} expansion: {
496496
"""
497-
var optionalDoubleArray = [1.0, 2.0, 3.0, nil] {
497+
var optionalDoubleArray {
498498
get {
499499
if let value = getAssociatedObject(
500500
self,
@@ -539,7 +539,7 @@ extension AssociatedTypeDetectionObjectTests {
539539
"""
540540
} expansion: {
541541
"""
542-
var doubleArray = [nil, 1, 1.0, nil, 2, 2.0, nil, 3, 3.0] {
542+
var doubleArray {
543543
get {
544544
if let value = getAssociatedObject(
545545
self,
@@ -585,7 +585,7 @@ extension AssociatedTypeDetectionObjectTests {
585585
"""
586586
} expansion: {
587587
"""
588-
var optionalBoolArray = [true, false, nil] {
588+
var optionalBoolArray {
589589
get {
590590
if let value = getAssociatedObject(
591591
self,
@@ -630,7 +630,7 @@ extension AssociatedTypeDetectionObjectTests {
630630
"""
631631
} expansion: {
632632
"""
633-
var optionalStringArray = [nil, "true", "false", nil] {
633+
var optionalStringArray {
634634
get {
635635
if let value = getAssociatedObject(
636636
self,
@@ -678,7 +678,7 @@ extension AssociatedTypeDetectionObjectTests {
678678
"""
679679
} expansion: {
680680
"""
681-
var dic = ["t": "a", "s": "b"] {
681+
var dic {
682682
get {
683683
if let value = getAssociatedObject(
684684
self,
@@ -723,7 +723,7 @@ extension AssociatedTypeDetectionObjectTests {
723723
"""
724724
} expansion: {
725725
"""
726-
var dic = [1: 3, 2: 4] {
726+
var dic {
727727
get {
728728
if let value = getAssociatedObject(
729729
self,
@@ -768,7 +768,7 @@ extension AssociatedTypeDetectionObjectTests {
768768
"""
769769
} expansion: {
770770
"""
771-
var dic = [1.0: 3.0, 2.0: 4.0] {
771+
var dic {
772772
get {
773773
if let value = getAssociatedObject(
774774
self,
@@ -817,7 +817,7 @@ extension AssociatedTypeDetectionObjectTests {
817817
"""
818818
} expansion: {
819819
"""
820-
var array = [[1.0], [2.0], [3.0, 4.0]] {
820+
var array {
821821
get {
822822
if let value = getAssociatedObject(
823823
self,

0 commit comments

Comments
 (0)