Skip to content

Commit c89a71a

Browse files
authored
Merge pull request #83710 from tbkka/tbkka-value-generics-in-stdlib
Allow value generics within the stdlib
2 parents c23cc5f + e11d3d2 commit c89a71a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -566,12 +566,16 @@ static void checkGenericParams(GenericContext *ownerCtx) {
566566
hasPack = true;
567567
}
568568

569-
if (gp->isValue()) {
570-
// Value generic nominal types require runtime support.
571-
//
572-
// Embedded doesn't require runtime support for this feature.
573-
if (isa<NominalTypeDecl>(decl) &&
574-
!ctx.LangOpts.hasFeature(Feature::Embedded)) {
569+
// Value generic nominal types require runtime support.
570+
if (gp->isValue() && isa<NominalTypeDecl>(decl)) {
571+
auto nomTypeDecl = cast<NominalTypeDecl>(decl);
572+
// But: Embedded doesn't require runtime support for this feature.
573+
// But: Stdlib/libswiftCore carries its own support,
574+
// so non-public stdlib declarations are safe
575+
if (!ctx.LangOpts.hasFeature(Feature::Embedded) &&
576+
!(decl->getModuleContext()->isStdlibModule() &&
577+
!nomTypeDecl->isAccessibleFrom(nullptr))) {
578+
// Everything else gets diagnosed for availability
575579
TypeChecker::checkAvailability(
576580
gp->getSourceRange(),
577581
ctx.getValueGenericTypeAvailability(),

0 commit comments

Comments
 (0)