Skip to content

Commit f6324c8

Browse files
committed
Add SILGen test for dynamic lookup with default args
1 parent a5e375a commit f6324c8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/SILGen/dynamic_lookup.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class X {
1414
}
1515
set {}
1616
}
17+
18+
@objc func hasDefaultParam(_ x: Int = 0) {}
1719
}
1820

1921
@objc protocol P {
@@ -356,3 +358,13 @@ func getIUOPropertyDynamically(x: AnyObject) -> Any {
356358
return x.iuoProperty
357359
}
358360

361+
// SR-11648
362+
// CHECK-LABEL: sil hidden [ossa] @$s14dynamic_lookup24testAnyObjectWithDefaultyyyXlF
363+
func testAnyObjectWithDefault(_ x: AnyObject) {
364+
// CHECK: function_ref default argument 0 of X.hasDefaultParam(_:)
365+
// CHECK: [[DEFGEN:%[0-9]+]] = function_ref @$s14dynamic_lookup1XC15hasDefaultParamyySiFfA_ : $@convention(thin) () -> Int
366+
// CHECK: [[DEFARG:%[0-9]+]] = apply %4() : $@convention(thin) () -> Int
367+
// CHECK: [[METHOD:%[0-9]+]] = objc_method [[OPENEDX:%[0-9]+]] : $@opened("{{.*}}") AnyObject, #X.hasDefaultParam!1.foreign : (X) -> (Int) -> (), $@convention(objc_method) (Int, @opened("{{.*}}") AnyObject) -> ()
368+
// CHECK: apply [[METHOD]]([[DEFARG]], [[OPENEDX]])
369+
x.hasDefaultParam()
370+
}

0 commit comments

Comments
 (0)