Skip to content

Commit 23a3fbd

Browse files
authored
Merge pull request #65110 from apple/es-rel-fix
[5.9] Add a target nil check
2 parents bc9f9e1 + b525ce2 commit 23a3fbd

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
19211921
(void)ID->getDecls();
19221922

19231923
auto target = ID->getModule();
1924-
if (!getASTContext().LangOpts.PackageName.empty() &&
1924+
if (target && // module would be nil if loading fails
1925+
!getASTContext().LangOpts.PackageName.empty() &&
19251926
getASTContext().LangOpts.PackageName == target->getPackageName().str() &&
19261927
!target->isNonSwiftModule() && // target is a Swift module
19271928
target->isNonUserModule()) { // target module is in distributed SDK

test/Sema/import_package_module_from_sdk.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
// RUN: %target-swift-frontend -typecheck -verify %t/Client2.swift -package-name libPkg -I %t
2323

24+
// RUN: rm %t/LibLocal.swiftmodule
25+
// RUN: not %target-swift-frontend -typecheck %t/Client2.swift -package-name libPkg -I %t 2>&1 | %FileCheck %s
26+
// CHECK: error: no such module 'LibLocal'
27+
2428
//--- Lib.swift
2529
package func log(level: Int) {}
2630

@@ -37,5 +41,3 @@ import LibLocal
3741
func someFunc() {
3842
log(level: 1)
3943
}
40-
41-

0 commit comments

Comments
 (0)