mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The language has limitations that don't allow us to express the API we actually want, and we have to resort to underscored protocols again. <rdar://problem/20715009> Implement recursive protocol constraints <rdar://problem/20477576> 'where' constraints on associated types in protocols Swift SVN r27820
39 lines
986 B
Swift
39 lines
986 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
import StdlibUnittest
|
|
|
|
//
|
|
// Check that CollectionType._prext_SubSlice is constrained to CollectionType.
|
|
//
|
|
|
|
// expected-error@+1 {{type 'CollectionWithBadSubSlice' does not conform to protocol 'CollectionType'}}
|
|
struct CollectionWithBadSubSlice : CollectionType {
|
|
var startIndex: MinimalForwardIndex {
|
|
fatalError("unreachable")
|
|
}
|
|
|
|
var endIndex: MinimalForwardIndex {
|
|
fatalError("unreachable")
|
|
}
|
|
|
|
subscript(i: MinimalForwardIndex) -> OpaqueValue<Int> {
|
|
fatalError("unreachable")
|
|
}
|
|
|
|
// expected-note@+1 {{possibly intended match '_prext_SubSlice' does not conform to '_CollectionDefaultsType'}}
|
|
typealias _prext_SubSlice = OpaqueValue<Int8>
|
|
}
|
|
|
|
func useCollectionTypeSubSliceIndex<
|
|
C : CollectionType
|
|
where
|
|
C._prext_SubSlice.Index : BidirectionalIndexType
|
|
>(c: C) {}
|
|
|
|
func useCollectionTypeSubSliceGeneratorElement<
|
|
C : CollectionType
|
|
where
|
|
C._prext_SubSlice.Generator.Element == C.Generator.Element
|
|
>(c: C) {}
|
|
|