Skip to content

Commit 13c1352

Browse files
committed
1 parent 251f4a1 commit 13c1352

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/Generics/sr12980.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
2+
3+
protocol VectorIndex : CaseIterable {}
4+
5+
protocol Vector {
6+
associatedtype Element
7+
associatedtype Index: VectorIndex
8+
subscript(index: Index) -> Element { get set }
9+
init(_ indexToElementMapping: (Index) -> Element)
10+
}
11+
12+
// CHECK: ExtensionDecl line={{.*}} base=Vector
13+
// CHECK-NEXT: Generic signature: <Self where Self : Vector, Self.[Vector]Element : Vector, Self.[Vector]Index == Self.[Vector]Element.[Vector]Index, Self.[Vector]Element.[Vector]Element : BinaryFloatingPoint>
14+
15+
// Some methods for square matrices:
16+
extension Vector where
17+
Self.Element: Vector,
18+
Self.Index == Self.Element.Index,
19+
Self.Element.Element: BinaryFloatingPoint
20+
{
21+
func row(_ index: Index) -> Element { self[index] }
22+
23+
func column(_ index: Index) -> Element { Element { self[$0][index] } }
24+
}

0 commit comments

Comments
 (0)