Skip to content

Commit d47a9c6

Browse files
committed
Sema: Set type on pattern in synthesized enum equatable/hashable conformance.
Fixes a regression caused by swiftlang#67636 in which the patterns for case statements generated to match unavailable enum elements were missing a type. The missing type caused a crash during SILGen if the unavailable element case was the first one in the swtich statement. Resolves rdar://113761850
1 parent baa20ae commit d47a9c6

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/Sema/DerivedConformances.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,7 @@ CaseStmt *DerivedConformance::unavailableEnumElementCaseStmt(
946946
TypeExpr::createImplicit(enumType, C), SourceLoc(), DeclNameLoc(),
947947
DeclNameRef(elt->getBaseIdentifier()), elt, nullptr, /*DC*/ parentDC);
948948
eltPattern->setImplicit();
949+
eltPattern->setType(enumType);
949950
return eltPattern;
950951
};
951952

test/Interpreter/enum_equatable_hashable_correctness.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ enum HasUnavailableCases: Hashable {
3232
case unavailablePayload(UnavailableStruct)
3333
}
3434

35+
enum AllUnavailableCases: Hashable {
36+
@available(*, unavailable)
37+
case nope
38+
}
39+
3540
var EnumSynthesisTests = TestSuite("EnumSynthesis")
3641

3742
EnumSynthesisTests.test("BasicEquatability/Hashability") {

0 commit comments

Comments
 (0)