Skip to content

Commit 279b433

Browse files
committed
Root unqualified lookups with module selectors at file scope
1 parent abe2805 commit 279b433

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/AST/UnqualifiedLookup.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,9 @@ void UnqualifiedLookupFactory::performUnqualifiedLookup() {
249249
}
250250

251251
if (Loc.isValid() && DC->getParentSourceFile()) {
252-
// Operator lookup is always global, for the time being.
253-
if (!Name.isOperator())
252+
// Operator lookup is always global, for the time being. Unqualified lookups
253+
// with module selectors always start at global scope.
254+
if (!Name.isOperator() && !Name.hasModuleSelector())
254255
lookInASTScopes();
255256
} else {
256257
assert((DC->isModuleScopeContext() || !DC->getParentSourceFile()) &&

test/NameLookup/module_selector.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ extension C: @retroactive ModuleSelectorTestingKit::Equatable {
140140
if ModuleSelectorTestingKit::Bool.ModuleSelectorTestingKit::random() {
141141

142142
ModuleSelectorTestingKit::negate()
143+
// expected-error@-1 {{cannot find 'ModuleSelectorTestingKit::negate' in scope}}
143144
}
144145
else {
145146
self = ModuleSelectorTestingKit::C(value: .ModuleSelectorTestingKit::min)
@@ -204,11 +205,11 @@ extension D: @retroactive Swift::Equatable {
204205
}
205206

206207
let mog: Never = fatalError()
208+
// expected-note@-1 {{did you mean 'mog'?}}
207209

208210
func localVarsCantBeAccessedByModuleSelector() {
209211
let mag: Int.Swift::Magnitude = main::mag
210-
// expected-error@-1 {{use of local variable 'main::mag' before its declaration}}
211-
// expected-note@-2 {{'mag' declared here}}
212+
// expected-error@-1 {{cannot find 'main::mag' in scope}}
212213

213214
let mog: Never = main::mog
214215
}

0 commit comments

Comments
 (0)