@@ -1483,14 +1483,11 @@ class UsableFromInlineChecker : public AccessControlCheckerBase,
1483
1483
}
1484
1484
};
1485
1485
1486
- // Diagnose public APIs exposing types that are either imported as
1487
- // implementation-only or declared as SPI.
1488
1486
class ExportabilityChecker : public DeclVisitor <ExportabilityChecker> {
1489
1487
class Diagnoser ;
1490
1488
1491
1489
void checkTypeImpl (
1492
1490
Type type, const TypeRepr *typeRepr, const SourceFile &SF,
1493
- const Decl *context,
1494
1491
const Diagnoser &diagnoser) {
1495
1492
// Don't bother checking errors.
1496
1493
if (type && type->hasError ())
@@ -1503,15 +1500,14 @@ class ExportabilityChecker : public DeclVisitor<ExportabilityChecker> {
1503
1500
if (typeRepr) {
1504
1501
const_cast <TypeRepr *>(typeRepr)->walk (TypeReprIdentFinder (
1505
1502
[&](const ComponentIdentTypeRepr *component) {
1506
- TypeDecl *typeDecl = component->getBoundDecl ();
1507
- ModuleDecl *M = typeDecl->getModuleContext ();
1508
- bool isImplementationOnly = SF.isImportedImplementationOnly (M);
1509
- if (isImplementationOnly ||
1510
- (SF.isImportedAsSPI (typeDecl) && !context->isSPI ())) {
1511
- diagnoser.diagnoseType (typeDecl, component, isImplementationOnly);
1512
- foundAnyIssues = true ;
1513
- }
1514
-
1503
+ ModuleDecl *M = component->getBoundDecl ()->getModuleContext ();
1504
+ if (!SF.isImportedImplementationOnly (M) &&
1505
+ !SF.isImportedAsSPI (component->getBoundDecl ()))
1506
+ return true ;
1507
+
1508
+ diagnoser.diagnoseType (component->getBoundDecl (), component,
1509
+ SF.isImportedImplementationOnly (M));
1510
+ foundAnyIssues = true ;
1515
1511
// We still continue even in the diagnostic case to report multiple
1516
1512
// violations.
1517
1513
return true ;
@@ -1529,19 +1525,19 @@ class ExportabilityChecker : public DeclVisitor<ExportabilityChecker> {
1529
1525
1530
1526
class ProblematicTypeFinder : public TypeDeclFinder {
1531
1527
const SourceFile &SF;
1532
- const Decl *context;
1533
1528
const Diagnoser &diagnoser;
1534
1529
public:
1535
- ProblematicTypeFinder (const SourceFile &SF, const Decl *context, const Diagnoser &diagnoser)
1536
- : SF(SF), context(context), diagnoser(diagnoser) {}
1530
+ ProblematicTypeFinder (const SourceFile &SF, const Diagnoser &diagnoser)
1531
+ : SF(SF), diagnoser(diagnoser) {}
1537
1532
1538
1533
void visitTypeDecl (const TypeDecl *typeDecl) {
1539
1534
ModuleDecl *M = typeDecl->getModuleContext ();
1540
- bool isImplementationOnly = SF.isImportedImplementationOnly (M);
1541
- if (isImplementationOnly ||
1542
- (SF.isImportedAsSPI (typeDecl) && !context->isSPI ()))
1543
- diagnoser.diagnoseType (typeDecl, /* typeRepr*/ nullptr ,
1544
- isImplementationOnly);
1535
+ if (!SF.isImportedImplementationOnly (M) &&
1536
+ !SF.isImportedAsSPI (typeDecl))
1537
+ return ;
1538
+
1539
+ diagnoser.diagnoseType (typeDecl, /* typeRepr*/ nullptr ,
1540
+ SF.isImportedImplementationOnly (M));
1545
1541
}
1546
1542
1547
1543
void visitSubstitutionMap (SubstitutionMap subs) {
@@ -1601,15 +1597,15 @@ class ExportabilityChecker : public DeclVisitor<ExportabilityChecker> {
1601
1597
}
1602
1598
};
1603
1599
1604
- type.walk (ProblematicTypeFinder (SF, context, diagnoser));
1600
+ type.walk (ProblematicTypeFinder (SF, diagnoser));
1605
1601
}
1606
1602
1607
1603
void checkType (
1608
1604
Type type, const TypeRepr *typeRepr, const Decl *context,
1609
1605
const Diagnoser &diagnoser) {
1610
1606
auto *SF = context->getDeclContext ()->getParentSourceFile ();
1611
1607
assert (SF && " checking a non-source declaration?" );
1612
- return checkTypeImpl (type, typeRepr, *SF, context, diagnoser);
1608
+ return checkTypeImpl (type, typeRepr, *SF, diagnoser);
1613
1609
}
1614
1610
1615
1611
void checkType (
@@ -1706,7 +1702,7 @@ class ExportabilityChecker : public DeclVisitor<ExportabilityChecker> {
1706
1702
AccessScope accessScope =
1707
1703
VD->getFormalAccessScope (nullptr ,
1708
1704
/* treatUsableFromInlineAsPublic*/ true );
1709
- if (accessScope.isPublic ())
1705
+ if (accessScope.isPublic () && !accessScope. isSPI () )
1710
1706
return false ;
1711
1707
1712
1708
// Is this a stored property in a non-resilient struct or class?
0 commit comments