Skip to content

Commit ada9bfb

Browse files
[test] Adding regression tests for SR-15053
1 parent 6e072ba commit ada9bfb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

test/Constraints/diag_ambiguities.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,13 @@ class MoviesViewController {
6868
_ = itemType // expected-error {{ambiguous use of 'itemType'}}
6969
}
7070
}
71+
72+
// SR-15053
73+
func SR15053<T : Numeric>(_ a: T, _ b: T) -> T {
74+
(a + b) / 2 // expected-error{{cannot convert return expression of type 'Int' to return type 'T'}}
75+
// expected-error@-1{{cannot convert value of type 'T' to expected argument type 'Int'}}
76+
}
77+
78+
func SR15053<T : Numeric>(_ a: T, _ b: T) {
79+
(a + b) / 2 // expected-error{{cannot convert value of type 'T' to expected argument type 'Int'}}
80+
}

test/Constraints/rdar40002266.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import Foundation
66
struct S {
77
init<T: NSNumber>(_ num: T) { // expected-note {{where 'T' = 'Bool'}}
88
self.init(num != 0) // expected-error {{initializer 'init(_:)' requires that 'Bool' inherit from 'NSNumber'}}
9-
// expected-error@-1 {{referencing operator function '!=' on 'BinaryInteger' requires that 'T' conform to 'BinaryInteger'}}
9+
// expected-error@-1 {{cannot convert value of type 'T' to expected argument type 'Int'}}
1010
}
1111
}

0 commit comments

Comments
 (0)