Commit Graph

25 Commits

Author SHA1 Message Date
Xi Ge
2be1ca0c8a migrator: add ! to property access whose definition changes from nonnull to nullable. rdar://48090648 2019-02-14 15:28:52 -08:00
Nathan Hawes
43c2f27783 [Refactoring][Migrator] Fix rename of callsites with a trailing closure argument
A label range of 0 length was being reported as the label of trailing closure
arguments, just before the opening '{'.

For the rename refactoring, this meant that if the corresponding parameter had
an external label (e.g. 'a') the occurrence would be treated as not matching the
expected symbol name, and so not be updated at all.

For the migrator, when renaming a function with an unlabelled closure for its
last parameter to have a label, it would incorrectly insert the new label in
front of the opening '{' on all of that function's callsites with trailing
closures.

Resolves rdar://problem/42162571
2018-12-19 16:24:14 -08:00
Xi Ge
83382c5f94 migrator: rename a property declaration if the framework property it overrides has been renamed. 2018-12-19 11:58:22 -08:00
Xi Ge
f83ccd6438 migrator: handle changed parameter declarations by introducing bridging local variables.
When users override a SDK function whose parameter types have been changed,
we should introduce a local variable in the body of the function definition
to shadow the changed parameter. Also, a proper conversion function should
be applied to bridge the parameter to the local variable.

rdar://41828411
2018-07-11 13:41:37 -07:00
Xi Ge
c40ebd1d2d migrator: support migration of raw representable initializer calls without explicit labels. rdar://41740103
Some raw representable struct from SDK can be initialized without
explicit labels (rawValue:). When their types have been changed to type
alias, we should migrate the initializer calls to the argument alone.
2018-07-03 11:44:21 -07:00
Xi Ge
8e0e779cc2 migrator: handle the composite change of updating type alias to raw-representable and rename the referenced variables simultaneously. rdar://41732485 2018-07-02 12:13:20 -07:00
Xi Ge
4ed9f9a9a6 migrator: support the migration from member variables to global ones. rdar://41658300 2018-06-29 16:35:51 -07:00
Xi Ge
9a0196e991 migrator: avoid adding conversion functions when expression types change as well.
When inserting conversion functions around expressions, we should check
whether the type of the expression is a recognized name alias that is
known to be changed to raw-value representable type. We should avoid
inserting conversion functions in this case because doing so causes
build errors.

resolves: rdar://40463990
2018-06-25 14:44:58 -07:00
Xi Ge
90303d12a6 migrator: handle the reversion of raw representable changes. rdar://39498127 2018-06-15 16:51:57 -07:00
Mark Lacey
01ae11769c [Migrator] Re-enable wrap_optional.swift test.
This had to be reworked a bit to deal with the fact that IUOs are no
longer a distinct type and there were uses of IUOs that are not
supported after SE-0054.

Fixes: rdar://problem/37040141
2018-05-31 14:43:11 -07:00
Nathan Hawes
9ee3c35186 [migrator] Filter out diag::wrong_argument_labels for the fixit pass
The migrator only applies changes from the APIDiffMigratorPass in the primary
file. This means that if a nominal type was renamed, for example, any members
users have added in an extension in a separate file won't be visible, because
the extension would still have the old name. This can result in 'wrong argument
label' errors with fixits to change the argument labels that, when applied by
the fixit pass, completely change which function was being called and cause
post-migration errors.

This patch updates the fixit pass to ignore diag::wrong_argument_labels.
diag::extra_argument_labels and diag::missing_argument_labels were already
filtered out for other reasons.

Resolves rdar://problem/40170377
2018-05-16 15:49:00 -07:00
Nathan Hawes
61d7193814 [migrator] Treat the top-level argument parens of function types as an index level in the ChildIndexFinder
The APIDiffMigrator pass was ignoring them in all cases, but function type
argument parens are significant and the API differ includes them as an index
level in the generated json. This was causing a segmentation fault when trying
to migrate anything inside a function type argument. E.g given the function
below:

func member(_ x: ([Any]?) -> Void) {}

to migrate Any to Int, the API differ produces an index into the signauture of
1:1:0:0:0, meant to indicate Any. The APIDiffMigratorPass was interpreting this
incorrectly, however:

1: The type of first parameter of member: ([Any]?) -> Void
   Migrator agreed.
1: The type of the function type's argument: ([Any]?)
   Migrator saw this as [Any]? due to the parens not being an index level
0: The 0th child of the paren type: [Any]?
   Migrator saw the 0th child of the optional, [Any]
0: the 0th child of the optional type, [Any]
   Migrator saw the 0th child of the array, Any
0: the 0th child of the array type, Any
  Migrator tried to look up the 0th child of Any, causing a crash.

Resolves rdar://problem/40225476.
2018-05-15 12:05:21 -07:00
Xi Ge
740e336e02 migrator: make sure we can handle the composite change of rename and string representable update. radr://40076924 2018-05-09 15:53:51 -07:00
Xi Ge
aef79e9b03 migrator: update type name in constructor call if the type becomes nested. rdar://40042252 2018-05-08 14:28:00 -07:00
Xi Ge
3ee07be5ba migrator: handle the migration of string enum variable references. 2018-04-18 14:24:19 -07:00
Xi Ge
5db971de0e migrator: handle assignment of attribute dictionary and others.
When users' codebase assigns an attribute dictionary that used to be of
type [String: Any], this migration inserts a helper function call on the source of
the assignment to bridge the type.
2018-04-18 11:11:27 -07:00
Xi Ge
6a4df3e820 migrator: handle return value migration introduced by string enum changes.
This patch migrates the function call whose return type used to "String" and
now becomes "StringRepresentableStruct".
2018-04-17 15:18:33 -07:00
Xi Ge
65eaccb2fa migrator: teach the tool to handle ArrayMemberUpdate and OptionalArrayMemberUpdate attributes emitted from swift-api-digester.
This bridges the function call arguments that used to be of type [String] and
now become [StringRepresentableStruct].
2018-04-16 13:30:53 -07:00
Xi Ge
a138744e45 migrator: teach the tool to handle OptionalDictionaryKeyUpdate attributes emitted from swift-api-digester.
For a function call used to take [String: Any]? as argument and now
takes [StringRepresentableStruct: Any]?, a helper function is inserted
to help the bridging of types.
2018-04-16 10:57:36 -07:00
Xi Ge
4c10f16c0e migrator: teach the tool to handle DictionaryKeyUpdate attribute on arguments.
When a user's code calls a function that used to take [String: Any] as
argument and now takes [StringRepresentableStruct: Any], this migration
inserts a helper function to convert the argument to the
expected type.
2018-04-13 16:55:19 -07:00
Xi Ge
4c4e4d2b79 migrator: handle simple attribute assignment and reference.
This patch migrates simple attribute assignment and reference when the
attribute used to be of type String and later became StringRepresentable struct.

Related: rdar://38192995
2018-04-12 11:54:28 -07:00
Sho Ikeda
a08fef219e [gardening] Change static public to public static for consistency 2018-03-11 18:06:01 +09:00
Xi Ge
f2ef42baed [migrator] When renaming a function decl, we should use underscore to represent empty external argument label. rdar://34569243 (#12221) 2017-10-02 12:31:09 -07:00
Xi Ge
476534d1e2 migrator: handle qualified replacement for member reference expression. rdar://32845918 (#10593)
Previously, we only handle dot syntax call expression for qualified
replacement, i.e. changing from A.a to B.b. This patch teaches the tool
to handle the migration of member reference expression tool.
2017-06-26 15:47:17 -07:00
Ben Langmuir
257c1a6caf [migrator] Fix cities vs. Cities case consistency in tests 2017-05-19 10:41:15 -07:00