Files
swift-mirror/test/Constraints/rdar68155466.swift
Kavon Farvardin 3a77083dcc note a small diagnostic regression
the way these diagnostics were added seems to have been through score hacking
and I haven't been able to get the behavior back since introducing the
copyable type constraint for generics. I've logged restoring this as a TODO
to take care of sometime later when I have more time.
2023-03-04 16:22:44 -08:00

31 lines
943 B
Swift

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s
// REQUIRES: objc_interop
import Foundation
@objc class A : NSObject {
func uniqueID() -> Int {
42
}
}
// FIXME: the diagnostic below ideally should have been emitted (rdar://106241733)
struct Loop< // note {{required by generic struct 'Loop' where 'ID' = '() -> Int'}}
Data : RandomAccessCollection,
ID : Hashable,
Content
> {
public init(
_ data: Data,
id: KeyPath<Data.Element, ID>,
content: @escaping (Data.Element) -> Content) {}
}
func data() -> [A] {
return []
}
_ = Loop(data(), id: \.uniqueID) { $0 } // expected-error {{key path cannot refer to instance method 'uniqueID()'}}
// FIXME: the diagnostics below ideally should have been emitted (rdar://106241733)
// error@-1 {{type '() -> Int' cannot conform to 'Hashable'}} note@-1 {{only concrete types such as structs, enums and classes can conform to protocols}}