1
- // RUN: %target-swift-frontend -emit-silgen %s | FileCheck %s
1
+ // RUN: %target-swift-frontend -use-native-super-method - emit-silgen %s | FileCheck %s
2
2
3
3
// Test that we emit a call to super.init at the end of the initializer, when none has been previously added.
4
4
@@ -16,8 +16,7 @@ class SomeDerivedClass : Parent {
16
16
// CHECK: integer_literal $Builtin.Int2048, 42
17
17
// CHECK: [[SELFLOAD:%[0-9]+]] = load [[SELF:%[0-9]+]] : $*SomeDerivedClass
18
18
// CHECK-NEXT: [[PARENT:%[0-9]+]] = upcast [[SELFLOAD]] : $SomeDerivedClass to $Parent
19
- // CHECK-NEXT: function_ref auto_generated_super_init_call.Parent.init
20
- // CHECK-NEXT: [[INITCALL1:%[0-9]+]] = function_ref @_TFC30auto_generated_super_init_call6Parentc
19
+ // CHECK-NEXT: [[INITCALL1:%[0-9]+]] = super_method [[SELFLOAD]] : $SomeDerivedClass, #Parent.init!initializer.1
21
20
// CHECK-NEXT: [[RES1:%[0-9]+]] = apply [[INITCALL1]]([[PARENT]])
22
21
// CHECK-NEXT: [[DOWNCAST:%[0-9]+]] = unchecked_ref_cast [[RES1]] : $Parent to $SomeDerivedClass
23
22
// CHECK-NEXT: store [[DOWNCAST]] to [[SELF]] : $*SomeDerivedClass
@@ -26,7 +25,7 @@ class SomeDerivedClass : Parent {
26
25
init ( x: Int ) {
27
26
y = x
28
27
// CHECK-LABEL: sil hidden @_TFC30auto_generated_super_init_call16SomeDerivedClassc{{.*}} : $@convention(method) (Int, @owned SomeDerivedClass) -> @owned SomeDerivedClass
29
- // CHECK: function_ref @_TFC30auto_generated_super_init_call6Parentc{{.* }} : $@convention(method) (@owned Parent) -> @owned Parent
28
+ // CHECK: super_method {{%[0-9]+ }} : $SomeDerivedClass, #Parent.init!initializer.1 : Parent.Type -> () -> Parent , $@convention(method) (@owned Parent) -> @owned Parent
30
29
}
31
30
32
31
init ( b: Bool ) {
@@ -42,7 +41,7 @@ class SomeDerivedClass : Parent {
42
41
// CHECK-LABEL: sil hidden @_TFC30auto_generated_super_init_call16SomeDerivedClassc{{.*}} : $@convention(method) (Bool, @owned SomeDerivedClass) -> @owned SomeDerivedClass
43
42
// CHECK: bb4:
44
43
// CHECK: [[SELFLOAD:%[0-9]+]] = load [[SELF:%[0-9]+]] : $*SomeDerivedClass
45
- // CHECK: function_ref @_TFC30auto_generated_super_init_call6Parentc{{.*}} : $@convention(method) (@owned Parent) -> @owned Parent
44
+ // CHECK: super_method [[SELFLOAD]] : $SomeDerivedClass, #Parent.init!initializer.1 : Parent.Type -> () -> Parent , $@convention(method) (@owned Parent) -> @owned Parent
46
45
// CHECK-NEXT: apply
47
46
// CHECK-NEXT: unchecked_ref_cast
48
47
// CHECK-NEXT: store
@@ -62,7 +61,7 @@ class SomeDerivedClass : Parent {
62
61
63
62
super. init ( )
64
63
// CHECK-LABEL: sil hidden @_TFC30auto_generated_super_init_call16SomeDerivedClassc{{.*}} : $@convention(method) (Bool, Int, @owned SomeDerivedClass) -> @owned SomeDerivedClass
65
- // CHECK: function_ref @_TFC30auto_generated_super_init_call6Parentc{{.* }} : $@convention(method) (@owned Parent) -> @owned Parent
64
+ // CHECK: super_method {{%[0-9]+ }} : $SomeDerivedClass, #Parent.init!initializer.1 : Parent.Type -> () -> Parent , $@convention(method) (@owned Parent) -> @owned Parent
66
65
// CHECK-NOT: function_ref @_TFC30auto_generated_super_init_call6Parentc
67
66
// CHECK: return
68
67
}
@@ -72,7 +71,7 @@ class SomeDerivedClass : Parent {
72
71
class HasNoIVars : Parent {
73
72
override init ( ) {
74
73
// CHECK-LABEL: sil hidden @_TFC30auto_generated_super_init_call10HasNoIVarsc{{.*}} : $@convention(method) (@owned HasNoIVars) -> @owned HasNoIVars
75
- // CHECK: function_ref @_TFC30auto_generated_super_init_call6Parentc
74
+ // CHECK: super_method {{%[0-9]+}} : $HasNoIVars, #Parent.init!initializer.1
76
75
}
77
76
}
78
77
@@ -96,7 +95,7 @@ class ChildOfParentWithNoExplicitInit : ParentWithNoExplicitInit {
96
95
override init ( ) {
97
96
y = 10
98
97
// CHECK-LABEL: sil hidden @_TFC30auto_generated_super_init_call31ChildOfParentWithNoExplicitInitc
99
- // CHECK: function_ref @_TFC30auto_generated_super_init_call24ParentWithNoExplicitInitc{{.* }} : $@convention(method) (@owned ParentWithNoExplicitInit) -> @owned ParentWithNoExplicitInit
98
+ // CHECK: super_method {{%[0-9]+ }} : $ChildOfParentWithNoExplicitInit, #ParentWithNoExplicitInit.init!initializer.1 : ParentWithNoExplicitInit.Type -> () -> ParentWithNoExplicitInit , $@convention(method) (@owned ParentWithNoExplicitInit) -> @owned ParentWithNoExplicitInit
100
99
}
101
100
}
102
101
@@ -110,7 +109,7 @@ class ChildOfParentWithNoExplicitInit2 : ParentWithNoExplicitInit2 {
110
109
override init ( ) {
111
110
y = 10
112
111
// CHECK-LABEL: sil hidden @_TFC30auto_generated_super_init_call32ChildOfParentWithNoExplicitInit2c
113
- // CHECK: function_ref @_TFC30auto_generated_super_init_call25ParentWithNoExplicitInit2c{{.* }} : $@convention(method) (@owned ParentWithNoExplicitInit2) -> @owned ParentWithNoExplicitInit2
112
+ // CHECK: super_method {{%[0-9]+ }} : $ChildOfParentWithNoExplicitInit2, #ParentWithNoExplicitInit2.init!initializer.1 : ParentWithNoExplicitInit2.Type -> () -> ParentWithNoExplicitInit2 , $ @convention(method) (@owned ParentWithNoExplicitInit2) -> @owned ParentWithNoExplicitInit2
114
113
}
115
114
}
116
115
0 commit comments