diff --git a/Sources/SymbolKit/SymbolGraph/Symbol/Swift/GenericConstraint.swift b/Sources/SymbolKit/SymbolGraph/Symbol/Swift/GenericConstraint.swift index de120b2..83d7b72 100644 --- a/Sources/SymbolKit/SymbolGraph/Symbol/Swift/GenericConstraint.swift +++ b/Sources/SymbolKit/SymbolGraph/Symbol/Swift/GenericConstraint.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2021-2023 Apple Inc. and the Swift project authors + Copyright (c) 2021-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -46,6 +46,17 @@ extension SymbolGraph.Symbol.Swift { ``` */ case sameType + + /** + A same-shape constraint, such as: + + ```swift + public func function( + _: (repeat (each Element0, each Element1)) + ) { } + ``` + */ + case sameShape } enum CodingKeys: String, CodingKey { diff --git a/Tests/SymbolKitTests/SymbolGraph/Symbol/Swift/GenericConstraintTests.swift b/Tests/SymbolKitTests/SymbolGraph/Symbol/Swift/GenericConstraintTests.swift index 8c17af3..b62584f 100644 --- a/Tests/SymbolKitTests/SymbolGraph/Symbol/Swift/GenericConstraintTests.swift +++ b/Tests/SymbolKitTests/SymbolGraph/Symbol/Swift/GenericConstraintTests.swift @@ -1,7 +1,7 @@ /* This source file is part of the Swift.org open source project - Copyright (c) 2023 Apple Inc. and the Swift project authors + Copyright (c) 2023-2025 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -66,4 +66,22 @@ class GenericConstraintTests: XCTestCase { ) XCTAssertEqual(jsonConstraint, constraint) } + + func testInitializeSameShape() throws { + let jsonString = """ + { + "kind": "sameShape", + "lhs": "T1", + "rhs": "T2", + } + """ + let jsonData = Data(jsonString.utf8) + let jsonConstraint = try JSONDecoder().decode(SymbolGraph.Symbol.Swift.GenericConstraint.self, from: jsonData) + let constraint = SymbolGraph.Symbol.Swift.GenericConstraint( + kind: .sameShape, + leftTypeName: "T1", + rightTypeName: "T2" + ) + XCTAssertEqual(jsonConstraint, constraint) + } }