Skip to content

Commit 48e70ed

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
1 parent 0e4d16d commit 48e70ed

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
@@ -8978,7 +8978,8 @@ static bool inferEnumMemberThroughTildeEqualsOperator(
89788978
}
89798979
}
89808980

8981-
cs.generateConstraints(target, FreeTypeVariableBinding::Disallow);
8981+
if (cs.generateConstraints(target, FreeTypeVariableBinding::Disallow))
8982+
return true;
89828983

89838984
// Sub-expression associated with expression pattern is the enum element
89848985
// 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)