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) {
1396
1396
if (auto *superclassDecl = classDecl->getSuperclassDecl ()) {
1397
1397
auto *decodableProto = C.getProtocol (KnownProtocolKind::Decodable);
1398
1398
auto superclassType = superclassDecl->getDeclaredInterfaceType ();
1399
- auto ref = classDecl->getParentModule ()->checkConformance (
1399
+ auto ref = classDecl->getParentModule ()->lookupConformance (
1400
1400
superclassType, decodableProto);
1401
1401
if (ref) {
1402
1402
// super conforms to Decodable, so we've failed to inherit init(from:).
@@ -1425,7 +1425,7 @@ static void diagnoseClassWithoutInitializers(ClassDecl *classDecl) {
1425
1425
// likely that the user forgot to override its encode(to:). In this case,
1426
1426
// we can produce a slightly different diagnostic to suggest doing so.
1427
1427
auto *encodableProto = C.getProtocol (KnownProtocolKind::Encodable);
1428
- auto ref = classDecl->getParentModule ()->checkConformance (
1428
+ auto ref = classDecl->getParentModule ()->lookupConformance (
1429
1429
superclassType, encodableProto);
1430
1430
if (ref) {
1431
1431
// 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
97
97
class CodableSubWithInitialValue : CodableSuper {
98
98
var value2 = 10
99
99
}
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