Commit Graph

2041 Commits

Author SHA1 Message Date
Suyash Srijan
5cbfeb7b83 Merge pull request #27026 from theblixguy/fix/SR--11412
[CSDiagnostics] Offer protocol conformance fix-it in ContextualFailure
2019-09-06 00:44:38 +01:00
Varun Gandhi
0dcb936531 Serialize extended nominal separately when serializing an extension.
Instead of computing it from the extended type after deserialization --
which is tricky to do, due to potential presence of protocol
compositions -- we obtain the extended nominal directly.

Fixes SR-11227 and linked rdar://problem/53712389.
2019-09-05 15:33:02 -07:00
Owen Voorhees
68e6065c8e [Diagnostics][NFC] Introduce Structured fix-its
These are defined with macros like errors/warnings/notes, and
make use of format strings and diagnostic arguments. The intent
is to leverage diagnostic arguments in the future to disambiguate
ambiguously spelled types.

Ported a few miscellaneous fix-its to the new system
2019-09-05 10:43:25 -07:00
Suyash Srijan
ab1184208a [CSDiagnostics] Offer a fix-it to conform the decl context to the missing protocols during contextual failure 2019-09-05 02:50:24 +01:00
Robert Widmann
59687518e2 Reject nominal extensions (with a bit of indirection)
If the canonical type is a nominal type then we can offer a diagnostic
that rewrites to it.

Resolves rdar://54799560
2019-09-01 01:52:41 -05:00
Suyash Srijan
bd53fe355d Revert "[CS] Don't crash when default argument is magic literal and types don't match" 2019-08-31 00:54:37 +01:00
Owen Voorhees
9222dfdd46 [Sema] Fix protocol refinement access control message (#26855)
Previously, the protocol refinement access control error
would always assume a protocol was being refined. Change it
to instead refer to the appropriate declaration kind.

Resolves SR-9195
2019-08-29 17:47:24 -07:00
Jordan Rose
7e9e4b5e5b Merge pull request #26836 from owenv/select_modifier_str_support
[Diagnostics][NFC] Add support for using the %select format specifier…
2019-08-26 16:58:54 -07:00
Owen Voorhees
486c7b883d [Diagnostics][NFC] Add support for using the %select format specifier with StringRef args
Get rid of some redundant availability diagnostics as a result.
2019-08-26 11:37:29 -07:00
Suyash Srijan
bb85ecb8b5 [Typechecker] Diagnose @dynamicMemberLookup subscript when it lacks an explicit argument label 2019-08-25 00:03:07 +01:00
Pavel Yaskevich
075e92b182 Merge pull request #26576 from LucianoPAlmeida/SR-10597-name-lookup-failure-diagnostics
SR-10597 KeyPath dynamic member lookup
2019-08-12 18:00:45 -07:00
Luciano Almeida
55907fbd0f Adding no corrections diagnostic for dynamic member 2019-08-12 19:25:38 -03:00
Varun Gandhi
68fb3b1f44 Merge pull request #26357 from varungandhi-apple/vg-fix-nested-exhaustiveness-check
Correctly distinguish between tuple fields and associated values in patterns
2019-08-12 13:58:48 -07:00
Varun Gandhi
e365b6be7d Implicitly untuple patterns if applicable and add warnings. 2019-08-12 09:58:22 -07:00
Luciano Almeida
a7b5f714e4 Apply diagnostic message suggestion 2019-08-09 23:47:42 -03:00
Luciano Almeida
a5db6bf0a5 Apply suggestions from code review
Co-Authored-By: Xiaodi Wu <xiaodi.wu@gmail.com>
2019-08-09 23:37:00 -03:00
Luciano Almeida
80c20a4dd3 Improving diagnostic message 2019-08-09 06:58:39 -03:00
Luciano Almeida
d55e1f6055 Adding diagnostic to fix SR-10597 2019-08-08 23:33:43 -03:00
Holly Borla
e76f5f1d0b [Diagnostics] Improve the diagnostic for invalid pointer conversion for an autoclosure result type.
Add constraint fix `AllowAutoClosurePointerConversion` and corresponding diagnostic
`AutoClosurePointerConversionFailure`. When we discover that we're trying to do an
inout-to-pointer conversion in `matchTypes`, add the constraint fix, which tries to do the
conversion as if the pointer type is a regular function argument.
2019-08-02 14:16:06 -07:00
Joe Groff
4db3938f78 Merge pull request #26408 from davezarzycki/simplify_code_synth_diag
[CodeSynth] NFC: Simplify diagnostic output
2019-07-31 08:26:34 -07:00
Andrew Trick
c8a16d3d9b Merge pull request #26041 from atrick/remove-ptrcast-diag
Remove the Swift-3-era pointer casting diagnostic.
2019-07-30 09:59:00 -07:00
David Zarzycki
2734fe55cc [CodeSynth] NFC: Simplify diagnostic output 2019-07-30 11:40:46 +01:00
Holly Borla
fd03db42cf Merge remote-tracking branch 'upstream/master' into init-kind-request 2019-07-29 13:39:56 -07:00
Holly Borla
9d00f42c46 Sema: compute InitKindRequest::evaluate in a more performant way.
Use `getSelfNominalTypeDecl` rather than `getDeclaredInterfaceType` in
`InitKindRequest::evaluate`, since it's cheaper to perform.
2019-07-29 13:36:38 -07:00
Joe Groff
61261fcddf Merge pull request #26326 from jckarter/property-wrapper-composition-mutatiness
Sema: Correct composition of property wrappers.
2019-07-27 10:16:44 -07:00
Joe Groff
fa4dd15612 Sema: Correct composition of property wrappers.
Fixes rdar://problem/53407949 | SR-11138. Previously, we'd only look at the outermost property wrapper to decide whether the wrapped property's getter and setter were `mutating` (or exist at all). In reality, this requires considering the semantics of the composed accesses of each wrapper layer's
`wrappedValue` property. Fixing this systematically addresses a number of issues:

- As SR-11138 reported, composing a nonmutating-get-set wrapper ought to produce a composed wrapper
  that's nonmutating.

- We would previously allow a property wrapper with a mutating getter to be nested inside one with
  only a getter, even though the resulting implementation was unsound (because there's no mutable
  context for the inner wrapper to execute its get on.)

- Similarly, we would construct unsound setters in cases where the setter can't exist, such as when
  the nested wrapper isn't settable but the outer wrapper is.
2019-07-26 16:09:54 -07:00
Joe Groff
1446b60801 Reenable property wrapper composition.
This reverts commit 5e08f7da32.
2019-07-25 15:50:21 -07:00
Pavel Yaskevich
1b4f9c33eb [Diagnostic] In no exact match cases diagnose labeling mismatch as a note
Each candidate with incorrect labels (but everything else lined up)
gets a note on its declarationm which says what is expected and what
has been given.
2019-07-25 14:49:52 -07:00
Slava Pestov
8047ddae82 Sema: Move finishStorageImplInfo() to StorageImplInfoRequest evaluation
This merges Sema's special logic for updating the ImplInfo of lazy properties
and property wrappers with the StorageImplInfoRequest.

I had to move some code from the parser into the StorageImplInfoRequest, to
avoid request cycles caused by hasStorage() calls; this is the right thing to
do anyway.

Since hasStorage() now answers false for lazy properties and property wrappers,
we have to move some diagnostic checks from checkDeclAttributesEarly() to
the StorageImplInfoRequest implementation itself.

Over time, I expect all of the checks currently in checkDeclAttributesEarly()
and checkDeclAttributes() to either migrate to requests, or typeCheckDecl().
2019-07-23 22:00:31 -04:00
Joe Groff
03dcccb828 Merge pull request #26287 from jckarter/disable-property-wrapper-composition
Disable property wrapper composition.
2019-07-23 12:39:12 -07:00
Joe Groff
5e08f7da32 Disable property wrapper composition.
There are ABI-affecting bugs with composition like SR-11138, so disable until those bugs can be
fixed. rdar://problem/53428736
2019-07-22 19:50:01 -07:00
Slava Pestov
a532a325e1 AST: Move a few methods from VarDecl down to ParamDecl 2019-07-22 20:19:09 -04:00
Pavel Yaskevich
c28174a26c Merge pull request #26262 from xedin/new-diag-for-non-matching-overloads
[CSDiagnostics] Use special error message when call didn't match exactly
2019-07-22 13:46:40 -07:00
Pavel Yaskevich
783add0ea4 [CSDiagnostics] Split no exact match diagnostic into three choices
1. If this is a special name avoid printing it because
   printing kind is sufficient;

2. If all of the labels match, print a full name;

3. If labels in different choices are different, it means
   that we can only print a base name.
2019-07-22 12:32:17 -07:00
Pavel Yaskevich
caf266f4b1 [CSDiagnostics] Use special error message when call didn't match exactly
For multiple solutions with fixes for the same call, replace
`ambiguous reference` diagnostic with the one that explicitly
mentions that there are no exact matches, and provide partially
matched candidates as notes.
2019-07-22 11:20:56 -07:00
Pavel Yaskevich
5fe29a719b Merge pull request #26219 from theblixguy/fix/SR-11060
[CSDiag] Add a new diagnostic for @propertyWrapper implicit init call missing arguments
2019-07-19 09:45:37 -07:00
Suyash Srijan
f47f5c44e4 [CSDiag] Adds a new diagnostic for implicit propertyWrapper initializer 2019-07-18 23:06:03 +01:00
Holly Borla
71fb2629ac Sema: implement requiresClass using a request evaluator.
Add the request `ProtocolRequiresClassRequest` to lazily determine if a
`ProtocolDecl` requires conforming types to be a class.

Note that using the request evaluator to compute `requiresClass` introduces
cycle errors for protocol declarations, where this computation didn't
previously emit diagnostics. For now, we'll allow duplicate diagnostics in this
case, with the eventual goal of removing explicitly checking for cycles
via `checkCircularity` (instead letting the request evaluator handle cycle
diagnostics).
2019-07-17 16:04:24 -07:00
Suyash Srijan
afa14713e9 Merge branch 'master' into fix/SR-11074 2019-07-17 08:40:49 +01:00
Pavel Yaskevich
9ff887b6d0 Merge pull request #26165 from xedin/move-single-tuple-param-splat
[Diagnostics] Add a diagnostic for single parameter tuple splat
2019-07-17 00:06:47 -07:00
Suyash Srijan
1a1bff46d8 [CS] Don't crash when using magic literals as default arg
Squash all commits into one
2019-07-17 01:20:25 +01:00
Pavel Yaskevich
0dc863313c [Diagnostics] Extend single parameter splat diagnostic to report substitutions 2019-07-16 11:06:42 -07:00
Pavel Yaskevich
9550d10037 [Diagnostics] Add a diagnostic for single parameter tuple splat
Diagnose situation when a single "tuple" parameter is given N arguments e.g.

```swift
func foo<T>(_ x: (T, Bool)) {}
foo(1, false) // foo exptects a single argument of tuple type `(1, false)`
```
2019-07-16 11:06:42 -07:00
Suyash Srijan
5279f2038e [Typechecker] Add the new generic signature to the diagnostic message 2019-07-13 21:50:24 +01:00
Suyash Srijan
3b7b723e0f [Diagnostics] Fix a typo in diagnostic message 2019-07-13 21:50:24 +01:00
Suyash Srijan
131310d9e4 Apply review feedback and update diagnostic 2019-07-13 21:50:24 +01:00
Suyash Srijan
55f01d640c [Typechecker] Check for generic signature requirements when pechecking for overrides 2019-07-13 21:50:23 +01:00
Doug Gregor
03c0cbc4ab [SE-0258] Remove compatibility with the first revision of the proposal
No longer recognize delegateValue or value as special properties in
a property wrapper type.
2019-07-10 15:29:12 -07:00
Doug Gregor
1284878ad8 [SE-0258] Rename init(initialValue:) --> init(wrappedValue:).
Addresses core team decision on acceptance of property wrappers.

Fixes rdar://problem/48871069.
2019-07-10 14:26:53 -07:00
Doug Gregor
02ff2ee4e6 [SE-0258] Diagnose uses of property wrappers in top-level code.
We don't current support property wrappers at the top level, so
error on them (rather than crashing later).
Fixes rdar://problem/51538524.
2019-07-09 16:30:35 -07:00