1
+ // RUN: rm -rf %t && mkdir -p %t
2
+ // RUN: %target-swift-frontend -emit-module -o %t -module-name InheritedInitializerBase %S/Inputs/inherited-initializer-base.swift
3
+ // RUN: %target-swift-frontend -emit-silgen -I %t %s | %FileCheck %s
4
+
5
+ import InheritedInitializerBase
6
+
7
+ class InheritsInit : Base { }
8
+
9
+ // CHECK-LABEL: sil hidden @_TF4main10testSimpleFT_T_
10
+ func testSimple( ) {
11
+ // CHECK: [[INIT:%.+]] = function_ref @_TFC4main12InheritsInitCfSiS0_
12
+ // CHECK: [[DEFAULT:%.+]] = function_ref @_TIFC24InheritedInitializerBase4BasecFSiS0_A_
13
+ // CHECK: [[ARG:%.+]] = apply [[DEFAULT]]()
14
+ // CHECK: apply [[INIT]]([[ARG]], {{%.+}})
15
+ _ = InheritsInit ( )
16
+
17
+ // CHECK: [[INIT:%.+]] = function_ref @_TFC4main12InheritsInitCfSiS0_
18
+ // CHECK: [[VALUE:%.+]] = integer_literal $Builtin.Int2048, 5
19
+ // CHECK: [[ARG:%.+]] = apply {{%.+}}([[VALUE]], {{%.+}}) : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int
20
+ // CHECK: apply [[INIT]]([[ARG]], {{%.+}})
21
+ _ = InheritsInit ( 5 )
22
+ } // CHECK: end sil function '_TF4main10testSimpleFT_T_'
23
+
24
+ struct Reinitializable < T> : Initializable {
25
+ init ( ) { }
26
+ }
27
+
28
+ class GenericSub < T: Initializable > : GenericBase < T > { }
29
+ class ModifiedGenericSub < U> : GenericBase < Reinitializable < U > > { }
30
+ class NonGenericSub : GenericBase < Reinitializable < Int > > { }
31
+
32
+ // CHECK-LABEL: sil hidden @_TF4main11testGenericFT_T_
33
+ func testGeneric( ) {
34
+ // CHECK: [[INIT:%.+]] = function_ref @_TFC4main10GenericSubCfxGS0_x_
35
+ // CHECK: [[TYPE:%.+]] = metatype $@thick GenericSub<Reinitializable<Int8>>.Type
36
+ // CHECK: [[DEFAULT:%.+]] = function_ref @_TIFC24InheritedInitializerBase11GenericBasecFxGS0_x_A_
37
+ // CHECK: apply [[DEFAULT]]<Reinitializable<Int8>>({{%.+}})
38
+ // CHECK: apply [[INIT]]<Reinitializable<Int8>>({{%.+}}, [[TYPE]])
39
+ _ = GenericSub< Reinitializable< Int8>>. init( ) // works around SR-3806
40
+
41
+ // CHECK: [[INIT:%.+]] = function_ref @_TFC4main18ModifiedGenericSubCfGVS_15Reinitializablex_GS0_x_
42
+ // CHECK: [[TYPE:%.+]] = metatype $@thick ModifiedGenericSub<Int16>.Type
43
+ // CHECK: [[DEFAULT:%.+]] = function_ref @_TIFC24InheritedInitializerBase11GenericBasecFxGS0_x_A_
44
+ // CHECK: apply [[DEFAULT]]<Reinitializable<Int16>>({{%.+}})
45
+ // CHECK: apply [[INIT]]<Int16>({{%.+}}, [[TYPE]])
46
+ _ = ModifiedGenericSub < Int16 > ( )
47
+
48
+ // CHECK: [[INIT:%.+]] = function_ref @_TFC4main13NonGenericSubCfGVS_15ReinitializableSi_S0_
49
+ // CHECK: [[TYPE:%.+]] = metatype $@thick NonGenericSub.Type
50
+ // CHECK: [[DEFAULT:%.+]] = function_ref @_TIFC24InheritedInitializerBase11GenericBasecFxGS0_x_A_
51
+ // CHECK: apply [[DEFAULT]]<Reinitializable<Int>>({{%.+}})
52
+ // CHECK: apply [[INIT]]({{%.+}}, [[TYPE]])
53
+ _ = NonGenericSub ( )
54
+ } // CHECK: end sil function '_TF4main11testGenericFT_T_'
0 commit comments