Files
swift-mirror/test/Sema/enum_equatable_conditional.swift
Huon Wilson fe7240ab8a [Sema] Disallow synthesis-in-extensions in Swift 3.
'private' properties can't be accessed in extensions in Swift 3, so synthesizing
a conformance that reads from such things is going to be incorrect in an
extension.
2018-05-09 09:55:41 +10:00

26 lines
664 B
Swift

// RUN: %target-typecheck-verify-swift -swift-version 4
struct NotEquatable { }
enum WithArrayOfNotEquatables : Equatable { // expected-error{{type 'WithArrayOfNotEquatables' does not conform to protocol 'Equatable'}}
case only([NotEquatable])
}
enum WithArrayOfNotEquatables2<T> : Equatable { // expected-error{{type 'WithArrayOfNotEquatables2<T>' does not conform to protocol 'Equatable'}}
case only([T])
}
// Okay: T is Equatable
enum WithArrayOfEquatables1<T: Equatable> : Equatable {
case only([T])
}
enum WithArrayOfEquatables2<T> {
case only([T])
}
// Okay: T is Equatable here too
extension WithArrayOfEquatables2: Equatable where T: Equatable { }