Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -46,6 +46,17 @@ extension SymbolGraph.Symbol.Swift {
```
*/
case sameType

/**
A same-shape constraint, such as:

```swift
public func function<each Element0, each Element1>(
_: (repeat (each Element0, each Element1))
) { }
```
*/
case sameShape
}

enum CodingKeys: String, CodingKey {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
}
}