Skip to content

Commit d8c5e79

Browse files
committed
Sema: Fix incorrect usage of NormalProtocolConformance in Codable synthesis
Noticed by inspection. It looks like there are no tests for generic Codable types. I'm just adding one to cover the changed code path.
1 parent 59f1133 commit d8c5e79

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8822,8 +8822,7 @@ void TypeChecker::synthesizeMemberForLookup(NominalTypeDecl *target,
88228822
if (auto ref = conformsToProtocol(targetType, protocol, target,
88238823
ConformanceCheckFlags::Used,
88248824
SourceLoc())) {
8825-
if (auto *conformance =
8826-
dyn_cast_or_null<NormalProtocolConformance>(ref->getConcrete())) {
8825+
if (auto *conformance = ref->getConcrete()->getRootNormalConformance()) {
88278826
if (conformance->isIncomplete()) {
88288827
// Check conformance, forcing synthesis.
88298828
//

test/decl/protocol/special/coding/struct_codable_member_type_lookup.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,3 +645,7 @@ extension C.Inner {
645645
case value
646646
}
647647
}
648+
649+
struct GenericCodableStruct<T : Codable> : Codable {}
650+
651+
func foo(_: GenericCodableStruct<Int>.CodingKeys) // expected-error {{'CodingKeys' is inaccessible due to 'private' protection level}}

0 commit comments

Comments
 (0)