Skip to content

Commit e3bf6bd

Browse files
authored
Merge pull request #68112 from tshortli/enum-equatable-all-elements-unavailable
Sema: Set type on pattern in synthesized enum equatable/hashable conformance
2 parents ffc0b98 + d47a9c6 commit e3bf6bd

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)