@@ -406,84 +406,6 @@ bool swift::isAdditiveArithmeticConformanceDerivationEnabled(SourceFile &SF) {
406
406
return isDifferentiableProgrammingEnabled (SF);
407
407
}
408
408
409
- void swift::checkInconsistentImplementationOnlyImports (ModuleDecl *MainModule) {
410
- bool hasAnyImplementationOnlyImports =
411
- llvm::any_of (MainModule->getFiles (), [](const FileUnit *F) -> bool {
412
- auto *SF = dyn_cast<SourceFile>(F);
413
- return SF && SF->hasImplementationOnlyImports ();
414
- });
415
- if (!hasAnyImplementationOnlyImports)
416
- return ;
417
-
418
- auto diagnose = [MainModule](const ImportDecl *normalImport,
419
- const ImportDecl *implementationOnlyImport) {
420
- auto &diags = MainModule->getDiags ();
421
- {
422
- InFlightDiagnostic warning =
423
- diags.diagnose (normalImport, diag::warn_implementation_only_conflict,
424
- normalImport->getModule ()->getName ());
425
- if (normalImport->getAttrs ().isEmpty ()) {
426
- // Only try to add a fix-it if there's no other annotations on the
427
- // import to avoid creating things like
428
- // `@_implementationOnly @_exported import Foo`. The developer can
429
- // resolve those manually.
430
- warning.fixItInsert (normalImport->getStartLoc (),
431
- " @_implementationOnly " );
432
- }
433
- }
434
- diags.diagnose (implementationOnlyImport,
435
- diag::implementation_only_conflict_here);
436
- };
437
-
438
- llvm::DenseMap<ModuleDecl *, std::vector<const ImportDecl *>> normalImports;
439
- llvm::DenseMap<ModuleDecl *, const ImportDecl *> implementationOnlyImports;
440
-
441
- for (const FileUnit *file : MainModule->getFiles ()) {
442
- auto *SF = dyn_cast<SourceFile>(file);
443
- if (!SF)
444
- continue ;
445
-
446
- for (auto *topLevelDecl : SF->getTopLevelDecls ()) {
447
- auto *nextImport = dyn_cast<ImportDecl>(topLevelDecl);
448
- if (!nextImport)
449
- continue ;
450
-
451
- ModuleDecl *module = nextImport->getModule ();
452
- if (!module )
453
- continue ;
454
-
455
- if (nextImport->getAttrs ().hasAttribute <ImplementationOnlyAttr>()) {
456
- // We saw an implementation-only import.
457
- bool isNew =
458
- implementationOnlyImports.insert ({module , nextImport}).second ;
459
- if (!isNew)
460
- continue ;
461
-
462
- auto seenNormalImportPosition = normalImports.find (module );
463
- if (seenNormalImportPosition != normalImports.end ()) {
464
- for (auto *seenNormalImport : seenNormalImportPosition->getSecond ())
465
- diagnose (seenNormalImport, nextImport);
466
-
467
- // We're done with these; keep the map small if possible.
468
- normalImports.erase (seenNormalImportPosition);
469
- }
470
- continue ;
471
- }
472
-
473
- // We saw a non-implementation-only import. Is that in conflict with what
474
- // we've seen?
475
- if (auto *seenImplementationOnlyImport =
476
- implementationOnlyImports.lookup (module )) {
477
- diagnose (nextImport, seenImplementationOnlyImport);
478
- continue ;
479
- }
480
-
481
- // Otherwise, record it for later.
482
- normalImports[module ].push_back (nextImport);
483
- }
484
- }
485
- }
486
-
487
409
bool swift::performTypeLocChecking (ASTContext &Ctx, TypeLoc &T,
488
410
DeclContext *DC,
489
411
bool ProduceDiagnostics) {
0 commit comments