Syntax highlighting/refactoring failure in Xcode 9

Originator:mattxg
Number:rdar://32629695 Date Originated:June 8 2017
Status:Closed Resolved:July 11 2017
Product:Xcode Product Version:9 beta (9M136h)
Classification: Reproducible:Always
 
Summary:
A very simple code sample consistently gives a "Refactoring engine ranges didn't match initial ranges" error when trying to refactor in Xcode 9.

Steps to Reproduce:
Create a new command line Mac project in Xcode. Put the following code in the main.swift file...

~~~
    import Foundation 

    guard let x = "z" as String? else { exit(1) }
    let y = x.data(using: .utf8)
~~~

Right click on the `x` in the last line and select "Rename...."

Expected Results:
Both instances of `x` should appear in the refactoring user-interface.

Observed Results:
The editor continually tries to select the entire `x.data` text, instead of easily selecting `x`. A few attempts may be required. I don't know if this is a related problem or a bug for another time.

An alert sheet with the message "Refactoring engine ranges didn't match initial ranges" appears and refactoring is not possible.

If the x on the `guard` line is selected, refactoring is offered but the `x` on the next line does not appear.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!