Commit Graph

72 Commits

Author SHA1 Message Date
David Farler
789bd3749f [Migrator] Use toLowercaseWord to lowercase SetterToProperty changes
Post-commit review follow-up:
This works better for properties that were all-caps, such as `URL`.

Thanks @harlanhaskins for the tip!

rdar://problem/32845968
2017-06-26 12:53:15 -07:00
Mark Lacey
1c9f85fc9b Tweak test to make it fail to compile regardless of SE-0110. 2017-06-15 12:07:26 -07:00
David Farler
df45a9ba6b [Migrator] Don't add -aarch64-use-tbi twice
Setting up an invocation adds -aarch64-use-tbi if the target is for
AArch64. In the fix-it passes, we inherit the frontend options which
already has it from the driver passing it down to the frontend.

rdar://problem/32284152
2017-06-14 14:21:51 -07:00
David Farler
6c08f802a6 [Migrator] Don't issue rewrites when diagnostics seen more than once
The clang::RewriteBuffer can do weird things when seeing multiple
replacements where the replacement text is one character longer or
one character shorter than the range it is replacing.

rdar://problem/32234525
2017-06-14 14:21:51 -07:00
Xi Ge
9f456b19a3 migrator: use the right method to get the location of return type. rdar://32545812
TypeLoc::getLoc() is not necessarily the start location of the type repr.
2017-06-02 15:17:24 -07:00
Xi Ge
fa78d9259e migrator/test: move all API diff data files to Inputs directory. NFC (#10074) 2017-06-02 14:20:35 -07:00
Ben Langmuir
257c1a6caf [migrator] Fix cities vs. Cities case consistency in tests 2017-05-19 10:41:15 -07:00
David Farler
d4c9eb1db7 [Migrator] Add null check when pre-fix-it passes fail
If code is irreparably broken when migrating, make sure to
check that the pre-fix-it compiler instance is `nullptr` and
bail if so.

rdar://problem/32240138
2017-05-18 14:26:10 -07:00
David Farler
a46127a20e Allow make_decl_objc diagnostic note into the FixitApplyDiagnosticConsumer
This allows the migrator to pick up fix-its from notes such as:

“Argument of #selector refers to instance method '___' that is not
exposed to Objective-C”

Add some more testing for minimal/complete workflows, and upstream
the cross-file fix-it test.

rdar://problem/32228948
2017-05-17 12:13:59 -07:00
Xi Ge
058d7f62e8 [migrator] Various quality improvement on type-hoist API migrations. rdar://32186526 (#9600) 2017-05-14 19:25:01 -07:00
David Farler
0baa7c6dd8 [Migrator] Migrate Static member abs function calls to Swift.abs
These are deprecated in Swift 3, but are hard obsoleted in Swift 4.

rdar://problem/31070486
2017-05-14 16:55:34 -07:00
Xi Ge
ff2622734e migrator: handle the special migration cases of NSOpenGLSetOption/NSOpenGLGetOption. rdar://32178753 (#9591) 2017-05-14 13:00:03 -07:00
Xi Ge
65b9043eb1 migrator: handle function hoist API changes and several its varieties. rdar://31234806 (#9544) 2017-05-12 21:34:06 -07:00
Nathan Hawes
0410f17c1b [Migrator] Fix optional types not being updated correctly in some cases
If the replacement type was a function type or protocol-constrained type (e.g.  'Class & Proto) and the existing type had a postfix ? or !, we weren't wrapping the replacement in parens. This would result in an incorrect/ambiguous new type. This patch wraps the replacement in parens if it contains an & or ->, the existing type has a trailing ? or !.

Resolves rdar://problem/32082269.
2017-05-09 12:08:13 -07:00
David Farler
be86bcac1d [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
2017-05-04 16:40:56 -07:00
Xi Ge
39c550fc40 [Migrator] Handle function decl renames. rdar://31766131 (#9157) 2017-05-02 10:53:56 -07:00
David Farler
98aae46ae6 Merge pull request #9167 from bitjammer/rdar-30928902-substring-string-migrator-tests
[Migrator] Add Substring -> String conversion fix-it tests
2017-05-01 17:26:26 -07:00
David Farler
39a95f2dad [Migrator] Add Substring -> String conversion fix-it tests
There is no implicit conversion between String and Substring, so
the migrator can offer fix-its to convert between the two by wrapping
in String.init or adding the void subscript [] accordingly. This
commit just adds the tests for migration for the time being.

rdar://problem/30928902
2017-05-01 16:21:32 -07:00
David Farler
b73b597a79 Merge pull request #9117 from bitjammer/rdar-31895432-migrator-dont-add-type-placeholder
[Migrator] Don't pick up missing argument type placeholder fix-its
2017-05-01 14:34:25 -07:00
David Farler
95e6506682 [Migrator] Don't pick up missing argument type placeholder fix-its
With SE-110, the migrator may get a recommendation to add a Void
placeholder in the call to f in:
func foo(f: (Void) -> ()) {
  f()
}
Here, f was () -> () in Swift 3 but now (()) -> () in Swift 4. Adding a
type placeholder in the f() call isn't helpful for migration, although
this particular fix-it should be to fix the f parameter's type.

rdar://problem/31895432
2017-05-01 12:57:38 -07:00
David Farler
bf52ff032a [Migrator] Conservative and Minimal @objc inference workflows
Based on recommendations in SE-0160, there are two migration workflows:

- Conservative: Maintain @objc visibility that was inferred in Swift 3
  by adding @objc to all declarations that were implicitily visible to
  the Objective-C runtime. This is invoked in the migrator by adding the
  -migrate-keep-objc-visibility flag.
- Minimal: Only declarations that must be visible to Objective-C based
  on their uses (or in cases like dynamic vars) are migrated.

rdar://problem/31876357
2017-04-28 18:28:34 -07:00
Nathan Hawes
8ad6aa4e0d [migrator] Add pass for API type changes
This handles optionality changes and type rewrites in function param and return types and constructor param and failability types.
Resolves rdar://problem/31766010
2017-04-27 22:19:52 -07:00