@@ -395,26 +395,32 @@ UnboundImport::getTopLevelModule(ModuleDecl *M, SourceFile &SF) {
395
395
ImplicitImportList
396
396
ModuleImplicitImportsRequest::evaluate (Evaluator &evaluator,
397
397
ModuleDecl *module ) const {
398
- SmallVector<ImplicitImport , 4 > imports;
398
+ SmallVector<AttributedImport<ImportedModule> , 4 > imports;
399
399
400
400
auto &ctx = module ->getASTContext ();
401
401
auto &importInfo = module ->getImplicitImportInfo ();
402
402
403
403
// Add an implicit stdlib if needed.
404
+ ModuleDecl *stdlib;
404
405
switch (importInfo.StdlibKind ) {
405
406
case ImplicitStdlibKind::None:
407
+ stdlib = nullptr ;
406
408
break ;
407
409
case ImplicitStdlibKind::Builtin:
408
- imports. emplace_back ( ctx.TheBuiltinModule ) ;
410
+ stdlib = ctx.TheBuiltinModule ;
409
411
break ;
410
412
case ImplicitStdlibKind::Stdlib: {
411
- auto * stdlib = ctx.getStdlibModule (/* loadIfAbsent*/ true );
413
+ stdlib = ctx.getStdlibModule (/* loadIfAbsent*/ true );
412
414
assert (stdlib && " Missing stdlib?" );
413
- imports.emplace_back (stdlib);
414
415
break ;
415
416
}
416
417
}
417
418
419
+ if (stdlib) {
420
+ ImportedModule import (ImportPath::Access (), stdlib);
421
+ imports.emplace_back (import , ImportOptions ());
422
+ }
423
+
418
424
// Add any modules we were asked to implicitly import.
419
425
for (auto moduleName : importInfo.ModuleNames ) {
420
426
auto *importModule = ctx.getModuleByIdentifier (moduleName);
@@ -427,13 +433,15 @@ ModuleImplicitImportsRequest::evaluate(Evaluator &evaluator,
427
433
}
428
434
continue ;
429
435
}
430
- imports.emplace_back (importModule);
436
+ ImportedModule import (ImportPath::Access (), importModule);
437
+ imports.emplace_back (import , ImportOptions ());
431
438
}
432
439
433
440
// Add any pre-loaded modules.
434
441
for (auto &module : importInfo.AdditionalModules ) {
435
- imports.emplace_back (module .first , module .second ? ImportFlags::Exported
436
- : ImportOptions ());
442
+ ImportedModule import (ImportPath::Access (), module .first );
443
+ imports.emplace_back (import , module .second ? ImportFlags::Exported
444
+ : ImportOptions ());
437
445
}
438
446
439
447
auto *clangImporter =
@@ -445,15 +453,17 @@ ModuleImplicitImportsRequest::evaluate(Evaluator &evaluator,
445
453
!clangImporter->importBridgingHeader (bridgingHeaderPath, module )) {
446
454
auto *headerModule = clangImporter->getImportedHeaderModule ();
447
455
assert (headerModule && " Didn't load bridging header?" );
448
- imports.emplace_back (headerModule, ImportFlags::Exported);
456
+ ImportedModule import (ImportPath::Access (), headerModule);
457
+ imports.emplace_back (import , ImportFlags::Exported);
449
458
}
450
459
451
460
// Implicitly import the underlying Clang half of this module if needed.
452
461
if (importInfo.ShouldImportUnderlyingModule ) {
453
462
auto *underlyingMod = clangImporter->loadModule (
454
463
SourceLoc (), ImportPath::Module::Builder (module ->getName ()).get ());
455
464
if (underlyingMod) {
456
- imports.emplace_back (underlyingMod, ImportFlags::Exported);
465
+ ImportedModule import (ImportPath::Access (), underlyingMod);
466
+ imports.emplace_back (import , ImportFlags::Exported);
457
467
} else {
458
468
ctx.Diags .diagnose (SourceLoc (), diag::error_underlying_module_not_found,
459
469
module ->getName ());
@@ -469,9 +479,8 @@ void ImportResolver::addImplicitImports() {
469
479
// TODO: Support cross-module imports.
470
480
for (auto &import : implicitImports.imports ) {
471
481
assert (!(SF.Kind == SourceFileKind::SIL &&
472
- import .Module ->isStdlibModule ()));
473
- ImportedModule importedMod{ImportPath::Access (), import .Module };
474
- boundImports.emplace_back (importedMod, import .Options );
482
+ import .module .importedModule ->isStdlibModule ()));
483
+ boundImports.push_back (import );
475
484
}
476
485
}
477
486
0 commit comments