mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add a deprecation warning for use of popFirst even with -swift-version 3, as it's prone to leaks under the old model. Test cases added.
15 lines
677 B
Swift
15 lines
677 B
Swift
// RUN: %swift -typecheck -swift-version 4 %s -verify
|
|
|
|
func testPopFirst() {
|
|
var str = "abc"
|
|
_ = str.popFirst() // expected-error{{'popFirst()' is unavailable: Please use 'first', 'dropFirst()', or 'Substring.popFirst()'}}
|
|
_ = str.characters.popFirst() // FIXME: deprecate CharacterView. This call currently gets paired with default popFirst from Collection :-(
|
|
_ = str.unicodeScalars.popFirst() // expected-error{{'popFirst()' is unavailable: Please use 'first', 'dropFirst()', or 'Substring.UnicodeScalarView.popFirst()'}}
|
|
|
|
var substr = str[...]
|
|
_ = substr.popFirst() // ok
|
|
_ = substr.characters.popFirst() // ok
|
|
_ = substr.unicodeScalars.popFirst() // ok
|
|
}
|
|
|