Skip to content

Commit 2283208

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
1 parent 5bdc5cc commit 2283208

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
@@ -239,3 +239,10 @@ func autoclosure1<T>(_: [T], _: X) { }
239239
func test_autoclosure1(ia: [Int]) {
240240
autoclosure1(ia, X()) // okay: resolves to the second function
241241
}
242+
243+
// rdar://problem/64368545 - failed to produce diagnostic (hole propagated to func result without recording a fix)
244+
func test_no_hole_propagation() {
245+
func test(withArguments arguments: [String]) -> String {
246+
return arguments.reduce(0, +) // expected-error {{cannot convert value of type 'Int' to expected argument type 'String'}}
247+
}
248+
}

0 commit comments

Comments
 (0)