Commit Graph

137 Commits

Author SHA1 Message Date
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
Argyrios Kyrtzidis
d2c502b2c3 Do some renames to match-up with the 'swift-fixit' name.
Swift SVN r27140
2015-04-08 22:13:59 +00:00