Skip to content

Commit b421d08

Browse files
committed
[GSB] Use resolved type when looking for a representative constraint.
When looking for a representative superclass constraint, take into account other same-type constraints by comparing against the resolved superclass constraint type rather than the type as spelled. Fixes SR-8179 / rdar://problem/41851224.
1 parent a9ebaef commit b421d08

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7062,7 +7062,7 @@ void GenericSignatureBuilder::checkSuperclassConstraints(
70627062
EquivalenceClass *equivClass) {
70637063
assert(equivClass->superclass && "No superclass constraint?");
70647064

7065-
// Resolve any this-far-unresolved dependent types.
7065+
// Resolve any thus-far-unresolved dependent types.
70667066
Type resolvedSuperclass =
70677067
resolveDependentMemberTypes(*this, equivClass->superclass);
70687068

@@ -7075,13 +7075,13 @@ void GenericSignatureBuilder::checkSuperclassConstraints(
70757075

70767076
Type resolvedType =
70777077
resolveDependentMemberTypes(*this, constraint.value);
7078-
return resolvedType->isEqual(equivClass->superclass);
7078+
return resolvedType->isEqual(resolvedSuperclass);
70797079
},
70807080
[&](const Constraint<Type> &constraint) {
70817081
Type superclass = constraint.value;
70827082

70837083
// If this class is a superclass of the "best"
7084-
if (superclass->isExactSuperclassOf(equivClass->superclass))
7084+
if (superclass->isExactSuperclassOf(resolvedSuperclass))
70857085
return ConstraintRelation::Redundant;
70867086

70877087
// Otherwise, it conflicts.
@@ -7091,7 +7091,7 @@ void GenericSignatureBuilder::checkSuperclassConstraints(
70917091
diag::redundant_superclass_constraint,
70927092
diag::superclass_redundancy_here);
70937093

7094-
// Resolve any this-far-unresolved dependent types.
7094+
// Record the resolved superclass type.
70957095
equivClass->superclass = resolvedSuperclass;
70967096

70977097
// If we have a concrete type, check it.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-frontend -emit-sil %s
2+
3+
protocol SignalInterface {
4+
associatedtype OutputValue
5+
}
6+
7+
class Signal<OV>: SignalInterface {
8+
typealias OutputValue = OV
9+
}
10+
11+
extension Signal {
12+
func foo<U>(_: U) -> SignalChannel<[U], Signal<Array<U>>>
13+
where OutputValue == Optional<U> { return SignalChannel() }
14+
}
15+
16+
struct SignalChannel<OutputValue, Output: Signal<OutputValue>> { }
17+

0 commit comments

Comments
 (0)