Skip to content

Commit 7a8dfa9

Browse files
authored
Merge pull request #37902 from etcwilde/ewilde/fix-actor-init-diagnostic
[5.5] Fix actor init diagnostic
2 parents 1666c2b + 9bde9c6 commit 7a8dfa9

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ NOTE(requires_stored_property_inits_here,none,
15261526
"%select{superclass|class}1 %0 requires all stored properties to have "
15271527
"initial values%select{| or use @NSManaged}2", (Type, bool, bool))
15281528
ERROR(class_without_init,none,
1529-
"class %0 has no initializers", (Type))
1529+
"%select{class|actor}0 %1 has no initializers", (bool, Type))
15301530
NOTE(note_no_in_class_init_1,none,
15311531
"stored property %0 without initial value prevents synthesized "
15321532
"initializers",

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,7 @@ static std::string getFixItStringForDecodable(ClassDecl *CD,
12181218
static void diagnoseClassWithoutInitializers(ClassDecl *classDecl) {
12191219
ASTContext &C = classDecl->getASTContext();
12201220
C.Diags.diagnose(classDecl, diag::class_without_init,
1221+
classDecl->isExplicitActor(),
12211222
classDecl->getDeclaredType());
12221223

12231224
// HACK: We've got a special case to look out for and diagnose specifically to

test/decl/var/default_init.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,12 @@ func testBadDefaultInit() {
5151
_ = NotInitializableOptionalStruct() // expected-error {{missing argument for parameter 'opt' in call}}
5252
_ = NotInitializableOptionalClass() // expected-error {{'NotInitializableOptionalClass' cannot be constructed because it has no accessible initializers}}
5353
}
54+
55+
// expected-error@+1{{actor 'NotInitializableActor' has no initializers}}
56+
actor NotInitializableActor {
57+
58+
// expected-note@+1{{stored property 'a' without initial value prevents synthesized initializers}}
59+
var a: Int
60+
// expected-note@+1{{stored property 'b' without initial value prevents synthesized initializers}}
61+
var b: Float
62+
}

0 commit comments

Comments
 (0)