Skip to content

Commit 960bbc3

Browse files
committed
Add a test for a SILGen bug that got fixed with recent generics changes
1 parent 0f62e68 commit 960bbc3

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/SILGen/generic_witness.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,34 @@ func bar(_ x: Runcible) {
2222
// CHECK: apply [[METHOD]]<[[OPENED]], Int>
2323
x.runce(5)
2424
}
25+
26+
protocol Color {}
27+
28+
protocol Ink {
29+
associatedtype Paint
30+
}
31+
32+
protocol Pen {}
33+
34+
protocol Pencil : Pen {
35+
associatedtype Stroke : Pen
36+
}
37+
38+
protocol Medium {
39+
associatedtype Texture : Ink
40+
41+
func draw<P : Pencil>(paint: Texture.Paint, pencil: P) where P.Stroke == Texture.Paint
42+
}
43+
44+
struct Canvas<I : Ink> where I.Paint : Pen {
45+
typealias Texture = I
46+
47+
func draw<P : Pencil>(paint: I.Paint, pencil: P) where P.Stroke == Texture.Paint { }
48+
}
49+
50+
extension Canvas : Medium {}
51+
52+
// CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWuRx15generic_witness3Inkwx5PaintS_3PenrGVS_6Canvasx_S_6MediumS_FS4_4drawuRd__S_6Pencilwd__6StrokezWx7TextureS1__rfT5paintWxS7_S1__6pencilqd___T_ : $@convention(witness_method) <I where I : Ink, I.Paint : Pen><P where P : Pencil> (@in I.Paint, @in P, @in_guaranteed Canvas<I>) -> () {
53+
// CHECK: [[FN:%.*]] = function_ref @_TFV15generic_witness6Canvas4drawuRd__S_6Pencilwx5Paintzwd__6StrokerfT5paintwxS2_6pencilqd___T_ : $@convention(method) <τ_0_0 where τ_0_0 : Ink, τ_0_0.Paint : Pen><τ_1_0 where τ_1_0 : Pencil, τ_0_0.Paint == τ_1_0.Stroke> (@in τ_0_0.Paint, @in τ_1_0, Canvas<τ_0_0>) -> ()
54+
// CHECK: apply [[FN]]<I, P, I.Paint>({{.*}}) : $@convention(method) <τ_0_0 where τ_0_0 : Ink, τ_0_0.Paint : Pen><τ_1_0 where τ_1_0 : Pencil, τ_0_0.Paint == τ_1_0.Stroke> (@in τ_0_0.Paint, @in τ_1_0, Canvas<τ_0_0>) -> ()
55+
// CHECK: }

0 commit comments

Comments
 (0)