File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -2441,6 +2441,12 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2441
2441
2442
2442
// / Check that all stored properties have in-class initializers.
2443
2443
void checkRequiredInClassInits (ClassDecl *cd) {
2444
+ // Initializers may be omitted from property declarations in module
2445
+ // interface files so don't diagnose in them.
2446
+ SourceFile *sourceFile = cd->getDeclContext ()->getParentSourceFile ();
2447
+ if (sourceFile && sourceFile->Kind == SourceFileKind::Interface)
2448
+ return ;
2449
+
2444
2450
ClassDecl *source = nullptr ;
2445
2451
for (auto member : cd->getMembers ()) {
2446
2452
auto pbd = dyn_cast<PatternBindingDecl>(member);
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s
2
+ // RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface)
3
+ // RUN: %FileCheck %s < %t.swiftinterface
4
+
5
+ // CHECK: @requires_stored_property_inits public class RequiresStoredPropertyInits
6
+ @requires_stored_property_inits
7
+ public class RequiresStoredPropertyInits {
8
+ // CHECK: final public let a: Swift.Int{{$}}
9
+ public let a : Int = 0
10
+
11
+ public init ( ) { }
12
+ }
You can’t perform that action at this time.
0 commit comments