Commit Graph

22 Commits

Author SHA1 Message Date
Holly Borla
c20b0e0956 [Concurrency] Obsolete AnyActor in Swift 6 using a typealias. 2024-05-29 22:59:19 -07:00
Slava Pestov
dde28e96a2 AST: Don't call getDirectlyInheritedNominalTypeDecls() on a protocol in ConformanceLookupTable 2024-02-24 07:25:59 -05:00
Kavon Farvardin
f296d8e158 NCGenerics: mass XFAIL tests
It's easier to get a handle on regressions while working through
failures if the tests that are known to not pass are XFAIL'd for
NoncopyableGenerics.
2024-02-20 18:26:05 -05:00
Harlan Haskins
4ac34a40ea @retroactive conformance syntax and checking (#36068) 2023-10-20 14:27:03 -07:00
Slava Pestov
250fbf2f3d Sema: Reject 'any P' in inheritance clauses 2022-02-23 23:10:10 -05:00
Slava Pestov
3701f745c4 Migrate various Sema tests to Swift 4 2018-06-25 01:02:20 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Dmitri Gribenko
984210aa53 tests: replace '// RUN: rm -rf' '// RUN: mkdir' pairs with '%empty-directory(...)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Doug Gregor
ef7b8039ec [Type checker] Warn about classes conforming to AnyObject in Swift 3 mode.
Swift 3 allowed a class to explicitly conform to AnyObject, although
it was meaningless. Recent AnyObject-related changes started rejecting
such conformances as ill-formed; allow them with a warning + Fix-It in
Swift 3 compatibility mode.
2017-05-04 10:28:27 -07:00
Slava Pestov
b5721e8d8e AST: Remove AnyObject protocol 2017-05-02 19:45:00 -07:00
Doug Gregor
f7bccb0e68 [Type checker] Downgrade some "redundant conformance" errors to warnings.
When an extension introduces a conformance that already exists, the
type checker will reject the conformance and then ignore it. In cases
where the original conformance is in the same module as the type or
protocol (but the new, redundant conformance is in some other module),
downgrade this error to a warning. This helps with library-evolution
cases where a library omitted a particular conformance for one of its
own types/protocols in a previous version, then introduces it in a new
version.

The specific driver for this is the conformance of String to
Collection, which affects source compatibility. Fixes
rdar://problem/31104415.
2017-05-01 13:22:15 -07:00
Joe Groff
6d9a40f455 Sema: Treat the implicit RawRepresentable conformance for enums as Synthesized again.
This reverts part of #4038 which made the compiler consider it to be an `Explicit` conformance, breaking source code that was accepted in Swift 3.0 which declared a raw type as well as explicit conformance to `RawRepresentable` (reported as rdar://problem/30386658). While I'm here, a couple of spot fixes:

- Ensure an enum's raw value exprs are type-checked before checking conformances of any of its extensions, since the RawRepresentable conformance derivation will blow up if the raw value exprs haven't been checked. Fixes an order dependency issue if `extension Foo: RawRepresentable {}` gets checked before `enum Foo: Int { ... }`.
- Don't display the custom `enum_declares_rawrep_with_raw_type` diagnostic if the source location for the enum's inheritance clause is invalid, so that we don't emit a dislocated diagnostic.
2017-02-08 15:31:17 -08:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Dmitri Gribenko
55864d10cb Tests: use 'mkdir -p' 2016-09-02 21:36:45 -07:00
SpringsUp
9432a84270 [Diagnostics QOI]: More descriptive errors for synthesized RawRepresentable enums 2016-08-23 01:03:03 +02:00
SpringsUp
f9af1257ef Tighter type-checking of enums with synthesized RawRepresentable
conformance
Fixes SR-2134
2016-08-22 22:49:48 +02:00
Dmitri Gribenko
65d840c0ae stdlib: lowercase cases in Optional and ImplicitlyUnwrappedOptional 2016-02-18 00:40:33 -08:00
Doug Gregor
8bd093d36b Eliminate the "ambiguous implied conformance" error.
Instead of requiring the user to disambiguate where an implied
protocol conformance goes---which they really, really don't care
about---just pick an arbitrary-but-deterministic location for the
conformance, which corresponds to the file unit in which the witness
table will be emitted. Fixes rdar://problem/21538899.

Swift SVN r30168
2015-07-13 21:56:40 +00:00
Doug Gregor
fea40a4dd2 Rank conformances implied by synthesized conformances as "synthesized".
This means that we prefer conformances implied by explicit
conformances (ones that the user wrote) over conformances implied by
synthesized conformances (those that the compiler would
generate). This resolves the ambiguity causing rdar://problem/21007417.

Swift SVN r28880
2015-05-21 17:14:28 +00:00
Jordan Rose
2ad796627a Revert "Prefer compiler-provided conformances to those required by other protocols."
This may not be the right solution. Even if it is, there are SourceKit tests
that need updating.

This reverts commit r28849 / rdar://problem/21007417.

Swift SVN r28852
2015-05-20 21:32:56 +00:00
Jordan Rose
1ad7651e19 Prefer compiler-provided conformances to those required by other protocols.
Previously, we'd warn on this code:

  enum Suit { case Spades, Hearts, Clubs, Diamonds }
  extension Suit : Comparable {}
  func <(...) {...}

because both Comparable and the synthesized conformance to Hashable imply
a conformance to Equatable. However, that's silly: Suit already has a
synthesized conformance to Equatable associated with the main 'enum'
declaration, not the extension. These compiler-provided conformances are
part of the language and something people rely on, so rank them higher than
conformances implied by conforming to a refined protocol.

rdar://problem/21007417

Swift SVN r28849
2015-05-20 20:48:04 +00:00
Doug Gregor
9271a24a92 Introduce a protocol conformance registry for nominal types.
(Note that this registry isn't fully enabled yet; it's built so that
we can test it, but has not yet taken over the primary task of
managing conformances from the existing system).

The conformance registry tracks all of the protocols to which a
particular nominal type conforms, including those for which
conformance was explicitly specified, implied by other explicit
conformances, inherited from a superclass, or synthesized by the
implementation.

The conformance registry is a lazily-built data structure designed for
multi-file support (which has been a problematic area for protocol
conformances). It allows one to query for the conformances of a type
to a particular protocol, enumerate all protocols to which a type
conforms, and enumerate all of the conformances that are associated
with a particular declaration context (important to eliminate
duplicated witness tables).

The conformance registry diagnoses conflicts and ambiguities among
different conformances of the same type to the same protocol. There
are three common cases where we'll see a diagnostic:

1) Redundant explicit conformance of a type to a protocol:

    protocol P { }
    struct X : P {  }
    extension X : P { } // error: redundant explicit conformance

2) Explicit conformance to a protocol that collides with an inherited
  conformance:

    protocol P { }
    class Super : P { }
    class Sub : Super, P { } // error: redundant explicit conformance

3) Ambiguous placement of an implied conformance:

    protocol P1 { }
    protocol P2 : P1 { }
    protocol P3 : P1 { }

    struct Y { }
    extension Y : P2 { }
    extension Y : P3 { } // error: ambiguous implied conformance to 'P1'

  This happens when two different explicit conformances (here, P2 and
  P3) placed on different declarations (e.g., two extensions, or the
  original definition and other extension) both imply the same
  conformance (P1), and neither of the explicit conformances imply
  each other. We require the user to explicitly specify the ambiguous
  conformance to break the ambiguity and associate the witness table
  with a specific context.

Swift SVN r26067
2015-03-12 21:11:23 +00:00