Commit Graph

10 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
Ben Cohen
dcab9493ae Removed some warnings (#12753) 2017-11-30 15:12:56 -08: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
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
Ben Cohen
ea2f64cad2 [stdlib] Add Sequence.Element, change ExpressibleByArrayLiteral.Element to ArrayLiteralElement (#8990)
* Give Sequence a top-level Element, constrain Iterator to match

* Remove many instances of Iterator.

* Fixed various hard-coded tests

* XFAIL a few tests that need further investigation

* Change assoc type for arrayLiteralConvertible

* Mop up remaining "better expressed as a where clause" warnings

* Fix UnicodeDecoders prototype test

* Fix UIntBuffer

* Fix hard-coded Element identifier in CSDiag

* Fix up more tests

* Account for flatMap changes
2017-05-14 06:33:25 -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
David Farler
f697075abb [Migrator] Add Swift. prefix to type(of:) expressions in Swift 3
This changed to be resolved by overload resolution in Swift 4, and so
can suddenly be shadowed by similarly named properties and functions
that are visible at the expression's location. When in Swift 3 mode, if
there is a visible declaration named "type", add the `Swift.` prefix to
disambiguate in Swift 4 mode.

rdar://problem/31997321
2017-05-05 15:49:39 -07:00
Argyrios Kyrtzidis
7da453165c [test/migrator] Disable test/Migrator/tuple-arguments.swift on linux
Not sure why it is failing there.
2017-05-04 09:38:50 -07:00
Argyrios Kyrtzidis
1b6e001a19 [migrator] Add an AST pass to handle tuple mismatches
Migrates code that compiles fine in Swift 3 but breaks in Swift 4 due to
changes in how the typechecker handles tuple arguments.
2017-05-04 07:26:00 -07:00