Skip to content

Commit d4030a9

Browse files
Dave AbrahamsDave Abrahams
authored andcommitted
[stdlib] Fix constraint tests for new integers
1 parent ccf555c commit d4030a9

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

test/Constraints/bridging.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ let d: Double = 3.14159
194194
inferDouble = d
195195

196196
// rdar://problem/17962491
197-
var inferDouble2 = 1 % 3 / 3.0 // expected-error{{'%' is unavailable: Use truncatingRemainder instead}}
197+
_ = 1 % 3 / 3.0 // expected-error{{'%' is unavailable: Use truncatingRemainder instead}}
198+
var inferDouble2 = 1 / 3 / 3.0
198199
let d2: Double = 3.14159
199200
inferDouble2 = d2
200201

test/Constraints/closures.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func r22162441(_ lines: [String]) {
9494
func testMap() {
9595
let a = 42
9696
[1,a].map { $0 + 1.0 } // expected-error {{binary operator '+' cannot be applied to operands of type 'Int' and 'Double'}}
97-
// expected-note @-1 {{overloads for '+' exist with these partially matching parameter lists: (Int, Int), (Double, Double), (Int, UnsafeMutablePointer<Pointee>), (Int, UnsafePointer<Pointee>)}}
97+
// expected-note @-1 {{overloads for '+' exist with these partially matching parameter lists: }}
9898
}
9999

100100
// <rdar://problem/22414757> "UnresolvedDot" "in wrong phase" assertion from verifier

test/Constraints/diagnostics.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func perform<T>() {} // expected-error {{generic parameter 'T' is not used in f
179179
// <rdar://problem/17080659> Error Message QOI - wrong return type in an overload
180180
func recArea(_ h: Int, w : Int) {
181181
return h * w // expected-error {{no '*' candidates produce the expected contextual result type '()'}}
182-
// expected-note @-1 {{overloads for '*' exist with these result types: UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64, Int64, UInt, Int, Float, Double}}
182+
// expected-note @-1 {{overloads for '*' exist with these result types: }}
183183
}
184184

185185
// <rdar://problem/17224804> QoI: Error In Ternary Condition is Wrong
@@ -457,8 +457,8 @@ func someGeneric19997471<T>(_ x: T) {
457457
func f20371273() {
458458
let x: [Int] = [1, 2, 3, 4]
459459
let y: UInt = 4
460-
x.filter { $0 == y } // expected-error {{binary operator '==' cannot be applied to operands of type 'Int' and 'UInt'}}
461-
// expected-note @-1 {{overloads for '==' exist with these partially matching parameter lists: (UInt, UInt), (Int, Int)}}
460+
_ = x.filter { $0 == y } // expected-error {{binary operator '==' cannot be applied to operands of type 'Int' and 'UInt'}}
461+
// expected-note @-1 {{overloads for '==' exist with these partially matching parameter lists:}}
462462
}
463463

464464

@@ -542,7 +542,7 @@ func testTypeSugar(_ a : Int) {
542542
// <rdar://problem/21974772> SegFault in FailureDiagnosis::visitInOutExpr
543543
func r21974772(_ y : Int) {
544544
let x = &(1.0 + y) // expected-error {{binary operator '+' cannot be applied to operands of type 'Double' and 'Int'}}
545-
//expected-note @-1 {{overloads for '+' exist with these partially matching parameter lists: (Int, Int), (Double, Double), (UnsafeMutablePointer<Pointee>, Int), (UnsafePointer<Pointee>, Int)}}
545+
//expected-note @-1 {{overloads for '+' exist with these partially matching parameter lists: }}
546546
}
547547

548548
// <rdar://problem/22020088> QoI: missing member diagnostic on optional gives worse error message than existential/bound generic/etc
@@ -752,8 +752,8 @@ if AssocTest.one(1) == AssocTest.one(1) {} // expected-error{{binary operator '=
752752
func r24251022() {
753753
var a = 1
754754
var b: UInt32 = 2
755-
a += a + // expected-error {{binary operator '+' cannot be applied to operands of type 'Int' and 'UInt32'}} expected-note {{expected an argument list of type '(Int, Int)'}}
756-
b
755+
a += a +
756+
b // expected-error {{cannot convert value of type 'UInt32' to expected argument type 'Int'}}
757757
}
758758

759759
func overloadSetResultType(_ a : Int, b : Int) -> Int {
@@ -763,10 +763,13 @@ func overloadSetResultType(_ a : Int, b : Int) -> Int {
763763
// expected-note @-1 {{expected an argument list of type '(Bool, @autoclosure () throws -> Bool)'}}
764764
}
765765

766+
postfix operator +++
767+
postfix func +++ <T>(_: inout T) -> T { fatalError() }
768+
766769
// <rdar://problem/21523291> compiler error message for mutating immutable field is incorrect
767770
func r21523291(_ bytes : UnsafeMutablePointer<UInt8>) {
768771
let i = 42 // expected-note {{change 'let' to 'var' to make it mutable}}
769-
let r = bytes[i++] // expected-error {{cannot pass immutable value as inout argument: 'i' is a 'let' constant}}
772+
_ = bytes[i+++] // expected-error {{cannot pass immutable value as inout argument: 'i' is a 'let' constant}}
770773
}
771774

772775

test/Constraints/generics.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class MyArrayBuffer<Element>: r22409190ManagedBuffer<UInt, Element> {
169169
// <rdar://problem/22459135> error: 'print' is unavailable: Please wrap your tuple argument in parentheses: 'print((...))'
170170
func r22459135() {
171171
func h<S : Sequence>(_ sequence: S) -> S.Iterator.Element
172-
where S.Iterator.Element : Integer {
172+
where S.Iterator.Element : FixedWidthInteger {
173173
return 0
174174
}
175175

@@ -205,7 +205,7 @@ var _ : Int = R24267414.foo() // expected-error {{generic parameter 'T' could no
205205

206206

207207
// https://bugs.swift.org/browse/SR-599
208-
func SR599<T: Integer>() -> T.Type { return T.self } // expected-note {{in call to function 'SR599'}}
208+
func SR599<T: FixedWidthInteger>() -> T.Type { return T.self } // expected-note {{in call to function 'SR599'}}
209209
_ = SR599() // expected-error {{generic parameter 'T' could not be inferred}}
210210

211211

@@ -225,7 +225,7 @@ func test9215114<T: P19215114, U: Q19215114>(_ t: T) -> (U) -> () {
225225
}
226226

227227
// <rdar://problem/21718970> QoI: [uninferred generic param] cannot invoke 'foo' with an argument list of type '(Int)'
228-
class Whatever<A: IntegerArithmetic, B: IntegerArithmetic> { // expected-note 2 {{'A' declared as parameter to type 'Whatever'}}
228+
class Whatever<A: Arithmetic, B: Arithmetic> { // expected-note 2 {{'A' declared as parameter to type 'Whatever'}}
229229
static func foo(a: B) {}
230230

231231
static func bar() {}

test/Constraints/lvalues.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ var y : Y
2929

3030
func +=(lhs: inout X, rhs : X) {}
3131
func +=(lhs: inout Double, rhs : Double) {}
32-
prefix func ++(rhs: inout X) {}
33-
postfix func ++(lhs: inout X) {}
32+
prefix operator +++
33+
prefix func +++(rhs: inout X) {}
3434

3535
f0(&i)
3636
f1(&i)
@@ -44,7 +44,7 @@ f1(y[i]) // expected-error{{passing value of type 'Float' to an inout parameter
4444

4545
// Assignment operators
4646
x += x
47-
++x
47+
+++x
4848

4949
var yi = y[i]
5050

@@ -77,28 +77,28 @@ f2(&non_settable_x) // expected-error{{cannot pass immutable value as inout argu
7777
f1(&non_settable_x) // expected-error{{cannot pass immutable value as inout argument: 'non_settable_x' is a get-only property}}
7878
// - inout assignment
7979
non_settable_x += x // expected-error{{left side of mutating operator isn't mutable: 'non_settable_x' is a get-only property}}
80-
++non_settable_x // expected-error{{cannot pass immutable value as inout argument: 'non_settable_x' is a get-only property}}
80+
+++non_settable_x // expected-error{{cannot pass immutable value as inout argument: 'non_settable_x' is a get-only property}}
8181

8282
// non-settable property is non-settable:
8383
z.non_settable_x = x // expected-error{{cannot assign to property: 'non_settable_x' is a get-only property}}
8484
f2(&z.non_settable_x) // expected-error{{cannot pass immutable value as inout argument: 'non_settable_x' is a get-only property}}
8585
f1(&z.non_settable_x) // expected-error{{cannot pass immutable value as inout argument: 'non_settable_x' is a get-only property}}
8686
z.non_settable_x += x // expected-error{{left side of mutating operator isn't mutable: 'non_settable_x' is a get-only property}}
87-
++z.non_settable_x // expected-error{{cannot pass immutable value as inout argument: 'non_settable_x' is a get-only property}}
87+
+++z.non_settable_x // expected-error{{cannot pass immutable value as inout argument: 'non_settable_x' is a get-only property}}
8888

8989
// non-settable subscript is non-settable:
9090
z[0] = 0.0 // expected-error{{cannot assign through subscript: subscript is get-only}}
9191
f2(&z[0]) // expected-error{{cannot pass immutable value as inout argument: subscript is get-only}}
9292
f1(&z[0]) // expected-error{{cannot pass immutable value as inout argument: subscript is get-only}}
9393
z[0] += 0.0 // expected-error{{left side of mutating operator isn't mutable: subscript is get-only}}
94-
++z[0] // expected-error{{cannot pass immutable value as inout argument: subscript is get-only}}
94+
+++z[0] // expected-error{{cannot pass immutable value as inout argument: subscript is get-only}}
9595

9696
// settable property of an rvalue value type is non-settable:
9797
fz().settable_x = x // expected-error{{cannot assign to property: 'fz' returns immutable value}}
9898
f2(&fz().settable_x) // expected-error{{cannot pass immutable value as inout argument: 'fz' returns immutable value}}
9999
f1(&fz().settable_x) // expected-error{{cannot pass immutable value as inout argument: 'fz' returns immutable value}}
100100
fz().settable_x += x // expected-error{{left side of mutating operator isn't mutable: 'fz' returns immutable value}}
101-
++fz().settable_x // expected-error{{cannot pass immutable value as inout argument: 'fz' returns immutable value}}
101+
+++fz().settable_x // expected-error{{cannot pass immutable value as inout argument: 'fz' returns immutable value}}
102102

103103
// settable property of an rvalue reference type IS SETTABLE:
104104
fref().property = 0.0
@@ -112,7 +112,7 @@ z.non_settable_x.property = 1.0 // expected-error{{cannot assign to property: 'n
112112
f2(&z.non_settable_x.property) // expected-error{{cannot pass immutable value as inout argument: 'non_settable_x' is a get-only property}}
113113
f1(&z.non_settable_x.property) // expected-error{{cannot pass immutable value as inout argument: 'non_settable_x' is a get-only property}}
114114
z.non_settable_x.property += 1.0 // expected-error{{left side of mutating operator isn't mutable: 'non_settable_x' is a get-only property}}
115-
++z.non_settable_x.property // expected-error{{cannot pass immutable value as inout argument: 'non_settable_x' is a get-only property}}
115+
+++z.non_settable_x.property // expected-error{{cannot pass immutable value as inout argument: 'non_settable_x' is a get-only property}}
116116

117117
// settable property of a non-settable reference type IS SETTABLE:
118118
z.non_settable_reftype.property = 1.0

0 commit comments

Comments
 (0)