File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -381,6 +381,8 @@ void UnqualifiedLookupFactory::setAsideUnavailableResults(
381
381
}
382
382
383
383
void UnqualifiedLookupFactory::addImportedResults (const DeclContext *const dc) {
384
+ assert (dc);
385
+
384
386
using namespace namelookup ;
385
387
SmallVector<ValueDecl *, 8 > CurModuleResults;
386
388
auto resolutionKind = isOriginallyTypeLookup ? ResolutionKind::TypesOnly
@@ -391,6 +393,10 @@ void UnqualifiedLookupFactory::addImportedResults(const DeclContext *const dc) {
391
393
// We'd need a new ResolutionKind.
392
394
moduleToLookIn =
393
395
dc->getASTContext ().getLoadedModule (Name.getModuleSelector ());
396
+
397
+ // If we didn't find the module, it obviously can't have any results.
398
+ if (!moduleToLookIn)
399
+ return ;
394
400
395
401
auto nlOptions = NL_UnqualifiedDefault;
396
402
if (options.contains (Flags::IncludeUsableFromInline))
Original file line number Diff line number Diff line change @@ -448,3 +448,19 @@ precedencegroup main::PG1 {
448
448
higherThan: Swift: : AdditionPrecedence
449
449
// expected-error@-1 {{precedence group specifier cannot be qualified with module selector}}
450
450
}
451
+
452
+ func badModuleNames( ) {
453
+ NonexistentModule: : print( )
454
+ // expected-error@-1 {{declaration 'print' is not imported through module 'NonexistentModule'}}
455
+ // expected-note@-2 {{did you mean module 'Swift'?}} {{3-20=Swift}}
456
+ // FIXME redundant: expected-note@-3 {{did you mean module 'Swift'?}}
457
+
458
+ _ = " foo " . NonexistentModule: : count
459
+ // FIXME improve: expected-error@-1 {{value of type 'String' has no member 'NonexistentModule::count'}}
460
+
461
+ let x : NonexistentModule : : MyType = NonexistentModule: : MyType( )
462
+ // expected-error@-1 {{use of undeclared type 'NonexistentModule::MyType'}}
463
+
464
+ let y : A . NonexistentModule : : MyChildType = fatalError ( )
465
+ // expected-error@-1 {{'NonexistentModule::MyChildType' is not a member type of 'A'}}
466
+ }
You can’t perform that action at this time.
0 commit comments