File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
test/decl/protocol/special/coding Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -97,3 +97,13 @@ class EncodableSubWithoutInitialValue : CodableSuper { // expected-error {{class
9797class 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+ }
You can’t perform that action at this time.
0 commit comments