Skip to content

Commit 797805a

Browse files
committed
SILGen: Test lowered generic signatures for decls with contextual where clauses
1 parent 6f08216 commit 797805a

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

test/SILGen/generic_signatures.swift

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-emit-silgen -parse-stdlib %s
1+
// RUN: %target-swift-emit-silgen %s | %FileCheck %s
22

33
protocol P {
44
associatedtype Assoc
@@ -81,3 +81,62 @@ func concreteJungle<T>(_: T, f: @escaping (T.Foo) -> C) -> T.Foo where T : Fooab
8181
let ff: (C) -> T.Foo = f
8282
return ff(C())
8383
}
84+
85+
protocol Whereable {
86+
associatedtype Assoc
87+
associatedtype Bssoc: Whereable
88+
}
89+
extension Whereable {
90+
// CHECK-LABEL sil hidden [ossa] @$s18generic_signatures9WhereablePAAE19staticExtensionFunc3arg7ElementSTQz8IteratorSTQz_tSTRzrlFZ : $@convention(method) <Self where Self : Sequence, Self : Whereable> (@in_guaranteed Self.Iterator, @thick Self.Type) -> @out Self.Element
91+
static func staticExtensionFunc(arg: Self.Iterator) -> Self.Element
92+
where Self: Sequence {
93+
fatalError()
94+
}
95+
96+
// CHECK-LABEL sil hidden [ossa] @$s18generic_signatures9WhereablePAAE13extensionFuncyy5BssocQz5AssocRtzrlF : $@convention(method) <Self where Self : Whereable, Self.Assoc == Self.Bssoc> (@in_guaranteed Self) -> ()
97+
func extensionFunc() where Assoc == Bssoc { }
98+
99+
// CHECK-LABEL sil hidden [ossa] @$s18generic_signatures9WhereablePAAE5AssocQzSgycAabERQAD_5BssocQZAGRtzrluig : $@convention(method) <Self where Self : Whereable, Self.Assoc : Whereable, Self.Bssoc == Self.Assoc.Bssoc> (@in_guaranteed Self) -> @out Optional<Self.Assoc>
100+
subscript() -> Assoc
101+
where Assoc: Whereable, Bssoc == Assoc.Bssoc {
102+
fatalError()
103+
}
104+
105+
// CHECK-LABEL sil hidden [ossa] @$s18generic_signatures9WhereablePAAE5AssocQzSgycAabERQ5Bssoc_ADQZAERSrluig : $@convention(method) <Self where Self : Whereable, Self.Assoc : Whereable, Self.Assoc == Self.Bssoc.Assoc> (@in_guaranteed Self) -> @out Optional<Self.Assoc>
106+
subscript() -> Assoc
107+
where Assoc: Whereable, Assoc == Bssoc.Assoc {
108+
fatalError()
109+
}
110+
}
111+
112+
struct W1 {}
113+
struct W2 {}
114+
115+
class Class<T> {
116+
// CHECK-LABEL: sil hidden [ossa] @$s18generic_signatures5ClassC9classFuncyyAA9WhereableRz5AssocQzRszlFZ : $@convention(method) <T where T : Whereable, T == T.Assoc> (@thick Class<T>.Type) -> ()
117+
class func classFunc() where T: Whereable, T.Assoc == T { }
118+
119+
// CHECK-LABEL: sil hidden [ossa] @$s18generic_signatures5ClassC5func1yyAA7FooableRzlF : $@convention(method) <T where T : Fooable> (@guaranteed Class<T>) -> ()
120+
func func1() where T: Fooable { }
121+
// CHECK-LABEL: sil hidden [ossa] @$s18generic_signatures5ClassC5func2yyAA2W1VRszlF : $@convention(method) (@guaranteed Class<W1>) -> ()
122+
func func2() where T == W1 { }
123+
// CHECK-LABEL: sil hidden [ossa] @$s18generic_signatures5ClassC5func2yyAA2W2VRszlF : $@convention(method) (@guaranteed Class<W2>) -> ()
124+
func func2() where T == W2 { }
125+
126+
// CHECK-LABEL: sil hidden [ossa] @$s18generic_signatures5ClassC5AssocQzycAA9WhereableRzluig : $@convention(method) <T where T : Whereable> (@guaranteed Class<T>) -> @out T.Assoc
127+
subscript() -> T.Assoc where T: Whereable {
128+
fatalError()
129+
}
130+
131+
// CHECK-LABEL: sil hidden [ossa] @$s18generic_signatures5ClassC06NestedC0CAEyx_Gycfc : $@convention(method) <T where T : Fooable> (@owned Class<T>.NestedClass) -> @owned Class<T>.NestedClass
132+
class NestedClass where T: Fooable { }
133+
}
134+
135+
extension Class where T: Whereable {
136+
// CHECK-LABEL: sil hidden [ossa] @$s18generic_signatures5ClassCA2A9WhereableRzlE13extensionFuncyyAA7FooableRzrlF : $@convention(method) <T where T : Fooable, T : Whereable> (@guaranteed Class<T>) -> ()
137+
func extensionFunc() where T: Fooable { }
138+
}
139+
extension Class.NestedClass {
140+
// CHECK-LABEL: sil hidden [ossa] @$s18generic_signatures5ClassC06NestedC0C3foo3argyx_tAA9WhereableRz3FooAA7FooablePQz5AssocAaHPRtzrlF : $@convention(method) <T where T : Fooable, T : Whereable, T.Assoc == T.Foo> (@in_guaranteed T, @guaranteed Class<T>.NestedClass) -> ()
141+
func foo(arg: T) where T: Whereable, T.Foo == T.Assoc { }
142+
}

0 commit comments

Comments
 (0)