Skip to content

Commit 356522d

Browse files
authored
Merge pull request #16590 from xedin/rdar-39616039
[CSBindings] Don't try to rank bindings based on number of defaults i…
2 parents 233d29a + e6e3c3e commit 356522d

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

lib/Sema/ConstraintSystem.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2790,10 +2790,7 @@ class ConstraintSystem {
27902790
if (formBindingScore(x) < formBindingScore(y))
27912791
return true;
27922792

2793-
if (!x.hasNonDefaultableBindings())
2794-
return false;
2795-
2796-
if (x.FullyBound || x.SubtypeOfExistentialType)
2793+
if (formBindingScore(y) < formBindingScore(x))
27972794
return false;
27982795

27992796
// If the only difference is default types,

test/Constraints/generics.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,3 +561,20 @@ do {
561561
func rdar35890334(_ arr: inout [Int]) {
562562
_ = arr.popFirst() // expected-error {{'[Int]' requires the types '[Int]' and 'ArraySlice<Int>' be equivalent to use 'popFirst'}}
563563
}
564+
565+
// rdar://problem/39616039
566+
567+
func rdar39616039() {
568+
func foo<V>(default: V, _ values: [String: V]) -> V {
569+
return values["foo"] ?? `default`
570+
}
571+
572+
var a = foo(default: 42, ["foo": 0])
573+
a += 1 // ok
574+
575+
var b = foo(default: 42.0, ["foo": 0])
576+
b += 1 // ok
577+
578+
var c = foo(default: 42.0, ["foo": Float(0)])
579+
c += 1 // ok
580+
}

0 commit comments

Comments
 (0)