File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,24 @@ func fibonacci(_ n: Int) -> Int {
18
18
return recursive ( n)
19
19
}
20
20
21
+ class C {
22
+ required init ( ) { }
23
+ func f( ) { }
24
+ // Make sure that we capture dynamic self type if an explicit self isn't guaranteed
25
+ func returnsSelf( ) -> Self {
26
+ return { self . f ( ) ; return . init( ) } ( )
27
+ // CHECK-LABEL: sil private @{{.*}}returnsSelf{{.*}} : $@convention(thin) (@guaranteed C) -> @owned C
28
+ }
29
+
30
+ func returnsSelf1( ) -> Self {
31
+ return { [ weak self] in self ? . f ( ) ; return . init( ) } ( )
32
+ // CHECK-LABEL: sil private @{{.*}}returnsSelf{{.*}} : $@convention(thin) (@guaranteed { var @sil_weak Optional<C> }, @thick @dynamic_self C.Type) -> @owned C
33
+ }
34
+
35
+ func returnsSelf2( ) -> Self {
36
+ return { [ unowned self] in self . f ( ) ; return . init( ) } ( )
37
+ // CHECK-LABEL: sil private @{{.*}}returnsSelf{{.*}} : $@convention(thin) (@guaranteed @sil_unowned C, @thick @dynamic_self C.Type) -> @owned C
38
+ }
39
+ }
40
+
41
+
You can’t perform that action at this time.
0 commit comments