Skip to content

Commit

Permalink
Merge pull request #74413 from DougGregor/preconcurrency-import-under…
Browse files Browse the repository at this point in the history
…lying-6.0

[6.0] Teach "find imports" to equate overlay modules with their underlying modules
  • Loading branch information
DougGregor authored Jun 14, 2024
2 parents 5e36e45 + f555f71 commit 2046d04
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/AST/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2667,9 +2667,11 @@ ImportDeclRequest::evaluate(Evaluator &evaluator, const SourceFile *sf,
auto &ctx = sf->getASTContext();
auto imports = sf->getImports();

auto mutModule = const_cast<ModuleDecl *>(module);
// Look to see if the owning module was directly imported.
for (const auto &import : imports) {
if (import.module.importedModule == module)
if (import.module.importedModule
->isSameModuleLookingThroughOverlays(mutModule))
return import;
}

Expand All @@ -2678,7 +2680,8 @@ ImportDeclRequest::evaluate(Evaluator &evaluator, const SourceFile *sf,
for (const auto &import : imports) {
auto &importSet = importCache.getImportSet(import.module.importedModule);
for (const auto &transitive : importSet.getTransitiveImports()) {
if (transitive.importedModule == module) {
if (transitive.importedModule
->isSameModuleLookingThroughOverlays(mutModule)) {
return import;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend -swift-version 6 -I %t %s -emit-sil -o /dev/null -verify -parse-as-library

// REQUIRES: OS=macosx

import Foundation
@preconcurrency import Darwin

func mach_task_self() -> mach_port_t {
return mach_task_self_
}

0 comments on commit 2046d04

Please sign in to comment.