Skip to content

Commit 6255e23

Browse files
authored
Merge pull request #84085 from egorzhdan/egorzhdan/frt-test
[cxx-interop] Test initializing foreign reference type when passed by parameter
2 parents 0bcc956 + 45dcb68 commit 6255e23

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

test/Interop/Cxx/foreign-reference/Inputs/pass-as-parameter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ inline int extractValueFromRefToPtr(IntBox *&b) { return b->value; }
1414
inline int extractValueFromRefToConstPtr(IntBox const *&b) { return b->value; }
1515
inline int extractValueFromConstRefToPtr(IntBox *const &b) { return b->value; }
1616
inline int extractValueFromConstRefToConstPtr(IntBox const *const &b) { return b->value; }
17+
18+
inline void initializeByPtr(int value, IntBox **b) {
19+
*b = IntBox::create(value);
20+
}

test/Interop/Cxx/foreign-reference/pass-as-parameter-module-interface.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
// CHECK: func extractValueFromRefToConstPtr(_ b: inout IntBox!) -> Int32
88
// CHECK: func extractValueFromConstRefToPtr(_ b: IntBox!) -> Int32
99
// CHECK: func extractValueFromConstRefToConstPtr(_ b: IntBox!) -> Int32
10+
11+
// CHECK: func initializeByPtr(_ value: Int32, _ b: UnsafeMutablePointer<IntBox?>!)

test/Interop/Cxx/foreign-reference/pass-as-parameter.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,10 @@ PassAsParameterTestSuite.test("pass as const reference to const pointer") {
5353
expectEqual(aValue, 789)
5454
}
5555

56+
PassAsParameterTestSuite.test("initialize by pointer") {
57+
var a: IntBox!
58+
initializeByPtr(987, &a)
59+
expectEqual(a.value, 987)
60+
}
61+
5662
runAllTests()

0 commit comments

Comments
 (0)