Commit Graph

11 Commits

Author SHA1 Message Date
Nathan Hawes
f3e9685d88 [migrator] Fix missed dollar arg migration in closures relying on implicit destructuring of tuple type arg.
func foo(_: ((Int, Int)) -> Bool) {}
foo({ $0 > $1 }) // doesn't need migration
let x: ((Int, Int)) -> Bool = { $0 > $1 } // but this does
func bar() -> ((Int, Int)) -> Bool {
  return {$0 > $1} // and this does
}
2017-12-04 11:33:36 -08:00
Slava Pestov
0715eaeaed AST: Move SourceEntityWalker to IDE 2017-11-13 22:10:41 -08:00
Robert Widmann
4411223156 [NFC] Switch some more of the frontend to params 2017-06-30 10:24:52 -07:00
David Farler
9c1fa89d41 [Migrator] Remove closure shorthand prefixing.
In https://github.com/apple/swift/pull/10414, some SE-0110 features
were backed out, so the Migrator no longer needs to add `$0` shorthand
prefixing.

rdar://problem/32907276
2017-06-21 14:25:53 -07:00
David Farler
177718bf56 [Migrator] Remove some now unnecessary tuple destructuring
Some changes for SE-0110 were backed out in
https://github.com/apple/swift/pull/10414, so the migrator no longer
needs to add its own tuple destructuring.

rdar://problem/32513074
2017-06-20 17:57:48 -07:00
David Farler
2b0e04869c [Migrator] Expand tuple destructuring to support tuple input types
The migrator pass that converts single-argument function input types
doesn't handle the case when the function input has a label and is
therefore a tuple. Expand it to handle that possibility.

rdar://problem/32477319
2017-06-14 14:21:51 -07:00
David Farler
0a86e66f60 [Migrator] Add return keyword when adding temp bindings in single-expression closures
The migrator pass to add tuple destructuring that now needs to add a
`return` statement for closures that were once single-expression but are
no longer because of the added statement to do the binding.

rdar://problem/32433206
2017-05-31 13:37:35 -07:00
practicalswift
57d0a407d1 [gardening] Fix spacing 2017-05-24 21:28:24 +02:00
Nathan Hawes
5d60bfc75c [Migrator] Add doc comments and fix whitespace in TupleSplatMigratorPass.cpp 2017-05-17 15:31:10 -07:00
Nathan Hawes
63b40bdcd2 [Migrator] Migrate references to shorthand closure params (e.g. $0, $1) where affected by SE110
In Swift 3:
 1) a closure referring to $1 or above type checked against a function type that takes a single tuple argument with that arity
 2) a closure referring only to $0 (or $0.1 etc) type checked against a function type that takes multiple arguments
but neither compiles in Swift 4.

This patch migrates shorthand references for
  1) by prefixing "0." in front of the existing references, e.g. "$1" to "$0.1"
  2) by removing the leading 0. if one existing or substituting a tuple of the correct arity if it doesn't, e.g. "$0.1" to "$1" and "$0" to "($0, $1, $2)"

Resolves rdar://problem/31969538
2017-05-17 14:16:47 -07:00
David Farler
0774db030f [Migrator] Separate AST Pass implementations
The SyntacticMigratorPass is getting Too Big To Fail and covers
multiple migrations. There was already an early exit to not run
the pass if APIDigesterDataStorePath wasn't supplied, so SE-0110
tuple splat fix-its weren't getting run. This manifested in Migrator
tests not printing migrated contents on Linux.

New: ASTMigratorPass
Renamed: SyntacticMigratorPass -> APIDiffMigratorPass
New: TupleSplatMigratorPass

These implementations are entirely hidden and can only be invoked
by a swift::migrator function.

rdar://problem/32025974
2017-05-05 23:35:13 -07:00