Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0] Teach "find imports" to equate overlay modules with their underlying modules #74413

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_
}