Skip to content

Commit 2e850bb

Browse files
authored
Merge pull request #78869 from artemcm/61_NoPackageOnlyImportOnImplicitBuild
[6.1 🍒][ModuleInterface] Determine package-only resolution need based on input mode
2 parents bba7a23 + 26c4207 commit 2e850bb

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,9 +2297,10 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
22972297
Opts.ScannerModuleValidation |= Args.hasFlag(OPT_scanner_module_validation,
22982298
OPT_no_scanner_module_validation,
22992299
CASOpts.EnableCaching);
2300+
23002301
bool buildingFromInterface =
2301-
FrontendOptions::doesActionBuildModuleFromInterface(
2302-
FrontendOpts.RequestedAction);
2302+
FrontendOpts.InputMode ==
2303+
FrontendOptions::ParseInputMode::SwiftModuleInterface;
23032304
auto firstInputPath =
23042305
FrontendOpts.InputsAndOutputs.hasInputs()
23052306
? FrontendOpts.InputsAndOutputs.getFilenameOfFirstInput()
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/module-cache)
3+
// RUN: %empty-directory(%t/Swift)
4+
// RUN: %empty-directory(%t/OtherSwift)
5+
// RUN: split-file %s %t
6+
7+
// Build in-package ModuleC
8+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/OtherSwift/ModuleC.swiftmodule -module-name ModuleC -package-name TestPak %t/C.swift
9+
10+
// Build in-package ModuleB
11+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Swift/ModuleB.swiftmodule -enable-library-evolution -emit-module-interface-path %t/Swift/ModuleB.swiftinterface -module-name ModuleB -package-name TestPak %t/B.swift -I%t/OtherSwift
12+
13+
// Build in-package ModuleA
14+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Swift/ModuleA.swiftmodule -enable-library-evolution -emit-module-interface-path %t/Swift/ModuleA.swiftinterface -module-name ModuleA -package-name TestPak %t/A.swift -I%t/Swift -I%t/OtherSwift
15+
16+
// Remove binary module for A to make sure an implicit interface compile gets triggered
17+
// RUN: rm %t/Swift/ModuleA.swiftmodule
18+
// Remove in-package-only dependency of B to ensure that if the compiler looks for it, compilation will fail
19+
// RUN: rm %t/OtherSwift/ModuleC.swiftmodule
20+
21+
// Build out-of-package client source
22+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Swift/Client.swiftmodule -module-name Client %t/Client.swift -I%t/Swift
23+
24+
//--- C.swift
25+
public func c() {}
26+
27+
//--- B.swift
28+
package import ModuleC
29+
30+
//--- A.swift
31+
@_exported public import ModuleB
32+
33+
//--- Client.swift
34+
import ModuleA
35+

0 commit comments

Comments
 (0)