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.
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
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.
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.
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.
* 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'
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.