Skip to content

Commit 5800336

Browse files
committed
updates
1 parent 3bcd726 commit 5800336

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ ERROR(in_package_module_not_compiled_from_source,none,
10141014

10151015
WARNING(in_package_module_not_compiled_locally,none,
10161016
"module %0 is in package %1 but was loaded from SDK; "
1017-
"modules of the same package are expected to be loaded from local build directory: %2",
1017+
"modules of the same package should be built locally from source only: %2",
10181018
(Identifier, Identifier, StringRef))
10191019

10201020
ERROR(import_restriction_conflict,none,

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,13 +1962,14 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
19621962

19631963
auto target = ID->getModule();
19641964
if (target->isNonUserModule() && // target module is in distributed SDK
1965+
!getASTContext().LangOpts.PackageName.empty() &&
19651966
getASTContext().LangOpts.PackageName == target->getPackageName().str()) {
19661967
// If reached here, a binary module (.swiftmodule) instead of interface of the
19671968
// target was loaded for the main module, where both belong to the same package;
19681969
// this is an expected behavior, but it should have been loaded from the local
19691970
// build directory, not from distributed SDK. In such case, we show a warning.
19701971
auto &diags = ID->getASTContext().Diags;
1971-
diags.diagnose(target->getLoc(),
1972+
diags.diagnose(ID,
19721973
diag::in_package_module_not_compiled_locally,
19731974
target->getBaseIdentifier(),
19741975
target->getPackageName(),

test/Sema/import_package_module_from_sdk.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@
1414

1515
// RUN: test -f %t/SDK/Frameworks/LibInSDK.framework/Modules/LibInSDK.swiftmodule/%module-target-triple.swiftmodule
1616

17-
// RUN: %target-swift-frontend -typecheck %t/Client1.swift -package-name libPkg -sdk %t/SDK -I %t -I %t/SDK/Frameworks/LibInSDK.framework/Modules 2> %t/result.output
18-
// RUN: %FileCheck %s < %t/result.output
19-
// CHECK: warning: module 'LibInSDK' is in package 'libPkg' but was loaded from SDK; modules of the same package are expected to be loaded from local build directory: {{.*}}/SDK/Frameworks/LibInSDK.framework/Modules/LibInSDK.swiftmodule/{{.*}}.swiftmodule
17+
// RUN: %target-swift-frontend -typecheck -verify -verify-ignore-unknown %t/Client1.swift -package-name libPkg -sdk %t/SDK -I %t -I %t/SDK/Frameworks/LibInSDK.framework/Modules
2018

2119
// RUN: %target-swift-frontend -module-name LibLocal -emit-module -emit-module-path %t/LibLocal.swiftmodule -parse-as-library %t/Lib.swift -package-name libPkg
2220
// RUN: test -f %t/LibLocal.swiftmodule
2321

24-
// RUN: %target-swift-frontend -typecheck %t/Client2.swift -package-name libPkg -I %t
22+
// RUN: %target-swift-frontend -typecheck -verify %t/Client2.swift -package-name libPkg -I %t
2523

2624
//--- Lib.swift
2725
package func log(level: Int) {}
2826

2927
//--- Client1.swift
30-
import LibInSDK
28+
import LibInSDK // expected-warning {{module 'LibInSDK' is in package 'libPkg' but was loaded from SDK; modules of the same package should be built locally from source only}}
3129

3230
func someFunc() {
3331
log(level: 1)

0 commit comments

Comments
 (0)