Skip to content

Commit c4bf8fd

Browse files
authored
Merge pull request #21390 from nkcsgexi/rename-index
migrator: rename index(of:) to firstIndex(of:) for swift 5.
2 parents 6b405a4 + 97257c5 commit c4bf8fd

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

lib/Migrator/overlay4.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,5 +1320,16 @@
13201320
"DiffItemKind": "SpecialCaseDiffItem",
13211321
"Usr": "s:5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF",
13221322
"SpecialCaseId": "UIApplicationMain"
1323-
}
1323+
},
1324+
{
1325+
"DiffItemKind": "CommonDiffItem",
1326+
"NodeKind": "Function",
1327+
"NodeAnnotation": "Rename",
1328+
"ChildIndex": "0",
1329+
"LeftUsr": "s:SlsSQ7ElementRpzrlE5index2of5IndexQzSgAB_tF",
1330+
"LeftComment": "index",
1331+
"RightUsr": "",
1332+
"RightComment": "firstIndex",
1333+
"ModuleName": "Swift"
1334+
},
13241335
]

test/Migrator/stdlib_rename.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// REQUIRES: objc_interop
2+
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -emit-migrated-file-path %t/stdlib_rename.swift.result -emit-remap-file-path %t/stdlib_rename.swift.remap -o /dev/null
3+
// RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result
4+
5+
func test1(_ a: [String], s: String) {
6+
_ = a.index(of: s)
7+
}
8+
func test2(_ s: String, c: Character) {
9+
_ = s.index(of: c)
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// REQUIRES: objc_interop
2+
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -emit-migrated-file-path %t/stdlib_rename.swift.result -emit-remap-file-path %t/stdlib_rename.swift.remap -o /dev/null
3+
// RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result
4+
5+
func test1(_ a: [String], s: String) {
6+
_ = a.firstIndex(of: s)
7+
}
8+
func test2(_ s: String, c: Character) {
9+
_ = s.firstIndex(of: c)
10+
}

0 commit comments

Comments
 (0)