mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This implements a structural walk over the TypeRepr to catch situations where we attempt to infer `A` from `func f(_: A)`, which references the concrete `A` that will be synthesized in the conforming type. Fixes: - rdar://34956654 / https://github.com/apple/swift/issues/48680 - rdar://38913692 / https://github.com/apple/swift/issues/49066 - rdar://56672411 - https://github.com/apple/swift/issues/50010 - rdar://81587765 / https://github.com/apple/swift/issues/57355 - rdar://117442510
31 lines
884 B
Swift
31 lines
884 B
Swift
// RUN: %target-swift-frontend -emit-ir %s
|
|
|
|
// https://github.com/apple/swift/issues/48464
|
|
|
|
public protocol VectorIndex {
|
|
associatedtype Vector8 : Vector where Vector8.Index == Self, Vector8.Element == UInt8
|
|
}
|
|
public enum VectorIndex1 : VectorIndex {
|
|
case i0
|
|
public typealias Vector8 = Vector1<UInt8>
|
|
}
|
|
public protocol Vector {
|
|
associatedtype Index: VectorIndex
|
|
associatedtype Element
|
|
init(elementForIndex: (Index) -> Element)
|
|
subscript(index: Index) -> Element { get set }
|
|
}
|
|
public struct Vector1<Element> : Vector {
|
|
public var e0: Element
|
|
public init(elementForIndex: (VectorIndex1) -> Element) {
|
|
e0 = elementForIndex(.i0)
|
|
}
|
|
public subscript(index: Index) -> Element {
|
|
get { return e0 }
|
|
set { e0 = newValue }
|
|
}
|
|
}
|
|
extension Vector where Index == VectorIndex1 {
|
|
public init(_ e0: Element) { fatalError() }
|
|
}
|