Commit Graph

23 Commits

Author SHA1 Message Date
Pavel Yaskevich
ebdb5c7776 [ConstraintSystem] Improve handling of ambiguities related to fixes
Solutions passed to `diagnoseAmbiguityWithFixes` aren't filtered
so we need to remove all of the solutions with the score worse
than overall "best". Also logic has to account for some fixes being
"warnings".
2019-12-03 12:07:16 -08:00
Luciano Almeida
1184492d25 [Diagnostics] SR-11419 Diagnose protocol stub note in editor mode only (#28101)
* [TypeChecker] Enclosing stubs protocol note within editor mode

* [test] Removing note from test where there is no -diagnostics-editor-mode flag

* Formatting modified code

* [tests] Fixing tests under validation-tests
2019-11-06 07:42:48 -08:00
Xi Ge
1535bea268 FixCode: issue a separate note for protocol-stub fixit when the fixit location is in another file
Under non-editor mode, the fixit for inserting protocol stubs is associated with a note
pointing to the missing protocol member declaration which could stay in a separate file from
the conforming type, leading to the behavior of rdar://51534405. This change checks if
the fixit is in a separate file and issues another note to carry the fixit if so.

rdar://51534405
2019-07-10 12:30:54 -07:00
Owen Voorhees
e273d05460 [Sema] Add notes to explain why Equatable/Hashable conformance couldn't be synthesized
If a struct/enum cannot have Equatable/Hashable conformance automatically synthesized because a member's type is not Equatable/Hashable, add a note to the existing 'does not conform' diagnostic pointing out the type that blocked synthesis.
2019-06-08 13:02:49 -07:00
Suyash Srijan
8928431cbe [sema] support weak/unowned variables when checking for conformance 2019-01-26 02:57:45 +00:00
Karoy Lorentey
cb3cff55f9 [test] Test new deprecation warning for hashValue implementations 2018-12-05 19:00:55 +00:00
Karoy Lorentey
666a22feff [test] Modernize hashing throughout the test suite 2018-11-29 17:38:29 +00:00
Matt Diephouse
5e9da14b5a Pare down operator candidates during protocol type checking 2018-08-28 08:41:15 -04:00
Huon Wilson
80a74b4dfc [AST] Choose an implied conformance source next to the type, if possible.
If a conformance to a protocol is implied by several other
conformances (i.e. protocol P: Equatable {} and protocol Q: Equatable {} and a
type declares conformance to both P and Q), we should choose a source that's in
the same file as the type, if we can, because automatic synthesis of
conformances (for Equatable, Hashable, etc.) only works in that case.

Fixes rdar://problem/41852654.
2018-07-06 18:24:21 +10:00
Huon Wilson
d3dc80da6b [test] Avoid needing an entry point in struct/enum synthesis conformance tests.
The special handling of interleaved decls and statements is confusing and makes
other testing hard.
2018-07-06 18:24:21 +10:00
Huon Wilson
fe7240ab8a [Sema] Disallow synthesis-in-extensions in Swift 3.
'private' properties can't be accessed in extensions in Swift 3, so synthesizing
a conformance that reads from such things is going to be incorrect in an
extension.
2018-05-09 09:55:41 +10:00
Huon Wilson
47e643af0e [Sema] Fix synthesis of Equatable and Hashable conformances in extensions of generic types.
https://bugs.swift.org/browse/SR-6803
2018-05-07 09:41:25 +10:00
Huon Wilson
3488a3a53b [Sema] Allow synthesis of protocol conformances in extensions.
This works for all protocols except for Decodable on non-final classes, because
the init requirement has to be 'required' and thus in the type's declaration.

Fixes most of https://bugs.swift.org/browse/SR-6803.
2018-05-07 09:41:25 +10:00
Karoy Lorentey
110ee052b1 [SE-0206][test] Update diagnostic tests for Hashable derivation 2018-04-24 17:43:23 +01:00
Saleem Abdulrasool
b67d5f0cf7 test: convert rm -rf && mkdir -p into %empty-directory
This converts the instances of the pattern for which we have a proper
substitution in lit.  This will make it easier to replace it
appropriately with Windows equivalents.
2018-03-06 14:30:54 -08:00
Alex Hoppen
8d3652ad61 [Sema] Translate names in unused result warnings of implicit functions
Instead of warning about an unused result of a call to an implicit
function '__derived_enum_equals' or '__derived_struct_equals' use its
user-facing name '=='.
2017-12-26 17:19:52 +01:00
Tony Allevato
aef3d09a1f "yet" was removed from some diagnostics by 21b2073b 2017-09-21 23:55:18 -07:00
Tony Allevato
1d5ef700cc Fix some typos 2017-08-21 07:28:17 -07:00
Tony Allevato
fca78a3634 [Sema] Fix type checking for enums defined in other files 2017-08-08 18:30:22 -07:00
Tony Allevato
fd93e03768 [Sema] Forbid synthesis in an extension
The exception is if the conformance is already redundant (for example,
the implicit synthesis for RawRepresentable enums).
2017-08-08 18:30:22 -07:00
Tony Allevato
a3db968057 Move derivesProtocolConformances from AST to Sema 2017-08-08 18:30:22 -07:00
Tony Allevato
aa93ee52e1 Formatting and other cleanup. 2017-08-08 18:30:22 -07:00
Tony Allevato
5f39659155 [test] Update enum Equatable/Hashable tests 2017-08-08 18:20:58 -07:00