Skip to content

Commit 679ce36

Browse files
committed
Add more tests
1 parent a22e65e commit 679ce36

18 files changed

+191
-7
lines changed

lib/Sema/ResilienceDiagnostics.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "swift/AST/Decl.h"
2222
#include "swift/AST/DeclContext.h"
2323
#include "swift/AST/Initializer.h"
24-
#include "swift/AST/ModuleNameLookup.h"
2524
#include "swift/AST/ProtocolConformance.h"
2625
#include "swift/AST/SourceFile.h"
2726
#include "swift/AST/TypeDeclFinder.h"

lib/Sema/TypeCheckAccess.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "swift/AST/ASTWalker.h"
2323
#include "swift/AST/DiagnosticsSema.h"
2424
#include "swift/AST/ExistentialLayout.h"
25+
#include "swift/AST/ModuleNameLookup.h"
2526
#include "swift/AST/Pattern.h"
2627
#include "swift/AST/ParameterList.h"
2728
#include "swift/AST/TypeCheckRequests.h"

test/Interop/C/implementation-only-imports/lookup-visible-decls-recursively-inversed.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %empty-directory(%t)
22
// RUN: mkdir %t/use_module_a %t/use_module_b
3-
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_a/UseModuleA.swiftmodule %S/Inputs/use-module-a.swift -I %S/Inputs -enable-cxx-interop
4-
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_b/UseModuleB.swiftmodule %S/Inputs/use-module-b.swift -I %S/Inputs -enable-cxx-interop
3+
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_a/UseModuleA.swiftmodule %S/Inputs/use-module-a.swift -I %S/Inputs
4+
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_b/UseModuleB.swiftmodule %S/Inputs/use-module-b.swift -I %S/Inputs
55

6-
// RUN: %target-swift-frontend -typecheck -swift-version 5 -I %t/use_module_a -I %t/use_module_b -I %S/Inputs -enable-cxx-interop %s
6+
// RUN: %target-swift-frontend -typecheck -swift-version 5 -I %t/use_module_a -I %t/use_module_b -I %S/Inputs %s
77

88

99
// If a decl comes from two modules, one of which is marked as

test/Interop/C/implementation-only-imports/lookup-visible-decls-recursively.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %empty-directory(%t)
22
// RUN: mkdir %t/use_module_a %t/use_module_b
3-
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_a/UseModuleA.swiftmodule %S/Inputs/use-module-a.swift -I %S/Inputs -enable-cxx-interop
4-
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_b/UseModuleB.swiftmodule %S/Inputs/use-module-b.swift -I %S/Inputs -enable-cxx-interop
3+
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_a/UseModuleA.swiftmodule %S/Inputs/use-module-a.swift -I %S/Inputs
4+
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_b/UseModuleB.swiftmodule %S/Inputs/use-module-b.swift -I %S/Inputs
55

6-
// RUN: %target-swift-frontend -typecheck -swift-version 5 -I %t/use_module_a -I %t/use_module_b -I %S/Inputs -enable-cxx-interop %s
6+
// RUN: %target-swift-frontend -typecheck -swift-version 5 -I %t/use_module_a -I %t/use_module_b -I %S/Inputs %s
77

88

99
// If a decl comes from two modules, one of which is marked as
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_DECL_A_H
2+
#define TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_DECL_A_H
3+
4+
inline int getFortySomething() {
5+
return 42;
6+
};
7+
8+
#endif // TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_DECL_A_H
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_DECL_B_H
2+
#define TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_DECL_B_H
3+
4+
inline int getFortySomething() {
5+
return 46;
6+
};
7+
8+
#endif // TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_DECL_B_H
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_HELPER_H
2+
#define TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_HELPER_H
3+
4+
inline int getFortyTwo() {
5+
return 42;
6+
};
7+
8+
class MagicWrapper {
9+
int _number;
10+
public:
11+
MagicWrapper(){};
12+
MagicWrapper(int number) : _number(number) {};
13+
};
14+
15+
#endif // TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_HELPER_H
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module UserA {
2+
header "user-a.h"
3+
export *
4+
}
5+
6+
module UserB {
7+
header "user-b.h"
8+
export *
9+
}
10+
11+
module DeclA {
12+
header "decl-a.h"
13+
export *
14+
}
15+
16+
module DeclB {
17+
header "decl-b.h"
18+
export *
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@_exported import UserA
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@_exported import UserB
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USER_A_H
2+
#define TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USER_A_H
3+
4+
#include "helper.h"
5+
6+
#endif // TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USER_A_H
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USER_B_H
2+
#define TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USER_B_H
3+
4+
#include "helper.h"
5+
6+
#endif // TEST_INTEROP_CXX_IMPLEMENTATION_ONLY_IMPORTS_INPUTS_USER_B_H
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -o %t/FortyTwo.swiftmodule -I %S/Inputs %s -enable-cxx-interop
3+
4+
// REQUIRES: SR-13785
5+
6+
@_implementationOnly import UserA
7+
import UserB
8+
9+
@_inlineable
10+
public func createAWrapper() {
11+
let _wrapper = MagicWrapper();
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: not %target-swift-frontend -emit-module -o %t/FortyTwo.swiftmodule -I %S/Inputs -enable-cxx-interop %s 2>&1 | %FileCheck %s
3+
4+
@_implementationOnly import DeclA
5+
import DeclB
6+
7+
@_inlineable
8+
public func callFortySomething() -> CInt {
9+
return getFortySomething()
10+
}
11+
12+
// CHECK: 'getFortySomething' has different definitions in different modules
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir %t/use_module_a %t/use_module_b
3+
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_a/UseModuleA.swiftmodule %S/Inputs/use-module-a.swift -I %S/Inputs -enable-cxx-interop
4+
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_b/UseModuleB.swiftmodule %S/Inputs/use-module-b.swift -I %S/Inputs -enable-cxx-interop
5+
6+
// RUN: %target-swift-frontend -typecheck -swift-version 5 -I %t/use_module_a -I %t/use_module_b -I %S/Inputs -enable-cxx-interop %s
7+
8+
9+
// If a decl comes from two modules, one of which is marked as
10+
// @_implementationOnly, Swift may choose the @_implementationOnly source
11+
// and then error out due to the decl being hidden.
12+
13+
// Swift should consider all sources for the decl and recognize that the
14+
// decl is not hidden behind @_implementationOnly in all modules.
15+
16+
// This test, as well as `lookup-visible-decls-recursively.swift` checks
17+
// that the `getFortyTwo` decl can be found when at least one of the
18+
// modules is not `@_implementationOnly`.
19+
20+
@_implementationOnly import UseModuleA
21+
import UseModuleB
22+
23+
@inlinable
24+
public func callFortyTwo() -> CInt {
25+
return getFortyTwo()
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir %t/use_module_a %t/use_module_b
3+
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_a/UseModuleA.swiftmodule %S/Inputs/use-module-a.swift -I %S/Inputs -enable-cxx-interop
4+
// RUN: %target-swift-frontend -enable-library-evolution -swift-version 5 -emit-module -o %t/use_module_b/UseModuleB.swiftmodule %S/Inputs/use-module-b.swift -I %S/Inputs -enable-cxx-interop
5+
6+
// RUN: %target-swift-frontend -typecheck -swift-version 5 -I %t/use_module_a -I %t/use_module_b -I %S/Inputs -enable-cxx-interop %s
7+
8+
9+
// If a decl comes from two modules, one of which is marked as
10+
// @_implementationOnly, Swift may choose the @_implementationOnly source
11+
// and then error out due to the decl being hidden.
12+
13+
// Swift should consider all sources for the decl and recognize that the
14+
// decl is not hidden behind @_implementationOnly in all modules.
15+
16+
// This test, as well as `lookup-visible-decls-recursively-inversed.swift`
17+
// checks that the `getFortyTwo` decl can be found when at least one of the
18+
// modules is not `@_implementationOnly`.
19+
20+
import UseModuleA
21+
@_implementationOnly import UseModuleB
22+
23+
@inlinable
24+
public func callFortyTwo() -> CInt {
25+
return getFortyTwo()
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -o %t/FortyTwo.swiftmodule -I %S/Inputs -enable-cxx-interop %s
3+
4+
// If a decl comes from two modules, one of which is marked as
5+
// @_implementationOnly, Swift may choose the @_implementationOnly source
6+
// and then error out due to the decl being hidden.
7+
8+
// Swift should consider all sources for the decl and recognize that the
9+
// decl is not hidden behind @_implementationOnly in all modules.
10+
11+
// This test, as well as
12+
// `prefer-a-visible-decl-over-implementation-only-decls.swift`
13+
// checks that the `getFortyTwo` decl can be found when at least one of the
14+
// modules is not `@_implementationOnly`.
15+
16+
import UserA
17+
@_implementationOnly import UserB
18+
19+
@_inlineable
20+
public func callFortyTwo() -> CInt {
21+
return getFortyTwo()
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -o %t/FortyTwo.swiftmodule -I %S/Inputs -enable-cxx-interop %s
3+
4+
// If a decl comes from two modules, one of which is marked as
5+
// @_implementationOnly, Swift may choose the @_implementationOnly source
6+
// and then error out due to the decl being hidden.
7+
8+
// Swift should consider all sources for the decl and recognize that the
9+
// decl is not hidden behind @_implementationOnly in all modules.
10+
11+
// This test, as well as
12+
// `prefer-a-visible-decl-over-implementation-only-decls-inversed.swift`
13+
// checks that the `getFortyTwo` decl can be found when at least one of the
14+
// modules is not `@_implementationOnly`.
15+
16+
@_implementationOnly import UserA
17+
import UserB
18+
19+
@_inlineable
20+
public func callFortyTwo() -> CInt {
21+
return getFortyTwo()
22+
}

0 commit comments

Comments
 (0)