Commit Graph

9 Commits

Author SHA1 Message Date
Allan Shortlidge
1f32e83e10 [Sema] Diagnose use of unavailable protocols in type erasing expressions (e.g. let x: P = S where S conforms to P).
Resolves rdar://83731428.
2022-01-28 14:05:12 -08:00
Allan Shortlidge
9346ad87df [Sema] When walking a member reference expression, if the member is provided by a protocol conformance be sure to check the availability of conformance.
Expands conformance availability tests to include test cases covering member references and key paths.

Resolves rdar://87795154.
2022-01-27 20:39:47 -08:00
Slava Pestov
daceb1677a Sema: Allow unavailable conformances to be referenced from unavailable contexts
Relaxes the conformance availability check to match the Swift 5.3 behavior
with unavailable types.

Fixes rdar://problem/75430966.
2021-05-03 23:40:46 -04:00
Slava Pestov
c346c4fd3b Sema: Relax witness availability check
We were checking that the witness is at least as available as
the intersection of the protocol and the conforming type.

In the case where the conformance is defined in an extension,
this should actually be the intersection of the protocol and
the _availability of the extension_.

Fixes <rdar://problem/74114880>.
2021-03-05 16:58:57 -05:00
Slava Pestov
3b051a2b7b Convert tabs to spaces in test/Sema/conformance_availability.swift 2020-11-12 15:57:21 -05:00
Slava Pestov
0ff82ca051 Sema: Check conformance availability when ranking solutions
This completes the work on <rdar://problem/35158274>, and also
adds a test case for <rdar://problem/50627401>.
2020-11-10 17:52:51 -05:00
Slava Pestov
db394c5428 Sema: Don't emit 'add @available attribute' fixit on implicit declarations 2020-11-09 23:44:40 -05:00
Slava Pestov
972cd5c9b6 Sema: Check associated conformance availability
This replaces the old exportability check with a call into the
new general conformance availability check entry point.

Part of <rdar://problem/35158274>.
2020-11-09 23:44:40 -05:00
Slava Pestov
ceb8675ad1 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>.
2020-11-05 17:51:45 -05:00