mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Introduce a warning about redeclaring the associated types from an inherited protocol in the protocol being checked: * If the new declaration is an associated type, note that the declaration could be replaced by requirements in the protocol's where clause. * If the new declaration is a typealias, note that it could be replaced by a same-type constraint in the protocol's where clause.
36 lines
725 B
Swift
36 lines
725 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
protocol Incrementable {
|
|
func successor() -> Self
|
|
}
|
|
|
|
protocol _ForwardIndex {
|
|
associatedtype Distance = MyInt // expected-note{{declared here}}
|
|
}
|
|
|
|
protocol ForwardIndex : _ForwardIndex {
|
|
}
|
|
|
|
protocol _BidirectionalIndex : _ForwardIndex {
|
|
func predecessor() -> Self
|
|
}
|
|
|
|
protocol BidirectionalIndex : ForwardIndex, _BidirectionalIndex {
|
|
}
|
|
|
|
protocol _RandomAccessIndex : _BidirectionalIndex {
|
|
associatedtype Distance // expected-warning{{redeclaration of associated type 'Distance}}
|
|
}
|
|
|
|
protocol RandomAccessIndex
|
|
: BidirectionalIndex, _RandomAccessIndex {}
|
|
|
|
struct MyInt : RandomAccessIndex
|
|
{
|
|
typealias Distance = MyInt
|
|
|
|
func predecessor() -> MyInt {
|
|
return self
|
|
}
|
|
}
|