Skip to content

Commit eb01d5d

Browse files
committed
word-smith a diagnostic in preparation for it becoming a family.
Swift SVN r30668
1 parent afe762c commit eb01d5d

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

include/swift/AST/DiagnosticsSema.def

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ NOTE(suggest_partial_overloads,sema,none,
170170
"lists: %1", (StringRef, StringRef))
171171

172172
ERROR(cannot_convert_to_return_type,sema,none,
173-
"cannot convert return expression of type %0 to expected return type %1",
173+
"cannot convert return expression of type %0 to return type %1",
174174
(Type,Type))
175175

176176
ERROR(cannot_return_value_from_void_func,sema,none,

test/Constraints/bridging.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ func bridgeToAnyObject(s: BridgedStruct) -> AnyObject {
6565
}
6666

6767
func bridgeFromObjC(c: BridgedClass) -> BridgedStruct {
68-
return c // expected-error{{cannot convert return expression of type 'BridgedClass' to expected return type 'BridgedStruct'}}
68+
return c // expected-error{{cannot convert return expression of type 'BridgedClass' to return type 'BridgedStruct'}}
6969
return c as BridgedStruct
7070
}
7171

7272
func bridgeFromObjCDerived(s: BridgedClassSub) -> BridgedStruct {
73-
return s // expected-error{{cannot convert return expression of type 'BridgedClassSub' to expected return type 'BridgedStruct'}}
73+
return s // expected-error{{cannot convert return expression of type 'BridgedClassSub' to return type 'BridgedStruct'}}
7474
return s as BridgedStruct
7575
}
7676

test/Constraints/same_types.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func fail2<
7575
where
7676
T.Foo == U.Foo, T.Foo == X, U.Foo == Y // expected-error{{generic parameter 'Foo' cannot be equal to both 'X' and 'Y'}}
7777
>(t: T, u: U) -> (X, Y) {
78-
return (t.foo, u.foo) // expected-error{{cannot convert return expression of type '(X, X)' to expected return type '(X, Y)'}}
78+
return (t.foo, u.foo) // expected-error{{cannot convert return expression of type '(X, X)' to return type '(X, Y)'}}
7979
}
8080

8181
func test4<T: Barrable where T.Bar == Y>(t: T) -> Y {
@@ -87,7 +87,7 @@ func fail3<
8787
where
8888
T.Bar == X // expected-error{{'X' does not conform to required protocol 'Fooable'}}
8989
>(t: T) -> X {
90-
return t.bar // expected-error{{cannot convert return expression of type 'T.Bar' to expected return type 'X'}}
90+
return t.bar // expected-error{{cannot convert return expression of type 'T.Bar' to return type 'X'}}
9191
}
9292

9393
func test5<T: Barrable where T.Bar.Foo == X>(t: T) -> X {
@@ -108,7 +108,7 @@ func fail4<
108108
T.Bar == Y,
109109
T.Bar.Foo == Z // expected-error{{generic parameter 'Foo' cannot be equal to both 'Foo' (aka 'X') and 'Z'}}
110110
>(t: T) -> (Y, Z) {
111-
return (t.bar, t.bar.foo) // expected-error{{cannot convert return expression of type '(Y, X)' to expected return type '(Y, Z)'}}
111+
return (t.bar, t.bar.foo) // expected-error{{cannot convert return expression of type '(Y, X)' to return type '(Y, Z)'}}
112112
}
113113

114114
// TODO: repeat diagnostic
@@ -118,7 +118,7 @@ func fail5<
118118
T.Bar.Foo == Z,
119119
T.Bar == Y // expected-error 2{{generic parameter 'Foo' cannot be equal to both 'Z' and 'Foo'}}
120120
>(t: T) -> (Y, Z) {
121-
return (t.bar, t.bar.foo) // expected-error{{cannot convert return expression of type '(Y, X)' to expected return type '(Y, Z)'}}
121+
return (t.bar, t.bar.foo) // expected-error{{cannot convert return expression of type '(Y, X)' to return type '(Y, Z)'}}
122122
}
123123

124124
func test8<T: Fooable where T.Foo == X, T.Foo == Y>(t: T) {} // expected-error{{generic parameter 'Foo' cannot be equal to both 'X' and 'Y'}}
@@ -130,7 +130,7 @@ func testAssocTypeEquivalence<
130130
}
131131

132132
func fail6<T where T == Int>(t: T) -> Int { // expected-error{{same-type requirement makes generic parameter 'T' non-generic}}
133-
return t // expected-error{{cannot convert return expression of type 'T' to expected return type 'Int'}}
133+
return t // expected-error{{cannot convert return expression of type 'T' to return type 'Int'}}
134134
}
135135

136136
func test8<

test/Misc/misc_diagnostics.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var f2: Float = 3.0
3333
var dd: Double = f1 - f2 // expected-error{{'Float' is not convertible to 'Double'}}
3434

3535
func f() -> Bool {
36-
return 1 + 1 // expected-error{{cannot convert return expression of type 'Int' to expected return type 'Bool'}}
36+
return 1 + 1 // expected-error{{cannot convert return expression of type 'Int' to return type 'Bool'}}
3737
}
3838

3939
// Test that nested diagnostics are properly surfaced.
@@ -60,15 +60,15 @@ func retV() { return true } // expected-error {{unexpected non-void return value
6060
func retAI() -> Int {
6161
let a = [""]
6262
let b = [""]
63-
return (a + b) // expected-error {{cannot convert return expression of type '[String]' to expected return type 'Int'}}
63+
return (a + b) // expected-error {{cannot convert return expression of type '[String]' to return type 'Int'}}
6464
}
6565

6666
func bad_return1() {
6767
return 42 // expected-error {{unexpected non-void return value in void function}}
6868
}
6969

7070
func bad_return2() -> (Int, Int) {
71-
return 42 // expected-error {{cannot convert return expression of type 'Int' to expected return type '(Int, Int)'}}
71+
return 42 // expected-error {{cannot convert return expression of type 'Int' to return type '(Int, Int)'}}
7272
}
7373

7474
// <rdar://problem/14096697> QoI: Diagnostics for trying to return values from void functions

test/decl/func/default-values.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func tupleTypes() {
2424
}
2525

2626
func returnWithDefault() -> (a: Int, b: Int = 42) { // expected-error{{default argument not permitted in a tuple type}}
27-
return 5 // expected-error{{cannot convert return expression of type 'Int' to expected return type '(a: Int, b: Int)'}}
27+
return 5 // expected-error{{cannot convert return expression of type 'Int' to return type '(a: Int, b: Int)'}}
2828
}
2929

3030
// Only the first parameter list of a curried function can have a

test/decl/func/dynamic_self.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class C1 {
4343
// Instance methods have a self of type Self.
4444
func f(b: Bool) -> Self {
4545
// FIXME: below diagnostic should complain about C1 -> Self conversion
46-
if b { return C1(int: 5) } // expected-error{{cannot convert return expression of type 'C1' to expected return type 'Self'}}
46+
if b { return C1(int: 5) } // expected-error{{cannot convert return expression of type 'C1' to return type 'Self'}}
4747

4848
// One can use .dynamicType to attempt to construct an object of type Self.
4949
if !b { return self.dynamicType.init(int: 5) }

test/decl/subscript/addressors.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct Repeated {
4343
return UnsafePointer(base)
4444
}
4545
unsafeAddress { // expected-error {{duplicate definition}}
46-
return base // expected-error {{cannot convert return expression of type 'UnsafeMutablePointer<Int>' to expected return type 'UnsafePointer<Int>'}}
46+
return base // expected-error {{cannot convert return expression of type 'UnsafeMutablePointer<Int>' to return type 'UnsafePointer<Int>'}}
4747
}
4848
}
4949
}

test/decl/subscript/subscripting.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct Y1 {
6262

6363
subscript(i: Int) -> Int {
6464
get {
65-
return x // expected-error{{cannot convert return expression of type 'X' to expected return type 'Int'}}
65+
return x // expected-error{{cannot convert return expression of type 'X' to return type 'Int'}}
6666
}
6767
set {
6868
x = newValue // expected-error{{cannot assign a value of type 'Int' to a value of type 'X'}}

test/decl/var/properties.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ struct Y { }
382382
var y: Y
383383
var x20: X {
384384
get {
385-
return y // expected-error{{cannot convert return expression of type 'Y' to expected return type 'X'}}
385+
return y // expected-error{{cannot convert return expression of type 'Y' to return type 'X'}}
386386
}
387387
set {
388388
y = newValue // expected-error{{cannot assign a value of type 'X' to a value of type 'Y'}}
@@ -391,7 +391,7 @@ var x20: X {
391391

392392
var x21: X {
393393
get {
394-
return y // expected-error{{cannot convert return expression of type 'Y' to expected return type 'X'}}
394+
return y // expected-error{{cannot convert return expression of type 'Y' to return type 'X'}}
395395
}
396396
set(v) {
397397
y = v // expected-error{{cannot assign a value of type 'X' to a value of type 'Y'}}

0 commit comments

Comments
 (0)