mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When considering an implementation from a protocol extension as a possible witness to a protocol requirement, and using that witness to try to infer the protocol's associated types, we would sometimes consider `AssocType == ConformingType.AssocType` as a potential solution, even though this is a tautology; we would subsequently mark the potential solution as failed (because ConformingType.AssocType doesn't exist yet; it doesn't conform to any protocols) even when the witness is necessary to infer other associated types. Worse, this would introduce an order dependency when certain potential witnesses were visited before the right associated types were inferred. Fix this by filtering out useless tautological inferred witnesses before trying to validate them for conforming to the necessary requirements. Fixes rdar://problem/29954938.
22 lines
674 B
Swift
22 lines
674 B
Swift
// RUN: %target-swift-frontend -typecheck -verify %s
|
|
|
|
// rdar://problem/29954938 -- A bug in associated type inference exposed an
|
|
// order dependency where, if a type conformed to Collection in one extension
|
|
// then conformed to MutableCollection in a later extension, it would fail
|
|
// to type-check.
|
|
|
|
struct Butz<Flubz: Comparable> { }
|
|
|
|
extension Butz: Collection {
|
|
public var startIndex: Flubz { fatalError() }
|
|
public var endIndex: Flubz { fatalError() }
|
|
}
|
|
|
|
extension Butz: MutableCollection {
|
|
public subscript (_ position: Flubz) -> Flubz {
|
|
get { fatalError() }
|
|
set { }
|
|
}
|
|
public func index(after i: Flubz) -> Flubz { fatalError() }
|
|
}
|