Skip to content

Commit 520b6e8

Browse files
committed
Merge branch 'main' of github.com:apple/swift into tensorflow-stage
* 'main' of github.com:apple/swift: Add a failing test for SR-13785 (#34462)
2 parents f43deb9 + 64e5f76 commit 520b6e8

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_HELPER_H
2+
#define TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_HELPER_H
3+
4+
inline int getFortyTwo() {
5+
return 42;
6+
};
7+
8+
#endif // TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_HELPER_H
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module UserA {
2+
header "user_a.h"
3+
export *
4+
}
5+
6+
module UserB {
7+
header "user_b.h"
8+
export *
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERA_H
2+
#define TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERA_H
3+
4+
#include "helper.h"
5+
6+
#endif // TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERA_H
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERB_H
2+
#define TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERB_H
3+
4+
#include "helper.h"
5+
6+
#endif // TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERB_H
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -o %t/FortyTwo.swiftmodule -I %S/Inputs %s
3+
4+
// REQUIRES: SR-13785
5+
6+
// TODO: Fix @_implementationOnly to consider all symbol sources
7+
8+
// If a symbol comes from two modules, one of which is marked as
9+
// @_implementationOnly, Swift may choose the @_implementationOnly source
10+
// and then error out due to the symbol being hidden.
11+
12+
// Swift should consider all sources for the symbol and recognize that the
13+
// symbol is not hidden behind @_implementationOnly in all modules.
14+
15+
// E.g:
16+
// In this test case, UserA and UserB both textually include `helper.h`,
17+
// therefore both export `getFortyTwo()`.
18+
// This test verifies that even though Swift chooses UserA.getFortyTwo(), we
19+
// shouldn't get an error, because the symbol is also exported from UserB.
20+
21+
@_implementationOnly import UserA
22+
import UserB
23+
24+
@_inlineable
25+
public func callFortyTwo() -> CInt {
26+
return getFortyTwo()
27+
}

0 commit comments

Comments
 (0)