Skip to content

Commit 65fa99b

Browse files
add sameShape constraint kind (#103)
rdar://129338238
1 parent 3fc0c68 commit 65fa99b

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

Sources/SymbolKit/SymbolGraph/Symbol/Swift/GenericConstraint.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -46,6 +46,17 @@ extension SymbolGraph.Symbol.Swift {
4646
```
4747
*/
4848
case sameType
49+
50+
/**
51+
A same-shape constraint, such as:
52+
53+
```swift
54+
public func function<each Element0, each Element1>(
55+
_: (repeat (each Element0, each Element1))
56+
) { }
57+
```
58+
*/
59+
case sameShape
4960
}
5061

5162
enum CodingKeys: String, CodingKey {

Tests/SymbolKitTests/SymbolGraph/Symbol/Swift/GenericConstraintTests.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2023 Apple Inc. and the Swift project authors
4+
Copyright (c) 2023-2025 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -66,4 +66,22 @@ class GenericConstraintTests: XCTestCase {
6666
)
6767
XCTAssertEqual(jsonConstraint, constraint)
6868
}
69+
70+
func testInitializeSameShape() throws {
71+
let jsonString = """
72+
{
73+
"kind": "sameShape",
74+
"lhs": "T1",
75+
"rhs": "T2",
76+
}
77+
"""
78+
let jsonData = Data(jsonString.utf8)
79+
let jsonConstraint = try JSONDecoder().decode(SymbolGraph.Symbol.Swift.GenericConstraint.self, from: jsonData)
80+
let constraint = SymbolGraph.Symbol.Swift.GenericConstraint(
81+
kind: .sameShape,
82+
leftTypeName: "T1",
83+
rightTypeName: "T2"
84+
)
85+
XCTAssertEqual(jsonConstraint, constraint)
86+
}
6987
}

0 commit comments

Comments
 (0)