mirror of
https://github.com/apple/swift.git
synced 2026-10-18 17:49:23 +02:00
This PR converts these two experimental feature flags to regular language flags – includes #90017. Co-authored-by: Elsa Keirouz <e_keirouz@apple.com>
53 lines
2.2 KiB
Swift
53 lines
2.2 KiB
Swift
// RUN: %target-typecheck-verify-swift \
|
|
// RUN: -verify-ignore-unrelated
|
|
|
|
@available(SwiftStdlib 6.4, *)
|
|
struct DualConformanceSeq: Sequence, Iterable {
|
|
typealias Element = Int
|
|
typealias BorrowingIterator = BorrowingIteratorAdapter<IndexingIterator<[Int]>>
|
|
func makeIterator() -> IndexingIterator<[Int]> { return [].makeIterator() }
|
|
}
|
|
|
|
@available(SwiftStdlib 6.4, *)
|
|
func testSequencePreferredOverIterable(seq: DualConformanceSeq) {
|
|
for x in seq {
|
|
_ = x
|
|
}
|
|
}
|
|
|
|
// A Iterable conformance that is incomplete because the declared
|
|
// BorrowingIterator type does not conform to BorrowingIteratorProtocol.
|
|
// The type also conforms to Sequence.
|
|
@available(SwiftStdlib 6.4, *)
|
|
struct IncompleteBorrowingWithSequence: Sequence, Iterable { // expected-error {{type 'IncompleteBorrowingWithSequence' does not conform to protocol 'Iterable'}} expected-note {{add stubs for conformance}}
|
|
typealias Element = Int
|
|
typealias BorrowingIterator = Int // expected-note {{possibly intended match 'IncompleteBorrowingWithSequence.BorrowingIterator' (aka 'Int') does not conform to 'BorrowingIteratorProtocol'}}
|
|
func makeIterator() -> IndexingIterator<[Int]> { return [].makeIterator() }
|
|
}
|
|
|
|
@available(SwiftStdlib 6.4, *)
|
|
func testIncompleteBorrowingWithSequence(seq: IncompleteBorrowingWithSequence) {
|
|
for x in seq {
|
|
_ = x
|
|
}
|
|
}
|
|
|
|
// A Iterable conformance that is incomplete because a required member
|
|
// (makeBorrowingIterator) is not provided. The type has no Sequence
|
|
// conformance. Because the conformance is still registered, the compiler
|
|
// attempts the Iterable desugar path, and fails to infer the element
|
|
// type from the incomplete conformance.
|
|
@available(SwiftStdlib 6.4, *)
|
|
struct IncompleteBorrowingNoSequence: Iterable { // expected-error {{type 'IncompleteBorrowingNoSequence' does not conform to protocol 'Iterable'}} expected-note {{add stubs for conformance}}
|
|
typealias Element = Int
|
|
typealias BorrowingIterator = Span<Int>.BorrowingIterator
|
|
// makeBorrowingIterator() intentionally omitted
|
|
}
|
|
|
|
@available(SwiftStdlib 6.4, *)
|
|
func testIncompleteBorrowingNoSequence(seq: IncompleteBorrowingNoSequence) {
|
|
for x in seq { // expected-error {{generic parameter 'Element' could not be inferred}}
|
|
_ = x
|
|
}
|
|
}
|