Sema: (Mostly) check conformance availability

If a conformance is defined in an extension, we now look for
references to the conformance in types and expressions and
respect's the extension's availability (or deprecation, etc).

The conformance checker itself still needs to check conformance
availability of associated conformances and the like; that will
be a separate change.

Note that conformances defined on types don't require any
special handling, since they are as available as the
intersection of the conforming type and the protocol.

By default, we diagnose conformance availability violations
where the OS version is not sufficiently new as warnings, to
avoid breaking source compatibility. Stricter behavior where
these violations are diagnosed as errors is enabled by passing
the -enable-conformance-availability-errors flag. There are
test cases that run both with and without this flag. In the
future, we hope to make the stricter behavior the default,
since after all, violations here can result in link errors and
runtime crashes.

Uses of completely unavailable conformances are still always
diagnosed as errors, even when this flag is not passed in.

Progress on <rdar://problem/35158274>.
This commit is contained in:
Slava Pestov
2020-10-29 14:23:23 -04:00
parent f150bdd785
commit ceb8675ad1
10 changed files with 560 additions and 13 deletions

View File

@@ -391,6 +391,12 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.DisableAvailabilityChecking |=
Args.hasArg(OPT_disable_availability_checking);
if (auto A = Args.getLastArg(OPT_enable_conformance_availability_errors,
OPT_disable_conformance_availability_errors)) {
Opts.EnableConformanceAvailabilityErrors
= A->getOption().matches(OPT_enable_conformance_availability_errors);
}
if (auto A = Args.getLastArg(OPT_enable_access_control,
OPT_disable_access_control)) {
Opts.EnableAccessControl