mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Protect the operator/precedencegroup lookup code against modules that
import themselves. It's not clear to me whether this situation is really intended, but this does fix build modules with this strange situation.
This commit is contained in:
@@ -1008,8 +1008,13 @@ lookupOperatorDeclForName(const FileUnit &File, SourceLoc Loc, Identifier Name,
|
||||
// Record whether they come from re-exported modules.
|
||||
// FIXME: We ought to prefer operators elsewhere in this module before we
|
||||
// check imports.
|
||||
auto ownModule = SF.getParentModule();
|
||||
ImportedOperatorsMap<OP_DECL> importedOperators;
|
||||
for (auto &imported : SourceFile::Impl::getImportsForSourceFile(SF)) {
|
||||
// Protect against source files that contrive to import their own modules.
|
||||
if (imported.first.second == ownModule)
|
||||
continue;
|
||||
|
||||
bool isExported =
|
||||
imported.second.contains(SourceFile::ImportFlags::Exported);
|
||||
if (!includePrivate && !isExported)
|
||||
|
||||
12
test/ClangModules/overlay_with_submodule.swift
Normal file
12
test/ClangModules/overlay_with_submodule.swift
Normal file
@@ -0,0 +1,12 @@
|
||||
// RUN: %target-swift-frontend -emit-module %s -sdk %S/Inputs -module-name HasSubmodule -I %S/Inputs/custom-modules -o %t
|
||||
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
@_exported import HasSubmodule
|
||||
@_exported import HasSubmodule.Submodule
|
||||
|
||||
func useAnOperator() -> Int {
|
||||
var x : Int
|
||||
x = 1 + 2 // Forces a lookup of precedence groups
|
||||
return x
|
||||
}
|
||||
Reference in New Issue
Block a user