[test] Adding regression tests for SR-15053

This commit is contained in:
LucianoAlmeida
2021-10-11 21:48:28 -03:00
parent 6e072ba816
commit ada9bfb7bc
2 changed files with 11 additions and 1 deletions

View File

@@ -68,3 +68,13 @@ class MoviesViewController {
_ = itemType // expected-error {{ambiguous use of 'itemType'}}
}
}
// SR-15053
func SR15053<T : Numeric>(_ a: T, _ b: T) -> T {
(a + b) / 2 // expected-error{{cannot convert return expression of type 'Int' to return type 'T'}}
// expected-error@-1{{cannot convert value of type 'T' to expected argument type 'Int'}}
}
func SR15053<T : Numeric>(_ a: T, _ b: T) {
(a + b) / 2 // expected-error{{cannot convert value of type 'T' to expected argument type 'Int'}}
}

View File

@@ -6,6 +6,6 @@ import Foundation
struct S {
init<T: NSNumber>(_ num: T) { // expected-note {{where 'T' = 'Bool'}}
self.init(num != 0) // expected-error {{initializer 'init(_:)' requires that 'Bool' inherit from 'NSNumber'}}
// expected-error@-1 {{referencing operator function '!=' on 'BinaryInteger' requires that 'T' conform to 'BinaryInteger'}}
// expected-error@-1 {{cannot convert value of type 'T' to expected argument type 'Int'}}
}
}