Compute the expression range correctly for substring-to-string fixits.

rdar://33474838
This commit is contained in:
John McCall
2017-07-26 19:10:55 -04:00
parent 2cda3e0444
commit 0730a27f5b
2 changed files with 11 additions and 2 deletions

View File

@@ -86,3 +86,11 @@ func apply(_ fn: (String) -> (), _ s: String) {
let _: String = s[s.startIndex..<s.endIndex] // expected-error{{subscripts returning String were obsoleted in Swift 4; explicitly construct a String from subscripted result}} {{19-19=String(}} {{47-47=)}}
_ = s[s.startIndex..<s.endIndex] as String // expected-error{{subscripts returning String were obsoleted in Swift 4; explicitly construct a String from subscripted result}} {{7-7=String(}} {{35-35=)}}
}
// rdar://33474838
protocol Derivable {
func derive() -> Substring
}
func foo<T: Derivable>(t: T) -> String {
return t.derive() // expected-error {{cannot convert return expression of type 'Substring' to return type 'String'}} {{10-10=String(}} {{20-20=)}}
}