Skip to content

Commit 328096a

Browse files
committed
Sema: only mark the authoritative import as used in API
1 parent 2241bf5 commit 328096a

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

lib/Sema/TypeCheckAccess.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,15 +2507,9 @@ void swift::recordRequiredImportAccessLevelForDecl(
25072507
if (definingModule == dc->getParentModule())
25082508
return;
25092509

2510-
sf->registerRequiredAccessLevelForModule(definingModule, accessLevel);
2511-
25122510
if (auto attributedImport = sf->getImportAccessLevel(definingModule)) {
25132511
auto importedModule = attributedImport->module.importedModule;
2514-
2515-
// If the defining module is transitively imported, mark the responsible
2516-
// module as requiring the minimum access level too.
2517-
if (importedModule != definingModule)
2518-
sf->registerRequiredAccessLevelForModule(importedModule, accessLevel);
2512+
sf->registerRequiredAccessLevelForModule(importedModule, accessLevel);
25192513

25202514
if (dc->getASTContext().LangOpts.EnableModuleApiImportRemarks)
25212515
remark(*attributedImport);

test/Sema/authoritative-import-priority.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public func useTypesC(a: FarClangType) {}
133133
//--- ExportedClient_FileA.swift
134134
/// Prefer the defining module.
135135
public import NotLib // expected-warning {{public import of 'NotLib' was not used in public declarations or inlinable code}}
136-
public import LibCore
136+
public import LibCore // expected-warning {{public import of 'LibCore' was not used in public declarations or inlinable code}}
137137
public import Lib
138138

139139
public func useTypesA(a: ExportedType) {}
@@ -162,7 +162,7 @@ public func useTypesD(a: ExportedType) {}
162162

163163
//--- SwiftLibClient_FileA.swift
164164
/// Prefer the import matching public-module-name.
165-
public import SwiftPublicNameCore
165+
public import SwiftPublicNameCore // expected-warning {{public import of 'SwiftPublicNameCore' was not used in public declarations or inlinable code}}
166166
public import SwiftPublicName
167167

168168
public func useTypesA(a: SwiftStruct) {}

0 commit comments

Comments
 (0)