mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Migrator] Suggest String <-> Substring conversions
Some APIs that expected a String now expect a Substring and vice versa. To ease the transition, emit fix-its on conversion errors between these types that the migrator can pick up. When converting from Substring -> String, suggest wrapping in `String.init`. When converting from String -> Substring, suggest appending the void subscript `[]`. (This isn't implemented yet so this is hidden behind a flag). This can possibly be generalized later when converting between some sequence and its subsequence, such as Array and ArraySlice, for example. rdar://problem/31665649 rdar://problem/31666638
This commit is contained in:
@@ -884,6 +884,12 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
const FrontendOptions &FrontendOpts) {
|
||||
using namespace options;
|
||||
|
||||
/// FIXME: Remove this flag when void subscripts are implemented.
|
||||
/// This is used to guard preemptive testing for the fix-it.
|
||||
if (Args.hasArg(OPT_fix_string_substring_conversion)) {
|
||||
Opts.FixStringToSubstringConversions = true;
|
||||
}
|
||||
|
||||
if (auto A = Args.getLastArg(OPT_swift_version)) {
|
||||
auto vers = version::Version::parseVersionString(
|
||||
A->getValue(), SourceLoc(), &Diags);
|
||||
|
||||
Reference in New Issue
Block a user