Commit Graph

18 Commits

Author SHA1 Message Date
Becca Royal-Gordon
0cfda873b6 Suggest stub stored properties where possible
When generating a stub fix-it for a protocol conformance or implementation extension, Swift will now evaluate whether the context allows the declaration of stored properties and, if so, will suggest one. It will also use the `let` keyword instead of `var` if the property has no setter.
2025-04-09 16:48:41 -07:00
Alex Hoppen
66104395d7 [Sema/SourceKit] Emit same diagnostics for missing protocol requirements on the command line and in SourceKit
Some editors use diagnostics from SourceKit to replace build issues. This causes issues if the diagnostics from SourceKit are formatted differently than the build issues. Make sure they are rendered the same way, removing most uses of `DiagnosticsEditorMode`.

To do so, always emit the `add stubs for conformance` note (which previously was only emitted in editor mode) and remove all `; add <something>` suffixes from notes that state which requirements are missing.

rdar://129283608
2024-08-07 14:01:30 -07:00
Slava Pestov
6306884abe Sema: Only call diagnoseMissingWitnesses() once 2024-01-24 12:05:24 -05:00
Nishith Shah
8e2e625543 [Diagnostics] Use imperative msg for protocol conformance & switch-case fixits
This commit changes fixit messages from a question/suggestion to an
imperative message for protocol conformances and switch-case. Addresses
https://github.com/apple/swift/issues/67510.
2023-08-13 22:34:26 -07:00
Anthony Latsis
14b70f306b DiagnosticVerifier: Default expected fix-it start line to the diagnostic's 2023-03-08 12:10:27 +03:00
Anthony Latsis
6e8dcbe745 ConformanceChecker: Resolve value witnesses unless they depend on invalid type witnesses 2022-02-26 01:06:53 +03:00
Harlan Haskins
62f9edf647 [Sema] Don't print __consuming when suggesting protocol requirement stubs 2018-12-18 11:26:37 -08:00
Greg Titus
7d0bdb112e Omit protocol match diagnosis for constructors with differing names. 2018-10-14 17:08:50 -07:00
Alex Hoppen
2dd670ba8b Add test cases for special subscript name 2017-07-11 19:04:13 +02:00
Xi Ge
5d2cd20051 Sema/FixCode: Introducing a wrapper for ConformanceChecker to fix missing stubs for multiple protocols in a single fixit invocation. (#7937) 2017-03-06 16:37:43 -08:00
Xi Ge
d6cc431a8d [FixCode] Enhance existing fill-protocol-stub fixit so that all missing witnesses can fixed at once. 2017-03-02 14:48:20 -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
Slava Pestov
1df6e51c14 AST: Only print DynamicSelfType as 'Self' for class types
This fixes a regression from the previous patch which got
rid of PrintOptions::StripDynamicSelf.

When printing protocol declarations with a BaseType set in
PrintOptions, we can end up with a DynamicSelfType wrapping
a non-class type, if the protocol requirement returned
Self.

Note that this changes the diagnostic for missing protocol
requirements slightly; we used to sometimes refer to 'Self'
even if the conforming type is not a class, which is not
accepted by the type checker anyway. I believe the new
diagnostics are more correct.
2016-11-19 22:53:54 -08:00
Slava Pestov
a1eef126ba AST: Don't print "aka <<desugared type>>" for generic function types
This was causing us to emit diagnostics talking about τ_m_n, which is
not helpful.

Now that generic function types print sanely, print them in a few
places where we were previously printing PolymorphicFunctionTypes.
2016-09-15 21:47:57 -07:00
Rintaro Ishizaki
f585a270f9 [Sema] Improve fix-it for missing initializer requirement
* If current context is extension of non-final class, don't suggest stub
* If current context is extension of final class, insert 'convenience'
* If current context is direct definition of non-final class, insert 'required'
2016-09-05 18:13:05 +09:00
Rintaro Ishizaki
3be5e89708 [Sema] Emit only public access modifier in fix-it for missing witness 2016-09-01 18:10:32 +09:00
Doug Gregor
b9363fe6bd [SE-0111] Enable SE-0111 by default. 2016-07-29 17:28:24 -07:00
Alex Hoppen
c3b5b305b2 [Diag] Fixits for missing protocol requirements
To each note with a protocol requirement that is not met, a fixit is
added that inserts a stub for the requirement at the start of the
adoptee's declaration.
2016-07-20 11:47:08 +02:00