mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Previously we said that if P1 inherits from P2, then [P1:T] < [P2:T].
However, this didn't generalize to merged associated type symbols;
we always had [P1&P2:T] < [P3:T] even if P3 inherited from both P1
and P2.
This meant that the 'merge' operation did not preserve order, which
fired an assertion in the completion logic.
Fix this by generalizing the linear order to compare the 'support'
of protocols rather than the 'depth', where the 'support' is
defined as the size of the transitive closure of the set under
protocol inheritance.
Then, if you have something like
protocol P1 {}
protocol P2 {}
protocol P3 : P1, P2 {}
The support of 'P1 & P2' is 2, and the support of 'P3' is 3,
therefore [P3:T] < [P1&P2:T] in this example.
Fixes <rdar://problem/83768458>.
22 lines
498 B
Swift
22 lines
498 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
public protocol Collection {
|
|
associatedtype Index
|
|
}
|
|
|
|
public protocol BidirectionalCollection: Collection {}
|
|
|
|
public protocol RandomAccessCollection: BidirectionalCollection {}
|
|
|
|
public protocol Numeric {
|
|
associatedtype Magnitude
|
|
}
|
|
|
|
public protocol SignedNumeric: Numeric {}
|
|
|
|
public protocol BinaryInteger: Numeric {}
|
|
|
|
public protocol SignedInteger: BinaryInteger, SignedNumeric {}
|
|
|
|
struct S<X> where X : RandomAccessCollection, X.Index : SignedInteger {}
|