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 @@ -472,6 +472,8 @@ void UnqualifiedLookupFactory::setAsideUnavailableResults(
472
472
}
473
473
474
474
void UnqualifiedLookupFactory::addImportedResults (const DeclContext *const dc) {
475
+ assert (dc);
476
+
475
477
using namespace namelookup ;
476
478
SmallVector<ValueDecl *, 8 > CurModuleResults;
477
479
auto resolutionKind = isOriginallyTypeLookup ? ResolutionKind::TypesOnly
@@ -483,6 +485,10 @@ void UnqualifiedLookupFactory::addImportedResults(const DeclContext *const dc) {
483
485
// We'd need a new ResolutionKind.
484
486
moduleToLookIn =
485
487
dc->getASTContext ().getLoadedModule (Name.getModuleSelector ());
488
+
489
+ // If we didn't find the module, it obviously can't have any results.
490
+ if (!moduleToLookIn)
491
+ return ;
486
492
487
493
auto nlOptions = NL_UnqualifiedDefault;
488
494
if (options.contains (Flags::IncludeUsableFromInline))
Original file line number Diff line number Diff line change @@ -449,3 +449,19 @@ precedencegroup main::PG1 {
449
449
higherThan: Swift: : AdditionPrecedence
450
450
// expected-error@-1 {{precedence group specifier cannot be qualified with module selector}}
451
451
}
452
+
453
+ func badModuleNames( ) {
454
+ NonexistentModule: : print( )
455
+ // expected-error@-1 {{declaration 'print' is not imported through module 'NonexistentModule'}}
456
+ // expected-note@-2 {{did you mean module 'Swift'?}} {{3-20=Swift}}
457
+ // FIXME redundant: expected-note@-3 {{did you mean module 'Swift'?}}
458
+
459
+ _ = " foo " . NonexistentModule: : count
460
+ // FIXME improve: expected-error@-1 {{value of type 'String' has no member 'NonexistentModule::count'}}
461
+
462
+ let x : NonexistentModule : : MyType = NonexistentModule: : MyType( )
463
+ // expected-error@-1 {{use of undeclared type 'NonexistentModule::MyType'}}
464
+
465
+ let y : A . NonexistentModule : : MyChildType = fatalError ( )
466
+ // expected-error@-1 {{'NonexistentModule::MyChildType' is not a member type of 'A'}}
467
+ }
You can’t perform that action at this time.
0 commit comments