Skip to content

Commit 6edfc20

Browse files
committed
---
yaml --- r: 345958 b: refs/heads/master c: 21475b3 h: refs/heads/master
1 parent 0964528 commit 6edfc20

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d84c7d475c3b2b156c10ce15608004173ce5dbe9
2+
refs/heads/master: 21475b3ee52fd9938819102ef6ca0cc3767c018a
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/Sema/CSSimplify.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,6 +2473,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
24732473
if (conversionsOrFixes.size() > 1) {
24742474
auto fixedLocator = getConstraintLocator(locator);
24752475
SmallVector<Constraint *, 2> constraints;
2476+
24762477
for (auto potential : conversionsOrFixes) {
24772478
auto constraintKind = kind;
24782479

@@ -2485,6 +2486,10 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
24852486
constraints.push_back(
24862487
Constraint::createRestricted(*this, constraintKind, *restriction,
24872488
type1, type2, fixedLocator));
2489+
2490+
if (constraints.back()->getKind() == ConstraintKind::Equal)
2491+
constraints.back()->setFavored();
2492+
24882493
continue;
24892494
}
24902495

@@ -2493,6 +2498,16 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
24932498
Constraint::createFixed(*this, constraintKind, fix, type1, type2,
24942499
fixedLocator));
24952500
}
2501+
2502+
// Sort favored constraints first.
2503+
std::sort(constraints.begin(), constraints.end(),
2504+
[&](Constraint *lhs, Constraint *rhs) -> bool {
2505+
if (lhs->isFavored() == rhs->isFavored())
2506+
return false;
2507+
2508+
return lhs->isFavored();
2509+
});
2510+
24962511
addDisjunctionConstraint(constraints, fixedLocator);
24972512
return getTypeMatchSuccess();
24982513
}

trunk/test/expr/primary/literal/collection_upcast_opt.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ struct TakesArray<T> {
1515
// CHECK: assign_expr
1616
// CHECK-NOT: collection_upcast_expr
1717
// CHECK: array_expr type='[(X) -> Void]'
18-
// CHECK-NEXT: function_conversion_expr implicit type='(X) -> Void'
18+
// CHECK: semantic_expr
19+
// CHECK: function_conversion_expr implicit type='(X) -> Void'
1920
// CHECK-NEXT: {{declref_expr.*x1}}
2021
// CHECK-NEXT: function_conversion_expr implicit type='(X) -> Void'
2122
// CHECK-NEXT: {{declref_expr.*x2}}

trunk/validation-test/Sema/type_checker_perf/slow/rdar24543332.swift.gyb renamed to trunk/validation-test/Sema/type_checker_perf/fast/rdar24543332.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %scale-test --invert-result --begin 5 --end 20 --step 1 --select NumLeafScopes %s
1+
// RUN: %scale-test --begin 5 --end 20 --step 1 --select NumLeafScopes %s
22
// REQUIRES: OS=macosx
33
// REQUIRES: asserts
44

0 commit comments

Comments
 (0)