[CS] Handle conditional requirements in existential conversions of literals.

This likely affects other things too, but literals are where it appears
most. Previously, the mid-solving literal types like Array<$T0> were
just checked for whether they conformed to the protocol, without
acknowledging that this might introduce requirements on $T0, instead the
conditional requirements were checked against $T0, and so
failed (there's no reason that $T0 should satisfy the requirements at
all, it's a recently-constructed transient type variable). Instead,
capture the requirements and add them as constraints to the type
variable.

Fixes https://bugs.swift.org/browse/SR-7192 and rdar://problem/38461036
and improves https://bugs.swift.org/browse/SR-6941.
This commit is contained in:
Huon Wilson
2018-03-22 11:38:17 +11:00
parent b15fb396a0
commit 3ff1d34bf3
2 changed files with 132 additions and 1 deletions

View File

@@ -2580,7 +2580,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
case ConstraintKind::SelfObjectOfProtocol:
if (auto conformance =
TC.containsProtocol(type, protocol, DC,
ConformanceCheckFlags::InExpression)) {
(ConformanceCheckFlags::InExpression|
ConformanceCheckFlags::SkipConditionalRequirements))) {
return recordConformance(*conformance);
}
break;