Skip to content

Commit 260a482

Browse files
committed
[Diagnostics] NFC: Adjust some binary operator checks to verify exact diagnostic location
If one of the arguments to binary operator is invalid, let's verify that diagnostic points directly to it.
1 parent 1cd1f25 commit 260a482

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

test/Constraints/bridging.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,12 @@ func rdar19831919() {
261261

262262
// <rdar://problem/19831698> Incorrect 'as' fixits offered for invalid literal expressions
263263
func rdar19831698() {
264-
var v70 = true + 1 // expected-error{{cannot convert value of type 'Bool' to expected argument type 'Int'}}
264+
var v70 = true + 1 // expected-error@:13 {{cannot convert value of type 'Bool' to expected argument type 'Int'}}
265265
var v71 = true + 1.0 // expected-error{{binary operator '+' cannot be applied to operands of type 'Bool' and 'Double'}}
266266
// expected-note@-1{{overloads for '+'}}
267267
var v72 = true + true // expected-error{{binary operator '+' cannot be applied to two 'Bool' operands}}
268-
var v73 = true + [] // expected-error{{cannot convert value of type 'Bool' to expected argument type 'Array<Bool>'}}
269-
var v75 = true + "str" // expected-error {{cannot convert value of type 'Bool' to expected argument type 'String'}}
268+
var v73 = true + [] // expected-error@:13 {{cannot convert value of type 'Bool' to expected argument type 'Array<Bool>'}}
269+
var v75 = true + "str" // expected-error@:13 {{cannot convert value of type 'Bool' to expected argument type 'String'}}
270270
}
271271

272272
// <rdar://problem/19836341> Incorrect fixit for NSString? to String? conversions

test/Constraints/diagnostics.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func recArea(_ h: Int, w : Int) {
182182

183183
// <rdar://problem/17224804> QoI: Error In Ternary Condition is Wrong
184184
func r17224804(_ monthNumber : Int) {
185-
// expected-error @+1 {{cannot convert value of type 'Int' to expected argument type 'String'}}
185+
// expected-error@+1:49 {{cannot convert value of type 'Int' to expected argument type 'String'}}
186186
let monthString = (monthNumber <= 9) ? ("0" + monthNumber) : String(monthNumber)
187187
}
188188

@@ -720,7 +720,7 @@ func r24251022() {
720720
_ = a + b // expected-error {{binary operator '+' cannot be applied to operands of type 'Int' and 'UInt32'}} expected-note {{overloads for '+' exist with these partially matching parameter lists: (Int, Int), (UInt32, UInt32)}}
721721
a += a +
722722
b // expected-error {{cannot convert value of type 'UInt32' to expected argument type 'Int'}}
723-
a += b // expected-error {{cannot convert value of type 'UInt32' to expected argument type 'Int'}}
723+
a += b // expected-error@:8 {{cannot convert value of type 'UInt32' to expected argument type 'Int'}}
724724
}
725725

726726
func overloadSetResultType(_ a : Int, b : Int) -> Int {

test/Misc/misc_diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if let realRoomName = roomName as! NSString { // expected-warning{{forced cast f
1414

1515
var pi = 3.14159265358979
1616
var d: CGFloat = 2.0
17-
var dpi:CGFloat = d*pi // expected-error{{cannot convert value of type 'Double' to expected argument type 'CGFloat'}}
17+
var dpi:CGFloat = d*pi // expected-error@:21{{cannot convert value of type 'Double' to expected argument type 'CGFloat'}}
1818

1919
let ff: CGFloat = floorf(20.0) // expected-error{{cannot convert value of type 'Float' to specified type 'CGFloat'}}
2020

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -typecheck -enable-source-import -primary-file %s %S/Inputs/multi-file-with-main/main.swift -module-name=MultiFile -sdk "" -verify
22

33
func testOperator() {
4-
let x: Int = 1 +++ "abc" // expected-error {{cannot convert value of type 'String' to expected argument type 'Int'}}
4+
let x: Int = 1 +++ "abc" // expected-error@:22 {{cannot convert value of type 'String' to expected argument type 'Int'}}
55

66
_ = x
77
}

0 commit comments

Comments
 (0)