Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/Interop/C/implementation-only-imports/Inputs/helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_HELPER_H
#define TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_HELPER_H

inline int getFortyTwo() {
return 42;
};

#endif // TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_HELPER_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module UserA {
header "user_a.h"
export *
}

module UserB {
header "user_b.h"
export *
}
6 changes: 6 additions & 0 deletions test/Interop/C/implementation-only-imports/Inputs/user_a.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERA_H
#define TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERA_H

#include "helper.h"

#endif // TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERA_H
6 changes: 6 additions & 0 deletions test/Interop/C/implementation-only-imports/Inputs/user_b.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERB_H
#define TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERB_H

#include "helper.h"

#endif // TEST_INTEROP_C_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USERB_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -o %t/FortyTwo.swiftmodule -I %S/Inputs %s

// REQUIRES: SR-13785

// TODO: Fix @_implementationOnly to consider all symbol sources

// If a symbol comes from two modules, one of which is marked as
// @_implementationOnly, Swift may choose the @_implementationOnly source
// and then error out due to the symbol being hidden.

// Swift should consider all sources for the symbol and recognize that the
// symbol is not hidden behind @_implementationOnly in all modules.

// E.g:
// In this test case, UserA and UserB both textually include `helper.h`,
// therefore both export `getFortyTwo()`.
// This test verifies that even though Swift chooses UserA.getFortyTwo(), we
// shouldn't get an error, because the symbol is also exported from UserB.

@_implementationOnly import UserA
import UserB

@_inlineable
public func callFortyTwo() -> CInt {
return getFortyTwo()
}