Skip to content

Commit 2ad79f4

Browse files
committed
---
yaml --- r: 315103 b: refs/heads/master-next c: 9c0aad3 h: refs/heads/master i: 315101: 39f5599 315099: 50c7387 315095: 6a17b29 315087: 937ac2a 315071: a978159
1 parent 917d5a4 commit 2ad79f4

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3fe9333052029c114ef816ea805c335eb1ee8a99
3-
refs/heads/master-next: 469e06ae2c76c12a310cdfda2173f1fafc626d97
3+
refs/heads/master-next: 9c0aad3737eaa19787aa6cc755620a93f5c39227
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/Sema/CSSimplify.cpp

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,8 +2657,20 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
26572657
case ConstraintKind::Subtype:
26582658
case ConstraintKind::Conversion:
26592659
case ConstraintKind::ArgumentConversion:
2660-
case ConstraintKind::OperatorArgumentConversion:
2660+
case ConstraintKind::OperatorArgumentConversion: {
2661+
if (typeVar1) {
2662+
if (auto *locator = typeVar1->getImpl().getLocator()) {
2663+
// TODO(diagnostics): Only binding here for function types, because
2664+
// doing so for KeyPath types leaves the constraint system in an
2665+
// unexpected state for key path diagnostics should we fail.
2666+
if (locator->isLastElement(ConstraintLocator::KeyPathType) &&
2667+
type2->is<AnyFunctionType>())
2668+
return matchTypesBindTypeVar(typeVar1, type2, kind, flags, locator,
2669+
formUnsolvedResult);
2670+
}
2671+
}
26612672
return formUnsolvedResult();
2673+
}
26622674

26632675
case ConstraintKind::OpaqueUnderlyingType:
26642676
case ConstraintKind::ApplicableFunction:
@@ -5590,22 +5602,6 @@ ConstraintSystem::simplifyKeyPathConstraint(Type keyPathTy,
55905602
return SolutionKind::Error;
55915603
}
55925604

5593-
// If we have nothing else, and there's another constraint on our keyPathTy
5594-
// type variable that's some sort of conversion to a function type, use that
5595-
// constraint's second type.
5596-
if (keyPathTy->isTypeVariableOrMember()) {
5597-
for (auto constraint : getActiveConstraints()) {
5598-
if (constraint.getKind() > ConstraintKind::OperatorArgumentConversion)
5599-
continue;
5600-
if (constraint.getFirstType().getPointer() == keyPathTy.getPointer()) {
5601-
auto otherType = constraint.getSecondType();
5602-
if (otherType->is<FunctionType>() &&
5603-
!tryMatchRootAndValueFromType(otherType))
5604-
return SolutionKind::Error;
5605-
}
5606-
}
5607-
}
5608-
56095605
// See if we resolved overloads for all the components involved.
56105606
enum {
56115607
ReadOnly,
@@ -5736,10 +5732,7 @@ ConstraintSystem::simplifyKeyPathConstraint(Type keyPathTy,
57365732

57375733
auto loc = locator.getBaseLocator();
57385734
if (definitelyFunctionType) {
5739-
Type fnType =
5740-
FunctionType::get({AnyFunctionType::Param(rootTy)}, valueTy,
5741-
AnyFunctionType::ExtInfo().withThrows(false));
5742-
return matchTypes(keyPathTy, fnType, ConstraintKind::Bind, subflags, loc);
5735+
return SolutionKind::Solved;
57435736
} else if (!anyComponentsUnresolved ||
57445737
(definitelyKeyPathType && capability == ReadOnly)) {
57455738
auto resolvedKPTy =

0 commit comments

Comments
 (0)