Sema: introduce SuppressedAssociatedTypesWithDefaults

This is similar to SuppressedAssociatedTypes, but infers
default requirements when primary associated types of
protocols are suppressed. This defaulting for the primary
associated types happens in extensions of the protocol,
along with generic parameters, whenever a source-written
requirement states a conformance requirement for the protocol.

Thus, the current scheme for this defaulting is a simplistic,
driven by source-written requirements, rather than facts
that are inferred while building generic signatures.

Defaults are not expanded for infinitely many associated types.

rdar://135168163
This commit is contained in:
Kavon Farvardin
2025-11-13 16:29:33 -08:00
parent 761502fabe
commit 6f95203dfd
23 changed files with 978 additions and 74 deletions

View File

@@ -1316,6 +1316,13 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
if (ParseEnabledFeatureArgs(Opts, Args, Diags, FrontendOpts))
HadError = true;
// Do not allow both versions of SuppressedAssociatedTypes at the same time.
// Pick the version with defaults if both are specified.
if (Opts.hasFeature(SuppressedAssociatedTypes) &&
Opts.hasFeature(SuppressedAssociatedTypesWithDefaults)) {
Opts.disableFeature(SuppressedAssociatedTypes);
}
Opts.EnableAppExtensionLibraryRestrictions |= Args.hasArg(OPT_enable_app_extension_library);
Opts.EnableAppExtensionRestrictions |= Args.hasArg(OPT_enable_app_extension);
Opts.EnableAppExtensionRestrictions |= Opts.EnableAppExtensionLibraryRestrictions;