Skip to content

Commit 54238c0

Browse files
committed
[Constraint solver] Dont assume orphans are along in the inactive list.
The inactive list may contain other disjunctions associated with bound type variables. For now, make sure we recover the orphan directly to fix the crash in SR-4056 / rdar://problem/30686926. Later, we can treat these as orphans, too. (cherry picked from commit 99a1396)
1 parent 5bdc52b commit 54238c0

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,8 +2137,7 @@ bool ConstraintSystem::solveRec(SmallVectorImpl<Solution> &solutions,
21372137
}
21382138
} else {
21392139
// Get the orphaned constraint.
2140-
assert(InactiveConstraints.size() == 1 && "supposed to be an orphan!");
2141-
orphaned = &InactiveConstraints.front();
2140+
orphaned = allOrphanedConstraints[component - firstOrphanedConstraint];
21422141
}
21432142
CG.setOrphanedConstraint(orphaned);
21442143

test/Constraints/optional.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,21 @@ func rdar29977523(lhs: AnyObject?!, rhs: AnyObject?) {
176176

177177
calleeRdar29977523(lhs, rhs)
178178
}
179+
180+
// SR-4056
181+
protocol P1 { }
182+
183+
class C1: P1 { }
184+
185+
protocol P2 {
186+
var prop: C1? { get }
187+
}
188+
189+
class C2 {
190+
var p1: P1?
191+
var p2: P2?
192+
193+
var computed: P1? {
194+
return p1 ?? p2?.prop
195+
}
196+
}

0 commit comments

Comments
 (0)