Skip to content

Commit 91ddf5f

Browse files
committed
[ConstraintSystem] Don't propagate holes through supertype inference
Disallow holes to be inferred as supertype bindings while inferring bindings from other type variables (based on transitivity of subtype conversions), otherwise it would be possible to record a hole without recording associated fix. Resolves: rdar://problem/64368545 (cherry picked from commit 2283208)
1 parent c93c434 commit 91ddf5f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ void ConstraintSystem::inferTransitiveSupertypeBindings(
6969

7070
auto type = binding.BindingType;
7171

72+
if (type->isHole())
73+
continue;
74+
7275
if (!existingTypes.insert(type->getCanonicalType()).second)
7376
continue;
7477

test/Constraints/overload.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,10 @@ func autoclosure1<T>(_: [T], _: X) { }
238238
func test_autoclosure1(ia: [Int]) {
239239
autoclosure1(ia, X()) // okay: resolves to the second function
240240
}
241+
242+
// rdar://problem/64368545 - failed to produce diagnostic (hole propagated to func result without recording a fix)
243+
func test_no_hole_propagation() {
244+
func test(withArguments arguments: [String]) -> String {
245+
return arguments.reduce(0, +) // expected-error {{cannot convert value of type 'Int' to expected argument type 'String'}}
246+
}
247+
}

0 commit comments

Comments
 (0)