mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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.
21 lines
897 B
Swift
21 lines
897 B
Swift
// REQUIRES: objc_interop
|
|
// RUN: %empty-directory(%t.mod)
|
|
// RUN: %target-swift-frontend -emit-module -o %t.mod/Cities.swiftmodule %S/Inputs/Cities.swift -module-name Cities -parse-as-library
|
|
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -disable-migrator-fixits -primary-file %s -I %t.mod -api-diff-data-file %S/Inputs/API.json -emit-migrated-file-path %t/rename-func-decl.swift.result -o %t/rename-func-decl.swift.remap
|
|
// RUN: diff -u %S/rename-func-decl.swift.expected %t/rename-func-decl.swift.result
|
|
|
|
import Cities
|
|
|
|
class MyCities : MoreCities {
|
|
func setZooLocation(x ix: Int, y iy: Int, z iz: Int) {}
|
|
func addZooAt(_ x: Int, y: Int, z: Int) {}
|
|
}
|
|
|
|
class MySubTopLevelType: ToplevelType {
|
|
override func member(_ x: @escaping ([Any]?) -> Void) {}
|
|
}
|
|
|
|
class MySubTopLevelType2: ToplevelType {
|
|
override func member(_ x: @escaping (((([(Any)])?))) -> Void) {}
|
|
}
|