Commit Graph

101 Commits

Author SHA1 Message Date
Ben Langmuir
cb4b1b601b [FixCode] Apply #selector fixits
These are very useful fixits for migration. Note: this applies the
fixits for selectors that are actually found, but not the one that wraps
an arbitrary string literal in Selector(...), because that one indicates
a possibly missing selector that the user should review.

rdar://problem/26678232
2016-07-05 10:50:39 -07:00
Ben Langmuir
3f026bea27 [FixCode] Don't add .dynamicType
Adding .dynamicType interacts poorly with the swift migrator by
invalidating some inits with type errors.

rdar://problem/26642062
2016-07-05 09:46:38 -07:00
Ben Langmuir
d5d48f38b6 [FixCode] Apply @* is now an attribute on a parameter type fixits 2016-07-05 09:46:38 -07:00
Ben Langmuir
338f40296b [FixCode] Avoid removing @IB* attributes
If there are type-checking issues, these interact poorly with the
migrator and may remove @IB* attributes unnecessarily.

rdar://problem/26886636
2016-07-05 09:46:37 -07:00
Trent Nadeau
78a420d850 Made use of @warn_unused_result a warning with a fixit (#2760)
https://bugs.swift.org/browse/SR-1052
2016-06-08 10:10:21 -07:00
Argyrios Kyrtzidis
dd32ed86fb Follow-up from 7d6f11d217, add space between 'map' and left brace,
per feedback by Dmitri.
2016-06-05 18:13:19 -07:00
Argyrios Kyrtzidis
7d6f11d217 [sema] Follow-up on the raw-representable casting fixits, produce a fixit for optional source types as well.
For optional source types we use the form "expr.map{ T(rawValue: $0) }".
2016-06-05 18:06:14 -07:00
Ben Langmuir
24988f8c42 [fixits] Don't fixit-remove generic arguments on ModuleType
Seeing Module<Args> is more likely to indicate some catastrophic
failure, for instance a missing type with the same name as the module,
than that we should remove the generic arguments.

rdar://problem/26639477
2016-06-04 18:22:18 -07:00
Argyrios Kyrtzidis
3334a82974 [test] Add an extra test case for f60567e7ba, per feedback by BenL. 2016-06-04 12:18:51 -07:00
Argyrios Kyrtzidis
f60567e7ba [sema] Follow-up on the raw-representable casting fixits, produce the fixit for optional destination types as well. 2016-06-04 11:22:39 -07:00
Ben Langmuir
73f09176e1 [FixCode] Don't accept fixit that inserts commas; they break placeholders
These fixits interact poorly with code that has <#editor placeholder#>s
in it, inserting commas inside the placeholder.

rdar://problem/26623964
2016-06-03 10:47:13 -07:00
Argyrios Kyrtzidis
c1953e0f17 [sema] Add a fixit for missing generic arguments.
When the unbound generic type is missing type arguments try to add a fixit that
infers a generic type list to pass.

rdar://26623703
2016-06-03 09:59:50 -07:00
Argyrios Kyrtzidis
792ab3c8ed [sema] Add compiler fixit for the case where a raw-representable type is constructed from an argument with the same type.
Like this:

  MyEnumType(MyEnumType.foo)

This is missing 'rawValue:' label, but that won't actually fix this. A better fix is to just remove the unnecessary constructor call:

  MyEnumType(MyEnumType.foo)
-->
  MyEnumType.foo
2016-06-03 07:44:50 -07:00
Ben Langmuir
d3b40aa483 [FixCode] Pick up fixit for let->var change
This is an important fixit, but was lost because it is on the note
instead of the error.

rdar://problem/26593117
2016-06-02 10:19:45 -07:00
Argyrios Kyrtzidis
f36cc94f51 [FixCode] Add fix-its for mismatched integer types.
Adds fixits for:
 - Passing an integer with the right type but which is getting wrapped with a
   different integer type unnecessarily. The fixit removes the cast.

 - Passing an integer but expecting different integer type. The fixit adds
   a wrapping cast.
2016-05-31 22:29:28 -07:00
Slava Pestov
4558b5018c Sema: New fix-its for RawRepresentable conversions
If the expression type is RawRepresentable with an associated
RawValue type of T, and the contextual type is T, suggest adding
a '.rawValue' accessor call.

Also, suggest inserting the fixit in a few more cases, such as
dictionary keys.

This improves upon a previous patch which added a fix-it for the
other direction:

<55bf215feb>

Fixes <rdar://problem/26470490>.
2016-05-27 00:26:21 -07:00
Argyrios Kyrtzidis
146be88a6e [FixCode] When picking-up fixits for migration ignore the fixits for adding @objc(selector).
These interact badly with the swift migrator, they are triggered by label mismatches in pre-migrated code.

We also don't generally need them since we do inference for the most common cases.
2016-05-26 17:15:19 -07:00
Argyrios Kyrtzidis
48a063e853 [FixCode] Follow-up for b4a2b53739, ignore another diagnostic fixit that is messing with argument labels. 2016-05-26 17:15:19 -07:00
Argyrios Kyrtzidis
55bf215feb [sema] When the error is "cannot convert value of type <integer> to expected argument type <RawRepresentable>" add a fixit.
The fixit constructs the raw-representable type from the value. This helps with SDK changes.
2016-05-25 07:23:57 -07:00
Argyrios Kyrtzidis
91ce77d55a [test] Follow-up for commit b4a2b53739, add test methods with function bodies. 2016-05-24 16:43:27 -07:00
Argyrios Kyrtzidis
b4a2b53739 [FixCode] When picking-up fixits for migration ignore argument label fixits.
These interact badly with the swift migrator, they are undoing migration of arguments to preserve the no-label for first argument.
2016-05-24 16:31:49 -07:00
Argyrios Kyrtzidis
6b8ee42248 [fixcode] Accept the fixit for adding bang to unwrap optional.
This is useful for getting fixits for the IOU handling changes.
2016-05-11 13:58:24 -07:00
Argyrios Kyrtzidis
e5821519a4 [fixcode] Accept the warning fixit for single argument function types requiring parentheses. 2016-05-11 13:33:00 -07:00
Argyrios Kyrtzidis
3dbfd5c1d5 [fixcode] Accept the warning fixit for extraneous duplicate parameter label. 2016-05-09 07:44:34 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Manav Gabhawala
7862f104c9 [Parser] Cleans up parsing of parameter attributes. Implements SE-0053. Fixes SR-979, SR-1020 and cleans up implementation of SE-0003. Provides better fix-its and diagnostics for misplaced 'inout' and prohibits 'var' and 'let' from parameter attributes 2016-03-29 13:55:46 -04:00
Doug Gregor
7d70b704e4 Merge commit '5e11e3f7287427d386636a169c4065c0373931a8' into swift-3-api-guidelines 2016-01-19 23:18:20 -08:00
David Farler
a6f2530780 Revert "REVERTME: Temporarily make vars in refutable patterns a warning"
This reverts commit b96e06da44, making
vars in refutable patterns an error for Swift 3.

rdar://problem/23172698
2016-01-14 20:52:24 -08:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
Chris Lattner
666a42f5c7 Remove the ability to map back from a ParamDecl to its enclosing Pattern. This
is used by precisely one thing (producing a warning in a scenario that is obsolete
because we deprecated the entire thing), so the complexity isn't worth it anymore.
2015-12-29 21:09:11 -08:00
Max Moiseev
9391b0a848 Reverting fixits-apply.swift changes applied on merge 2015-12-23 11:34:42 -08:00
Max Moiseev
200be71583 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-23 10:28:04 -08:00
Chris Lattner
2bfb788ef2 remove the logic for upgrading Swift 1's print that used "appendNewline"
to Swift 2 syntax that uses "terminator".  It is legacy, and removing it
allows simplifications.
2015-12-22 14:42:18 -08:00
Doug Gregor
a97ab6dd14 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-18 10:15:47 -08:00
practicalswift
8ab8847684 Fix typos. 2015-12-16 22:09:32 +01:00
Maxim Moiseev
0e0191380a OptionSetType => OptionSet 2015-12-10 14:58:24 -08:00
Dmitri Gribenko
feacbc4433 Rename ErrorType to ErrorProtocol 2015-12-09 17:12:19 -08:00
Dmitri Gribenko
174d475833 stdlib: Remove unavavailable APIs that were left as migration aids
These APIs are from the Swift 1.2 => Swift 2.0 transition, and are not
relevant anymore.

Removing them reduces the surface area of the library that needs to be
reviewed.
2015-12-02 01:19:50 -08:00
Argyrios Kyrtzidis
1d5e9e0acd [FixCode] Introduce '-fixit-all' option that, when -fixit-code is enabled, applies all fixits from diagnostics without any filtering.
Swift SVN r31772
2015-09-08 18:30:49 +00:00
Argyrios Kyrtzidis
ab9375a3ec [Sema] Add a diagnostic fixit for the "print(_:appendNewline:)" -> "print(_:terminator:)" change.
Swift SVN r31237
2015-08-14 01:05:37 +00:00
Argyrios Kyrtzidis
310d92ecc1 [stdlib] Add RawOptionSetType as unavailable with a 'renamed' fixit to OptionSetType.
rdar://21800523

Swift SVN r30313
2015-07-17 07:16:10 +00:00
Chris Lattner
f04d2bb828 Implement <rdar://problem/20336036> QoI: Add cast-removing fixit for "Forced cast from 'T' to 'T' always succeeds"
Swift SVN r29876
2015-07-02 00:28:44 +00:00
Argyrios Kyrtzidis
514a57d02a [Sema] Find the 'var' location of 'catch' variables so that the warning "variable x was never mutated; consider changing to 'let’ constant",
can add a fixit for it.

rdar://21137461

Swift SVN r29106
2015-05-28 17:16:16 +00:00
Dave Abrahams
d65f696344 Kill off [_]RawOptionSetType
Now that we are using OptionSetType for option sets, all the support for
doing things the old way can die.

Note: the fix-it that used to apply to RawOptionSetType, it seemed to me,
should still apply to OptionSetType, so I switched it over instead of
removing it.

Swift SVN r29066
2015-05-27 15:55:54 +00:00
Argyrios Kyrtzidis
4bcb2d0b97 [Sema] Add a compiler fixit for erroneously returning an unnecessary cast of a raw value of a RawOptionSet.
The primary motivation is to address SDK change of a common API.
The diagnostic checks return statements per advice from JoeP to simplify implementation.

rdar://21034343

Swift SVN r28826
2015-05-20 07:53:35 +00:00
Argyrios Kyrtzidis
fcf040402a [fixit] Avoid picking up the fixit which adds a bang.
Adding a bang can be unsafe and may lead to silently adding crashes in user's code.
Err on the side of caution and let the compiler error stand so the user can review the code.

Swift SVN r28467
2015-05-12 14:11:00 +00:00
Argyrios Kyrtzidis
a01e7c27cf [fixit] Apply the 'forced_downcast_coercion' warning automatically.
This can show up when upgrading due to ObjC generics changes.

Swift SVN r28454
2015-05-12 05:14:38 +00:00
Chris Lattner
31c01eab73 Change the meaning of "if let x = foo()" back to Xcode 6.4 semantics. The compiler
includes a number of QoI things to help people write the correct code.  I will commit
the testcase for it as the next patch.

The bulk of this patch is moving the stdlib, testsuite and validation testsuite to
the new syntax.  I moved a few uses of "as" patterns back to as? expressions in the 
stdlib as well.



Swift SVN r27959
2015-04-30 04:38:13 +00:00
Argyrios Kyrtzidis
d646c3178c [fixit-code] Apply the fixit for the refutable pattern warning.
Swift SVN r27253
2015-04-13 15:28:29 +00:00
Argyrios Kyrtzidis
8b250d6d35 [driver] Remove the 'swift-fixit' symlink and introduce '-emit-fixits-path' frontend option that
writes compiler fixits as source edits.

Driver option '-fixit-code' adds '-emit-fixits-path' for all the frontend invocations.

Swift SVN r27208
2015-04-10 17:33:29 +00:00