mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Refactoring] Don't crash when converting a function to async that contains a call to init
We were trying to retrieve the name of all function calls in the body using `getBaseIdentifier`. But calls to `init` don’t have a base identifier, just a `DeclBaseName` (which is special). Work with the `DeclBaseName` internally to prevent the crash. Fixes rdar://78024731 [SR-14637]
This commit is contained in:
@@ -844,3 +844,15 @@ func testPreserveComments3() {
|
||||
// PRESERVE-TRAILING-COMMENT-CALL: let s = await simple()
|
||||
// PRESERVE-TRAILING-COMMENT-CALL-NEXT: print(s)
|
||||
// PRESERVE-TRAILING-COMMENT-CALL-NOT: // make sure we pickup this trailing comment if we're converting the function, but not the call
|
||||
|
||||
class TestConvertFunctionWithCallToFunctionsWithSpecialName {
|
||||
required init() {}
|
||||
subscript(index: Int) -> Int { return index }
|
||||
|
||||
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):3
|
||||
static func example() -> Self {
|
||||
let x = self.init()
|
||||
_ = x[1]
|
||||
return x
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user