diff --git a/lib/Sema/TypeChecker.cpp b/lib/Sema/TypeChecker.cpp index 450b3cf2dea..1e0b7ccac34 100644 --- a/lib/Sema/TypeChecker.cpp +++ b/lib/Sema/TypeChecker.cpp @@ -564,6 +564,9 @@ void swift::checkInconsistentImplementationOnlyImports(ModuleDecl *MainModule) { continue; ModuleDecl *module = nextImport->getModule(); + if (!module) + continue; + if (nextImport->getAttrs().hasAttribute()) { // We saw an implementation-only import. bool isNew = diff --git a/validation-test/NameBinding/inconsistent-implementation-only-errors.swift b/validation-test/NameBinding/inconsistent-implementation-only-errors.swift new file mode 100644 index 00000000000..de98d575dfc --- /dev/null +++ b/validation-test/NameBinding/inconsistent-implementation-only-errors.swift @@ -0,0 +1,9 @@ +// Just check that we don't crash (rdar://problem/52943397) + +// RUN: not %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck -show-diagnostics-after-fatal %s + +@_implementationOnly import Swift +import ThisModuleDoesNotExist +@_implementationOnly import ThisModuleDoesNotExist +@_implementationOnly import NeitherDoesThisOne