Commit Graph

118 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
895dc90513 [FixCode] Disable a migrating fixit that interacts badly with the migrator.
For such code:
  func test(p: Int, _: String) {}
  test(0, "")

the compiler bizarrely suggests to change order of arguments in the call site.
2016-08-12 13:33:46 -07:00
Argyrios Kyrtzidis
0cd8ca56dc [FixCode] Accept the fixit for the warning that @warn_unused_result is the default now.
rdar://27516354
2016-08-12 11:47:14 -07:00
Argyrios Kyrtzidis
72ac89325f Merge pull request #4240 from akyrtzi/typealias-print
[ASTPrinter] Fix printing of nested typealias types and make it consistent with printing of nominal types.
2016-08-11 16:49:00 -07:00
Ben Langmuir
8b42212543 Merge remote-tracking branch 'benlangmuir/fixit-protocol-comp'
Conflicts:
	lib/FrontendTool/FrontendTool.cpp
	test/FixCode/fixits-apply.swift
	test/FixCode/fixits-apply.swift.result
2016-08-11 12:55:21 -07:00
Ben Langmuir
008a57f7e5 Merge pull request #4205 from benlangmuir/fixit-anyobject
[fixcode] Add ( as AnyObject) fixit to the whitelist
2016-08-11 12:52:39 -07:00
Argyrios Kyrtzidis
69918a966d [ASTPrinter] Fix printing of nested typealias types and make it consistent with printing of nominal types.
This fixes several issues:
- By default parent types of alias types are not printed which results in
	- Erroneous fixits, for example when casting to 'Notification.Name' from a string, which ends up adding erroneous cast
	  as "Name(rawValue: ...)"
	- Hard to understand types in code-completion results and diagnostics
- When printing with 'fully-qualified' option typealias types are printed erroneously like this "<PARENT>.Type.<TYPEALIAS>"

The change make typealias printing same as nominal types and addresses the above.
2016-08-11 12:15:15 -07:00
Ben Langmuir
ec539d6abf [fixcode] Enabled protocol<...> fixits
The old syntax is deprecated in swift 3, and these fixits seem quite
safe, so apply them for migration.

rdar://problem/27794981
2016-08-11 10:28:18 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Argyrios Kyrtzidis
9bd3e48b21 [AST] Fix the source range for InterpolatedStringLiteralExpr.
This allows fixits to be correctly applied when wrapping such an expression.
2016-08-10 15:22:03 -07:00
Ben Langmuir
454ee8a8d9 [fixcode] Add ( as AnyObject) fixit to the whitelist
This fixit comes from a note, but is very useful for migration of code
that has changed from AnyObject to Any but wants to do AnyObject
dispatch.

rdar://problem/27793389
2016-08-10 14:51:59 -07:00
Xi Ge
398f483557 [FixCode] Blacklist the fixit for enum case renames to avoid reverting migrator's change. rdar://27776887 (#4199)
We added the fixit to help users manually migrate enum case references after the declaration
has been renamed; however, when interacting with the migrator, the fixit may revert migrator's
correct changes, when the migrator updates references before updating the declaration. This patch
blacklists the fixit in migrator's pass, so we leave it to users' manually application if necessary.
2016-08-10 13:52:25 -07:00
Michael Ilseman
f48471ebd4 [noescape by default] purge tests of needless @noescape 2016-08-04 16:14:27 -07:00
Argyrios Kyrtzidis
92c0980a88 [FixCode] Make sure to accept the fixit in warning about 'where' syntax change. 2016-08-02 13:00:45 -07:00
Argyrios Kyrtzidis
c04aadb1a8 [FixCode] Make sure to accept the fixit in note about adding '@escaping'. 2016-08-02 10:04:40 -07:00
Michael Ilseman
c37751ae96 [noescape by defaul] make noescape the default
This flips the switch to have @noescape be the default semantics for
function types in argument positions, for everything except property
setters. Property setters are naturally escaping, so they keep their
escaping-by-default behavior.

Adds contentual printing, and updates the test cases.

There is some further (non-source-breaking) work to be done for
SE-0103:

- We need the withoutActuallyEscaping function
- Improve diagnostics and QoI to at least @noescape's standards
- Deprecate / drop @noescape, right now we allow it
- Update internal code completion printing to be contextual
- Add more tests to explore tricky corner cases
- Small regressions in fixits in attr/attr_availability.swift
2016-07-29 13:49:08 -07:00
Doug Gregor
823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00
Ben Langmuir
e50c232f4b [FixCode] Add another case of inserting ';' to the ban list
We missed one of the fixits that insert ; separators.

rdar://problem/26681061
2016-07-06 17:08:08 -07:00
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