Skip to content

Commit fe8f6ae

Browse files
committed
Sema: More checkConformance() => lookupConformance()
1 parent 728d680 commit fe8f6ae

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ static void diagnoseClassWithoutInitializers(ClassDecl *classDecl) {
13961396
if (auto *superclassDecl = classDecl->getSuperclassDecl()) {
13971397
auto *decodableProto = C.getProtocol(KnownProtocolKind::Decodable);
13981398
auto superclassType = superclassDecl->getDeclaredInterfaceType();
1399-
auto ref = classDecl->getParentModule()->checkConformance(
1399+
auto ref = classDecl->getParentModule()->lookupConformance(
14001400
superclassType, decodableProto);
14011401
if (ref) {
14021402
// super conforms to Decodable, so we've failed to inherit init(from:).
@@ -1425,7 +1425,7 @@ static void diagnoseClassWithoutInitializers(ClassDecl *classDecl) {
14251425
// likely that the user forgot to override its encode(to:). In this case,
14261426
// we can produce a slightly different diagnostic to suggest doing so.
14271427
auto *encodableProto = C.getProtocol(KnownProtocolKind::Encodable);
1428-
auto ref = classDecl->getParentModule()->checkConformance(
1428+
auto ref = classDecl->getParentModule()->lookupConformance(
14291429
superclassType, encodableProto);
14301430
if (ref) {
14311431
// We only want to produce this version of the diagnostic if the

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,13 @@ class EncodableSubWithoutInitialValue : CodableSuper { // expected-error {{class
9797
class CodableSubWithInitialValue : CodableSuper {
9898
var value2 = 10
9999
}
100+
101+
class GenericCodableSuper<T>: Decodable {}
102+
103+
class GenericCodableSub<T>: GenericCodableSuper<T> {
104+
// expected-error@-1 {{class 'GenericCodableSub' has no initializers}}
105+
// expected-note@-2 {{did you mean to override 'init(from:)'?}}
106+
// expected-warning@-2 {{'required' initializer 'init(from:)' must be provided by subclass of 'GenericCodableSuper<T>'; this is an error in Swift 6}}
107+
var t: T
108+
// expected-note@-1 {{stored property 't' without initial value prevents synthesized initializers}}
109+
}

0 commit comments

Comments
 (0)