Files
swift-mirror/test/stdlib/IndexOfRenaming.swift
Max Moiseev e8b6091755 [stdlib] Deprecate Collection.index(of:) and index(where:) (#19071)
This should have been done for Swift 4.2 according to SE-0204, but
better later than never. Deprecating these methods as of Swift 5.0.

Also modfying the tests to check for the deprecation message.

Fixes: <rdar://problem/43694210>
2018-08-30 19:32:27 -07:00

9 lines
472 B
Swift

// RUN: %target-typecheck-verify-swift -swift-version 5
let a = [10, 20, 30, 40, 50, 60]
_ = a.index(of: 30) // expected-warning {{'index(of:)' is deprecated: renamed to 'firstIndex(of:)'}} expected-note {{use 'firstIndex(of:)' instead}}
_ = a.firstIndex(of: 30)
_ = a.index(where: { $0 > 30 }) // expected-warning {{'index(where:)' is deprecated: renamed to 'firstIndex(where:)'}} expected-note {{use 'firstIndex(where:)' instead}}
_ = a.firstIndex(where: { $0 > 30 })