Files
swift-mirror/test/stdlib/StringCompatibilityDiagnostics.swift
Michael Ilseman 64e0e1859e [stdlib] Deprecate popFirst in Swift 3.2
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.
2017-08-10 15:27:05 -07:00

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
}