Skip to content

Commit 06ceb19

Browse files
committed
Diag: Fix inaccuracy in dynamic_self_invalid
1 parent 3d31793 commit 06ceb19

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,8 +2931,8 @@ ERROR(dynamic_self_non_method,none,
29312931
"%select{global|local}0 function cannot return 'Self'", (bool))
29322932

29332933
ERROR(dynamic_self_invalid,none,
2934-
"covariant 'Self' can only appear as the type of a property, subscript or method result; "
2935-
"did you mean '%0'?", (StringRef))
2934+
"covariant 'Self' can only appear as the possibly optional type of a "
2935+
"property, subscript or method result; did you mean '%0'?", (StringRef))
29362936
ERROR(dynamic_self_in_mutable_property,none,
29372937
"mutable property cannot have covariant 'Self' type", ())
29382938
ERROR(dynamic_self_in_stored_property,none,

test/decl/ext/generic.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ extension Array where Element == String { }
149149
extension GenericClass : P3 where T : P3 { }
150150

151151
extension GenericClass where Self : P3 { }
152-
// expected-error@-1{{covariant 'Self' can only appear as the type of a property, subscript or method result; did you mean 'GenericClass'?}} {{30-34=GenericClass}}
152+
// expected-error@-1{{covariant 'Self' can only appear as the possibly optional type of a property, subscript or method result; did you mean 'GenericClass'?}} {{30-34=GenericClass}}
153153
// expected-error@-2{{'GenericClass<T>' in conformance requirement does not refer to a generic parameter or associated type}}
154154

155155
protocol P4 {

test/decl/func/dynamic_self.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ enum E0 {
2424
class C0 {
2525
func f() -> Self { } // okay
2626

27-
func g(_ ds: Self) { } // expected-error{{covariant 'Self' can only appear as the type of a property, subscript or method result; did you mean 'C0'?}}
27+
func g(_ ds: Self) { } // expected-error{{covariant 'Self' can only appear as the possibly optional type of a property, subscript or method result; did you mean 'C0'?}}
2828

29-
func h(_ ds: Self) -> Self { } // expected-error{{covariant 'Self' can only appear as the type of a property, subscript or method result; did you mean 'C0'?}}
29+
func h(_ ds: Self) -> Self { } // expected-error{{covariant 'Self' can only appear as the possibly optional type of a property, subscript or method result; did you mean 'C0'?}}
3030
}
3131

3232
protocol P0 {

test/type/self.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct S0<T> {
55
}
66

77
class C0<T> {
8-
func foo(_ other: Self) { } // expected-error{{covariant 'Self' can only appear as the type of a property, subscript or method result; did you mean 'C0'?}}
8+
func foo(_ other: Self) { } // expected-error{{covariant 'Self' can only appear as the possibly optional type of a property, subscript or method result; did you mean 'C0'?}}
99
}
1010

1111
enum E0<T> {
@@ -47,15 +47,15 @@ final class FinalMario : Mario {
4747

4848
class A<T> {
4949
typealias _Self = Self
50-
// expected-error@-1 {{covariant 'Self' can only appear as the type of a property, subscript or method result; did you mean 'A'?}}
50+
// expected-error@-1 {{covariant 'Self' can only appear as the possibly optional type of a property, subscript or method result; did you mean 'A'?}}
5151
let b: Int
5252
required init(a: Int) {
5353
print("\(Self.self).\(#function)")
5454
Self.y()
5555
b = a
5656
}
5757
static func z(n: Self? = nil) {
58-
// expected-error@-1 {{covariant 'Self' can only appear as the type of a property, subscript or method result; did you mean 'A'?}}
58+
// expected-error@-1 {{covariant 'Self' can only appear as the possibly optional type of a property, subscript or method result; did you mean 'A'?}}
5959
print("\(Self.self).\(#function)")
6060
}
6161
class func y() {

0 commit comments

Comments
 (0)