Skip to content

Commit 8c67d15

Browse files
authored
Merge pull request #72550 from fummicc1/diagnostics-init-msg-improvement
[AST] Improve diagnostic message about `constructor` expression
2 parents 86f5441 + 4dda7ef commit 8c67d15

15 files changed

+61
-61
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4669,7 +4669,7 @@ ERROR(value_of_module_type,none,
46694669
"expected module member name after module name", ())
46704670

46714671
ERROR(value_of_metatype_type,none,
4672-
"expected member name or constructor call after type name%select{|; this "
4672+
"expected member name or initializer call after type name%select{|; this "
46734673
"will be an error in Swift 6}0", (bool))
46744674

46754675
NOTE(add_parens_to_type,none,
@@ -6516,9 +6516,9 @@ ERROR(dynamic_replacement_replaced_not_objc_dynamic, none,
65166516
ERROR(dynamic_replacement_replacement_not_objc_dynamic, none,
65176517
"%0 is marked @objc dynamic", (DeclName))
65186518
ERROR(dynamic_replacement_replaced_constructor_is_convenience, none,
6519-
"replaced constructor %0 is marked as convenience", (DeclNameRef))
6519+
"replaced initializer %0 is marked as convenience", (DeclNameRef))
65206520
ERROR(dynamic_replacement_replaced_constructor_is_not_convenience, none,
6521-
"replaced constructor %0 is not marked as convenience", (DeclNameRef))
6521+
"replaced initializer %0 is not marked as convenience", (DeclNameRef))
65226522

65236523
//------------------------------------------------------------------------------
65246524
// MARK: @_typeEraser()

test/Constraints/dynamic_lookup.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,11 @@ func test_dynamic_subscript_accepts_type_name_argument() {
454454
}
455455

456456
func test(a: AnyObject, optA: AnyObject?) {
457-
let _ = a[A] // expected-warning {{expected member name or constructor call after type name; this will be an error in Swift 6}}
457+
let _ = a[A] // expected-warning {{expected member name or initializer call after type name; this will be an error in Swift 6}}
458458
// expected-note@-1 {{add arguments after the type to construct a value of the type}} {{16-16=()}}
459459
// expected-note@-2 {{use '.self' to reference the type object}} {{16-16=.self}}
460460

461-
let _ = optA?[A] // expected-warning {{expected member name or constructor call after type name; this will be an error in Swift 6}}
461+
let _ = optA?[A] // expected-warning {{expected member name or initializer call after type name; this will be an error in Swift 6}}
462462
// expected-note@-1 {{add arguments after the type to construct a value of the type}} {{20-20=()}}
463463
// expected-note@-2 {{use '.self' to reference the type object}} {{20-20=.self}}
464464
}

test/Constraints/dynamic_lookup_swift6.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ func test_dynamic_subscript_accepts_type_name_argument() {
1313
}
1414

1515
func test(a: AnyObject, optA: AnyObject?) {
16-
let _ = a[A] // expected-error {{expected member name or constructor call after type name}}
16+
let _ = a[A] // expected-error {{expected member name or initializer call after type name}}
1717
// expected-note@-1 {{add arguments after the type to construct a value of the type}} {{16-16=()}}
1818
// expected-note@-2 {{use '.self' to reference the type object}} {{16-16=.self}}
1919

20-
let _ = optA?[A] // expected-error {{expected member name or constructor call after type name}}
20+
let _ = optA?[A] // expected-error {{expected member name or initializer call after type name}}
2121
// expected-note@-1 {{add arguments after the type to construct a value of the type}} {{20-20=()}}
2222
// expected-note@-2 {{use '.self' to reference the type object}} {{20-20=.self}}
2323
}

test/Constraints/members.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ func rdar50679161() {
617617

618618
_ = { () -> Void in
619619
var foo = S
620-
// expected-error@-1 {{expected member name or constructor call after type name}}
620+
// expected-error@-1 {{expected member name or initializer call after type name}}
621621
// expected-note@-2 {{add arguments after the type to construct a value of the type}}
622622
// expected-note@-3 {{use '.self' to reference the type object}}
623623
print(foo)

test/Constraints/metatypes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ let test5 : S.Type = S.self
1515
let test6 : AnyClass = S.self // expected-error {{cannot convert value of type 'S.Type' to specified type 'AnyClass' (aka 'any AnyObject.Type')}}
1616

1717
func acceptMeta<T>(_ meta: T.Type) { }
18-
acceptMeta(A) // expected-error {{expected member name or constructor call after type name}}
18+
acceptMeta(A) // expected-error {{expected member name or initializer call after type name}}
1919
// expected-note@-1 {{add arguments after the type to construct a value of the type}}
2020
// expected-note@-2 {{use '.self' to reference the type object}}
2121

22-
acceptMeta((A) -> Void) // expected-error {{expected member name or constructor call after type name}}
22+
acceptMeta((A) -> Void) // expected-error {{expected member name or initializer call after type name}}
2323
// expected-note@-1 {{use '.self' to reference the type object}}
2424

2525
func id<T>(_ x: T.Type) -> T.Type { x }

test/Constraints/result_builder_diags.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ func acceptMetatype<T>(_: T.Type) -> Bool { true }
313313

314314
func syntacticUses<T>(_: T) {
315315
tuplify(true) { x in
316-
if x && acceptMetatype(T) { // expected-error{{expected member name or constructor call after type name}}
316+
if x && acceptMetatype(T) { // expected-error{{expected member name or initializer call after type name}}
317317
// expected-note@-1{{use '.self' to reference the type object}}
318-
acceptMetatype(T) // expected-error{{expected member name or constructor call after type name}}
318+
acceptMetatype(T) // expected-error{{expected member name or initializer call after type name}}
319319
// expected-note@-1{{use '.self' to reference the type object}}
320320
}
321321
}

test/Constraints/subscript.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ func test_subscript_accepts_type_name_argument() {
229229
}
230230

231231
func test(a: A, optA: A?) {
232-
let _ = a[A] // expected-warning {{expected member name or constructor call after type name; this will be an error in Swift 6}}
232+
let _ = a[A] // expected-warning {{expected member name or initializer call after type name; this will be an error in Swift 6}}
233233
// expected-note@-1 {{add arguments after the type to construct a value of the type}} {{16-16=()}}
234234
// expected-note@-2 {{use '.self' to reference the type object}} {{16-16=.self}}
235235

236-
let _ = optA?[A] // expected-warning {{expected member name or constructor call after type name; this will be an error in Swift 6}}
236+
let _ = optA?[A] // expected-warning {{expected member name or initializer call after type name; this will be an error in Swift 6}}
237237
// expected-note@-1 {{add arguments after the type to construct a value of the type}} {{20-20=()}}
238238
// expected-note@-2 {{use '.self' to reference the type object}} {{20-20=.self}}
239239
}

test/Constraints/subscript_swift6.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ func test_subscript_accepts_type_name_argument() {
77
}
88

99
func test(a: A, optA: A?) {
10-
let _ = a[A] // expected-error {{expected member name or constructor call after type name}}
10+
let _ = a[A] // expected-error {{expected member name or initializer call after type name}}
1111
// expected-note@-1 {{add arguments after the type to construct a value of the type}} {{16-16=()}}
1212
// expected-note@-2 {{use '.self' to reference the type object}} {{16-16=.self}}
1313

14-
let _ = optA?[A] // expected-error {{expected member name or constructor call after type name}}
14+
let _ = optA?[A] // expected-error {{expected member name or initializer call after type name}}
1515
// expected-note@-1 {{add arguments after the type to construct a value of the type}} {{20-20=()}}
1616
// expected-note@-2 {{use '.self' to reference the type object}} {{20-20=.self}}
1717
}

0 commit comments

Comments
 (0)