Skip to content

Commit 8a5b01f

Browse files
committed
[ConstraintSystem] Fail ~= synthesis if constraint generation fails
If constraint generation for application of `~=` failed that should result in an immediate synthesis failure. Resolves: rdar://92366212 (cherry picked from commit 48e70ed)
1 parent 48bbeaa commit 8a5b01f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8967,7 +8967,8 @@ static bool inferEnumMemberThroughTildeEqualsOperator(
89678967
}
89688968
}
89698969

8970-
cs.generateConstraints(target, FreeTypeVariableBinding::Disallow);
8970+
if (cs.generateConstraints(target, FreeTypeVariableBinding::Disallow))
8971+
return true;
89718972

89728973
// Sub-expression associated with expression pattern is the enum element
89738974
// access which needs to be connected to the provided element type.

test/expr/closure/multi_statement.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,16 @@ func test_wrapped_var_without_initializer() {
316316
var v;
317317
}
318318
}
319+
320+
// rdar://92366212 - crash in ConstraintSystem::getType
321+
func test_unknown_refs_in_tilde_operator() {
322+
enum E {
323+
}
324+
325+
let _: (E) -> Void = {
326+
if case .test(unknown) = $0 {
327+
// expected-error@-1 {{type 'E' has no member 'test'}}
328+
// expected-error@-2 2 {{cannot find 'unknown' in scope}}
329+
}
330+
}
331+
}

0 commit comments

Comments
 (0)