[Diagnostics] NFC: Update all of the improved test-cases

This commit is contained in:
Pavel Yaskevich
2019-09-06 12:07:18 -07:00
parent caa3569f27
commit a1643d94f7
40 changed files with 112 additions and 129 deletions

View File

@@ -61,7 +61,9 @@ func test9() {
let constFridge: CCRefrigerator = fridge
CCRefrigeratorOpen(fridge)
let item = CCRefrigeratorGet(fridge, 0).takeUnretainedValue()
// TODO(diagnostics): In this case we should probably suggest to flip `item` and `fridge`
CCRefrigeratorInsert(item, fridge) // expected-error {{cannot convert value of type 'CCItem' to expected argument type 'CCMutableRefrigerator?'}}
// expected-error@-1 {{cannot convert value of type 'CCMutableRefrigerator' to expected argument type 'CCItem?'}}
CCRefrigeratorInsert(constFridge, item) // expected-error {{cannot convert value of type 'CCRefrigerator' to expected argument type 'CCMutableRefrigerator?'}}
CCRefrigeratorInsert(fridge, item)
CCRefrigeratorClose(fridge)
@@ -117,6 +119,7 @@ func testOutParametersBad() {
let power: CCPowerSupply?
CCRefrigeratorGetPowerSupplyIndirect(0, power) // expected-error {{cannot convert value of type 'Int' to expected argument type 'CCRefrigerator?'}}
// expected-error@-1 {{cannot convert value of type 'CCPowerSupply?' to expected argument type 'AutoreleasingUnsafeMutablePointer<CCPowerSupply?>'}}
let item: CCItem?
CCRefrigeratorGetItemUnaudited(0, 0, item) // expected-error {{cannot convert value of type 'Int' to expected argument type 'CCRefrigerator?'}}

View File

@@ -17,6 +17,7 @@ func test_cfunc2(_ i: Int) {
#endif
_ = f as Float
cfunc2(b:17, a:i) // expected-error{{extraneous argument labels 'b:a:' in call}}
// expected-error@-1 {{cannot convert value of type 'Int' to expected argument type 'Int32'}}
cfunc2(17, i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'Int32'}}
}

View File

@@ -121,6 +121,7 @@ func checkInitWithCoder(_ coder: NSCoder) {
MyViewController(coder: coder) // expected-warning{{unused}}
MyTableViewController(coder: coder) // expected-warning{{unused}}
MyOtherTableViewController(coder: coder) // expected-error{{incorrect argument label in call (have 'coder:', expected 'int:')}}
// expected-error@-1 {{cannot convert value of type 'NSCoder' to expected argument type 'Int'}}
MyThirdTableViewController(coder: coder) // expected-warning{{unused}}
}

View File

@@ -50,7 +50,7 @@ useDoubleList([1.0,2,3])
useDoubleList([1.0,2.0,3.0])
useIntDict(["Niners" => 31, "Ravens" => 34])
useIntDict(["Niners" => 31, "Ravens" => 34.0]) // expected-error{{cannot convert value of type '(String, Double)' to expected element type '(String, Int)'}}
useIntDict(["Niners" => 31, "Ravens" => 34.0]) // expected-error{{cannot convert value of type 'Double' to expected argument type 'Int'}}
// <rdar://problem/22333090> QoI: Propagate contextual information in a call to operands
useDoubleDict(["Niners" => 31, "Ravens" => 34.0])
useDoubleDict(["Niners" => 31.0, "Ravens" => 34])

View File

@@ -180,11 +180,7 @@ func dictionaryToNSDictionary() {
// In this case, we should not implicitly convert Dictionary to NSDictionary.
struct NotEquatable {}
func notEquatableError(_ d: Dictionary<Int, NotEquatable>) -> Bool {
// FIXME: Another awful diagnostic.
return d == d // expected-error{{'<Self where Self : Equatable> (Self.Type) -> (Self, Self) -> Bool' requires that 'NotEquatable' conform to 'Equatable'}}
// expected-note @-1 {{requirement from conditional conformance of 'Dictionary<Int, NotEquatable>' to 'Equatable'}}
// expected-error @-2 {{type 'NotEquatable' does not conform to protocol 'Equatable'}}
// expected-note @-3{{requirement specified as 'NotEquatable' : 'Equatable'}}
return d == d // expected-error{{operator function '==' requires that 'NotEquatable' conform to 'Equatable'}}
}
// NSString -> String
@@ -265,14 +261,13 @@ func rdar19831919() {
// <rdar://problem/19831698> Incorrect 'as' fixits offered for invalid literal expressions
func rdar19831698() {
var v70 = true + 1 // expected-error{{binary operator '+' cannot be applied to operands of type 'Bool' and 'Int'}} expected-note {{expected an argument list of type '(Int, Int)'}}
var v70 = true + 1 // expected-error{{cannot convert value of type 'Bool' to expected argument type 'Int'}}
var v71 = true + 1.0 // expected-error{{binary operator '+' cannot be applied to operands of type 'Bool' and 'Double'}}
// expected-note@-1{{overloads for '+'}}
var v72 = true + true // expected-error{{binary operator '+' cannot be applied to two 'Bool' operands}}
// expected-note @-1 {{overloads for '+' exist with these partially matching parameter lists:}}
var v73 = true + [] // expected-error{{binary operator '+' cannot be applied to operands of type 'Bool' and '[Any]'}}
// expected-note @-1 {{overloads for '+' exist with these partially matching parameter lists: (Array<Element>, Array<Element>), (Other, Self), (Self, Other)}}
var v75 = true + "str" // expected-error {{binary operator '+' cannot be applied to operands of type 'Bool' and 'String'}} expected-note {{expected an argument list of type '(String, String)'}}
var v73 = true + [] // expected-error{{cannot convert value of type 'Bool' to expected argument type 'Array<Any>'}}
var v75 = true + "str" // expected-error {{cannot convert value of type 'Bool' to expected argument type 'String'}}
}
// <rdar://problem/19836341> Incorrect fixit for NSString? to String? conversions

View File

@@ -349,13 +349,12 @@ takeVoidVoidFn { () -> Void in
}
// <rdar://problem/19997471> Swift: Incorrect compile error when calling a function inside a closure
func f19997471(_ x: String) {}
func f19997471(_ x: Int) {}
func f19997471(_ x: String) {} // expected-note {{candidate expects value of type 'String' at psoition #0}}
func f19997471(_ x: Int) {} // expected-note {{candidate expects value of type 'Int' at psoition #0}}
func someGeneric19997471<T>(_ x: T) {
takeVoidVoidFn {
f19997471(x) // expected-error {{cannot invoke 'f19997471' with an argument list of type '(T)'}}
// expected-note @-1 {{overloads for 'f19997471' exist with these partially matching parameter lists: (Int), (String)}}
f19997471(x) // expected-error {{no exact matches in call to global function 'f19997471'}}
}
}
@@ -584,8 +583,7 @@ let u = rdar33296619().element //expected-error {{use of unresolved identifier '
[1].forEach { _ in
_ = "\(u)"
_ = 1 + "hi" // expected-error {{binary operator '+' cannot be applied to operands of type 'Int' and 'String'}}
// expected-note@-1 {{overloads for '+' exist with these partially matching parameter lists}}
_ = 1 + "hi" // expected-error {{no exact matches in call to operator function '+'}}
}
class SR5666 {
@@ -745,7 +743,7 @@ takesTwoInOut { _ in } // expected-error {{contextual closure type '(Int, inout
func f20371273() {
let x: [Int] = [1, 2, 3, 4]
let y: UInt = 4
_ = x.filter { ($0 + y) > 42 } // expected-error {{binary operator '+' cannot be applied to operands of type 'Int' and 'UInt'}} expected-note {{overloads for '+' exist with these partially matching parameter lists: (Int, Int), (UInt, UInt)}}
_ = x.filter { ($0 + y) > 42 } // expected-error {{cannot convert value of type 'UInt' to expected argument type 'Int'}}
}
// rdar://problem/42337247

View File

@@ -16,7 +16,9 @@ enum Z {
init() { self = .none }
init(_ c: UnicodeScalar) { self = .char(c) }
// expected-note@-1 2 {{candidate expects value of type 'UnicodeScalar' (aka 'Unicode.Scalar') at psoition #0}}
init(_ s: String) { self = .string(s) }
// expected-note@-1 2 {{candidate expects value of type 'String' at psoition #0}}
init(_ x: Int, _ y: Int) { self = .point(x, y) }
}
@@ -93,11 +95,9 @@ _ = b as! Derived
// are special cased in the library.
Int(i) // expected-warning{{unused}}
_ = i as Int
Z(z) // expected-error{{cannot invoke initializer for type 'Z' with an argument list of type '(Z)'}}
// expected-note @-1 {{overloads for 'Z' exist with these partially matching parameter lists: (String), (UnicodeScalar)}}
Z(z) // expected-error{{no exact matches in call to initializer}}
Z.init(z) // expected-error {{cannot invoke 'Z.Type.init' with an argument list of type '(Z)'}}
// expected-note @-1 {{overloads for 'Z.Type.init' exist with these partially matching parameter lists: (String), (UnicodeScalar)}}
Z.init(z) // expected-error {{no exact matches in call to initializer}}
_ = z as Z

View File

@@ -161,10 +161,7 @@ class r22409190ManagedBuffer<Value, Element> {
class MyArrayBuffer<Element>: r22409190ManagedBuffer<UInt, Element> {
deinit {
self.withUnsafeMutablePointerToElements { elems -> Void in
// FIXME(diagnostics): Diagnostic regressed here from `cannot convert value of type 'UInt' to expected argument type 'Int'`.
// Once argument-to-parameter mismatch diagnostics are moved to the new diagnostic framework, we'll be able to restore
// original contextual conversion failure diagnostic here. Note that this only happens in Swift 4 mode.
elems.deinitialize(count: self.value) // expected-error {{ambiguous reference to member 'deinitialize(count:)'}}
elems.deinitialize(count: self.value) // expected-error {{cannot convert value of type 'UInt' to expected argument type 'Int'}}
}
}
}

View File

@@ -602,8 +602,10 @@ func rdar50679161() {
var _ = Q(
a: v + foo.w,
// expected-error@-1 {{instance member 'w' cannot be used on type 'S'}}
// expected-error@-2 {{cannot convert value of type 'Point' to expected argument type 'Int'}}
b: v + foo.h
// expected-error@-1 {{instance member 'h' cannot be used on type 'S'}}
// expected-error@-2 {{cannot convert value of type 'Point' to expected argument type 'Int'}}
)
}
}

View File

@@ -217,7 +217,7 @@ struct SR_3248 {
SR_3248().callback?("test") // expected-error {{cannot convert value of type 'String' to expected argument type '[AnyObject]'}}
SR_3248().callback!("test") // expected-error {{cannot convert value of type 'String' to expected argument type '[AnyObject]'}}
SR_3248().callback("test") // expected-error {{cannot invoke 'callback' with an argument list of type '(String)'}}
SR_3248().callback("test") // expected-error {{cannot convert value of type 'String' to expected argument type '[AnyObject]'}}
_? = nil // expected-error {{'nil' requires a contextual type}}
_?? = nil // expected-error {{'nil' requires a contextual type}}

View File

@@ -3,7 +3,9 @@
func markUsed<T>(_ t: T) {}
func f0(_: Float) -> Float {}
// expected-note@-1 {{candidate expects value of type 'Float' at psoition #0}}
func f0(_: Int) -> Int {}
// expected-note@-1 {{candidate expects value of type 'Int' at psoition #0}}
func f1(_: Int) {}
@@ -24,8 +26,7 @@ _ = f0(1)
f1(f0(1))
f1(identity(1))
f0(x) // expected-error{{cannot invoke 'f0' with an argument list of type '(X)'}}
// expected-note @-1 {{overloads for 'f0' exist with these partially matching parameter lists: (Float), (Int)}}
f0(x) // expected-error{{no exact matches in call to global function 'f0'}}
_ = f + 1
_ = f2(i)

View File

@@ -143,7 +143,7 @@ class C_r25601561 {
// rdar://problem/31977679 - Misleading diagnostics when using subscript with incorrect argument
func r31977679_1(_ properties: [String: String]) -> Any? {
return properties[0] // expected-error {{cannot subscript a value of type '[String : String]' with an argument of type 'Int'}}
return properties[0] // expected-error {{cannot convert value of type 'Int' to expected argument type 'String'}}
}
func r31977679_2(_ properties: [String: String]) -> Any? {

View File

@@ -15,6 +15,7 @@ do {
concreteLabeled(x: 3)
concreteLabeled(x: (3))
concreteLabeled((x: 3)) // expected-error {{missing argument label 'x:' in call}}
// expected-error@-1 {{cannot convert value of type '(x: Int)' to expected argument type 'Int'}}
concreteTwo(3, 4)
concreteTwo((3, 4)) // expected-error {{missing argument for parameter #2 in call}}

View File

@@ -11,13 +11,7 @@ protocol P6: P2 {}
protocol Assoc { associatedtype AT }
func takes_P2<X: P2>(_: X) {}
// expected-note@-1 {{candidate requires that the types 'U' and 'V' be equivalent (requirement specified as 'U' == 'V')}}
// expected-note@-2 {{requirement from conditional conformance of 'SameTypeGeneric<U, V>' to 'P2'}}
// expected-note@-3 {{requirement from conditional conformance of 'SubclassBad' to 'P2'}}
// expected-note@-4 {{candidate requires that 'C1' inherit from 'U' (requirement specified as 'U' : 'C1')}}
// expected-note@-5 {{requirement from conditional conformance of 'ClassFree<U>' to 'P2'}}
// expected-note@-6 {{candidate requires that 'C1' inherit from 'Int' (requirement specified as 'Int' : 'C1')}}
func takes_P2<X: P2>(_: X) {} // expected-note {{in call to function 'takes_P2'}}
func takes_P5<X: P5>(_: X) {}
// Skip the first generic signature declcontext dump
@@ -102,7 +96,7 @@ func same_type_generic_good<U, V>(_: U, _: V)
}
func same_type_bad<U, V>(_: U, _: V) {
takes_P2(SameTypeGeneric<U, V>())
// expected-error@-1{{cannot invoke 'takes_P2(_:)' with an argument list of type '(SameTypeGeneric<U, V>)'}}
// expected-error@-1{{generic parameter 'X' could not be inferred}}
takes_P2(SameTypeGeneric<U, Int>())
// expected-error@-1{{global function 'takes_P2' requires the types 'U' and 'Int' be equivalent}}
takes_P2(SameTypeGeneric<Int, Float>())
@@ -152,13 +146,13 @@ struct ClassFree<T> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=ClassFree
// CHECK-NEXT: (normal_conformance type=ClassFree<T> protocol=P2
// CHECK-NEXT: superclass: T C1)
extension ClassFree: P2 where T: C1 {}
extension ClassFree: P2 where T: C1 {} // expected-note {{requirement from conditional conformance of 'ClassFree<U>' to 'P2'}}
func class_free_good<U: C1>(_: U) {
takes_P2(ClassFree<U>())
}
func class_free_bad<U>(_: U) {
takes_P2(ClassFree<U>())
// expected-error@-1{{cannot invoke 'takes_P2(_:)' with an argument list of type '(ClassFree<U>)'}}
// expected-error@-1{{global function 'takes_P2' requires that 'U' inherit from 'C1'}}
}
struct ClassMoreSpecific<T: C1> {}
@@ -189,10 +183,10 @@ class SubclassGood: Base<C1> {}
func subclass_good() {
takes_P2(SubclassGood())
}
class SubclassBad: Base<Int> {}
class SubclassBad: Base<Int> {} // expected-note {{requirement from conditional conformance of 'SubclassBad' to 'P2'}}
func subclass_bad() {
takes_P2(SubclassBad())
// expected-error@-1{{cannot invoke 'takes_P2(_:)' with an argument list of type '(SubclassBad)'}}
// expected-error@-1{{global function 'takes_P2' requires that 'Int' inherit from 'C1'}}
}
// Inheriting conformances:

View File

@@ -22,7 +22,7 @@ func useIdentity(_ x: Int, y: Float, i32: Int32) {
// Deduction where the result type and input type can get different results
var xx : X, yy : Y
xx = identity(yy) // expected-error{{cannot assign value of type 'Y' to type 'X'}}
xx = identity(yy) // expected-error{{cannot convert value of type 'Y' to expected argument type 'X'}}
xx = identity2(yy) // expected-error{{cannot convert value of type 'Y' to expected argument type 'X'}}
}
@@ -234,9 +234,9 @@ class C_GI : P_GI {
class GI_Diff {}
func genericInheritsA<T>(_ x: T) where T : P_GI, T.Y : GI_Diff {}
// expected-note@-1 {{candidate requires that 'GI_Diff' inherit from 'T.Y' (requirement specified as 'T.Y' : 'GI_Diff' [with T = C_GI])}}
// expected-note@-1 {{where 'T.Y' = 'C_GI.Y' (aka 'Double')}}
genericInheritsA(C_GI())
// expected-error@-1 {{cannot invoke 'genericInheritsA(_:)' with an argument list of type '(C_GI)'}}
// expected-error@-1 {{global function 'genericInheritsA' requires that 'C_GI.Y' (aka 'Double') inherit from 'GI_Diff'}}
//===----------------------------------------------------------------------===//
// Deduction for member operators
@@ -255,7 +255,7 @@ func addAddables<T : Addable, U>(_ x: T, y: T, u: U) -> T {
//===----------------------------------------------------------------------===//
struct MyVector<T> { func size() -> Int {} }
func getVectorSize<T>(_ v: MyVector<T>) -> Int {
func getVectorSize<T>(_ v: MyVector<T>) -> Int { // expected-note {{in call to function 'getVectorSize'}}
return v.size()
}
@@ -267,7 +267,8 @@ func testGetVectorSize(_ vi: MyVector<Int>, vf: MyVector<Float>) {
i = getVectorSize(vi)
i = getVectorSize(vf)
getVectorSize(i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'MyVector<T>'}}
getVectorSize(i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'MyVector<Any>'}}
// expected-error@-1 {{generic parameter 'T' could not be inferred}}
var x : X, y : Y
x = ovlVector(vi)
@@ -323,22 +324,21 @@ func foo() {
infix operator +&
func +&<R, S>(lhs: inout R, rhs: S) where R : RangeReplaceableCollection, S : Sequence, R.Element == S.Element {}
// expected-note@-1 {{candidate requires that the types 'String' and 'String.Element' (aka 'Character') be equivalent (requirement specified as 'R.Element' == 'S.Element' [with R = [String], S = String])}}
// expected-note@-1 {{where 'R.Element' = 'String', 'S.Element' = 'String.Element' (aka 'Character')}}
func rdar33477726_1() {
var arr: [String] = []
arr +& "hello"
// expected-error@-1 {{binary operator '+&(_:_:)' cannot be applied to operands of type '[String]' and 'String'}}
// expected-error@-1 {{operator function '+&' requires the types 'String' and 'String.Element' (aka 'Character') be equivalent}}
}
func rdar33477726_2<R, S>(_: R, _: S) where R: Sequence, S == R.Element {}
// expected-note@-1 {{candidate requires that the types 'Int' and 'String.Element' (aka 'Character') be equivalent (requirement specified as 'S' == 'R.Element' [with R = String, S = Int])}}
rdar33477726_2("answer", 42)
// expected-error@-1 {{cannot invoke 'rdar33477726_2(_:_:)' with an argument list of type '(String, Int)'}}
// expected-error@-1 {{cannot convert value of type 'Int' to expected argument type 'String.Element' (aka 'Character')}}
prefix operator +-
prefix func +-<T>(_: T) where T: Sequence, T.Element == Int {}
// expected-note@-1 {{candidate requires that the types 'String.Element' (aka 'Character') and 'Int' be equivalent (requirement specified as 'T.Element' == 'Int' [with T = String])}}
// expected-note@-1 {{where 'T.Element' = 'String.Element' (aka 'Character')}}
+-"hello"
// expected-error@-1 {{unary operator '+-(_:)' cannot be applied to an operand of type 'String'}}
// expected-error@-1 {{operator function '+-' requires the types 'String.Element' (aka 'Character') and 'Int' be equivalent}}

View File

@@ -17,7 +17,7 @@ func doCompare<T : EqualComparable, U : EqualComparable>(_ t1: T, t2: T, u: U) -
return true
}
return t1.isEqual(u) // expected-error {{cannot invoke 'isEqual' with an argument list of type '(U)'}} expected-note {{expected an argument list of type '(T)'}}
return t1.isEqual(u) // expected-error {{cannot convert value of type 'U' to expected argument type 'T'}}
}
protocol MethodLessComparable {
@@ -36,8 +36,7 @@ func min<T : MethodLessComparable>(_ x: T, y: T) -> T {
func existential<T : EqualComparable, U : EqualComparable>(_ t1: T, t2: T, u: U) {
var eqComp : EqualComparable = t1 // expected-error{{protocol 'EqualComparable' can only be used as a generic constraint}}
eqComp = u
if t1.isEqual(eqComp) {} // expected-error{{cannot invoke 'isEqual' with an argument list of type '(EqualComparable)'}}
// expected-note @-1 {{expected an argument list of type '(T)'}}
if t1.isEqual(eqComp) {} // expected-error{{cannot convert value of type 'EqualComparable' to expected argument type 'T'}}
if eqComp.isEqual(t2) {} // expected-error{{member 'isEqual' cannot be used on value of protocol type 'EqualComparable'; use a generic constraint instead}}
}
@@ -75,8 +74,8 @@ protocol Overload {
associatedtype B
func getA() -> A
func getB() -> B
func f1(_: A) -> A
func f1(_: B) -> B
func f1(_: A) -> A // expected-note {{candidate expects value of type 'OtherOvl.A' at psoition #0}}
func f1(_: B) -> B // expected-note {{candidate expects value of type 'OtherOvl.B' at psoition #0}}
func f2(_: Int) -> A // expected-note{{found this candidate}}
func f2(_: Int) -> B // expected-note{{found this candidate}}
func f3(_: Int) -> Int // expected-note {{found this candidate}}
@@ -106,9 +105,8 @@ func testOverload<Ovl : Overload, OtherOvl : Overload>(_ ovl: Ovl, ovl2: Ovl,
a = ovl2.f2(17)
a = ovl2.f1(a)
other.f1(a) // expected-error{{cannot invoke 'f1' with an argument list of type '(Ovl.A)'}}
// expected-note @-1 {{overloads for 'f1' exist with these partially matching parameter lists: (Self.A), (Self.B)}}
other.f1(a) // expected-error{{no exact matches in call to instance method 'f1'}}
// Overloading based on context
var f3i : (Int) -> Int = ovl.f3
var f3f : (Float) -> Float = ovl.f3
@@ -171,7 +169,7 @@ func staticEqCheck<T : StaticEq, U : StaticEq>(_ t: T, u: U) {
if T.isEqual(t, y: t) { return }
if U.isEqual(u, y: u) { return }
T.isEqual(t, y: u) // expected-error{{cannot invoke 'isEqual' with an argument list of type '(T, y: U)'}} expected-note {{expected an argument list of type '(T, y: T)'}}
T.isEqual(t, y: u) // expected-error{{cannot convert value of type 'U' to expected argument type 'T'}}
}
//===----------------------------------------------------------------------===//

View File

@@ -17,16 +17,16 @@ struct YourFoo: Foo {}
func someTypeIsTheSame() {
var a = foo(0)
a = foo(0)
a = foo("") // expected-error{{cannot assign}}
a = foo("") // expected-error{{cannot convert value of type 'String' to expected argument type 'Int'}}
var b = foo("")
b = foo(0) // expected-error{{cannot assign}}
b = foo(0) // expected-error{{cannot convert value of type 'Int' to expected argument type 'String'}}
b = foo("")
var c = foo(MyFoo())
c = foo(0) // expected-error{{cannot assign}}
c = foo(0) // expected-error{{cannot convert value of type 'Int' to expected argument type 'MyFoo'}}
c = foo(MyFoo())
c = foo(YourFoo()) // expected-error{{cannot assign}}
c = foo(YourFoo()) // expected-error{{cannot convert value of type 'YourFoo' to expected argument type 'MyFoo'}}
var barInt = Bar<Int>()
var barString = Bar<String>()
@@ -58,6 +58,6 @@ func someTypeIsTheSame() {
var f = barInt.foo(MyFoo())
f = barInt.foo(MyFoo())
f = barString.foo(MyFoo()) // expected-error{{cannot assign}}
f = barInt.foo(YourFoo()) // expected-error{{cannot assign}}
f = barInt.foo(YourFoo()) // expected-error{{cannot convert value of type 'YourFoo' to expected argument type 'MyFoo'}}
f = barString.foo(MyFoo()) // expected-error{{cannot assign}}
}

View File

@@ -1,7 +1,7 @@
// RUN: %target-swift-frontend -typecheck -enable-source-import -primary-file %s %S/Inputs/multi-file-with-main/main.swift -module-name=MultiFile -sdk "" -verify
func testOperator() {
let x: Int = 1 +++ "abc" // expected-error {{binary operator '+++' cannot be applied to operands of type 'Int' and 'String'}} expected-note {{expected an argument list of type '(Int, Int)'}}
let x: Int = 1 +++ "abc" // expected-error {{cannot convert value of type 'String' to expected argument type 'Int'}}
_ = x
}

View File

@@ -13,7 +13,7 @@ class ThisBase1 {
}
func baseFunc0() {}
func baseFunc1(_ a: Int) {} // expected-note 2 {{found this candidate}}
func baseFunc1(_ a: Int) {}
subscript(i: Int) -> Double {
get {
@@ -223,14 +223,11 @@ class ThisDerived1 : ThisBase1 {
self.baseInstanceVar = 42 // expected-error {{member 'baseInstanceVar' cannot be used on type 'ThisDerived1'}}
self.baseProp = 42 // expected-error {{member 'baseProp' cannot be used on type 'ThisDerived1'}}
self.baseFunc0() // expected-error {{instance member 'baseFunc0' cannot be used on type 'ThisDerived1'}}
self.baseFunc0(ThisBase1())() // expected-error {{'ThisBase1' is not convertible to 'ThisDerived1'}}
self.baseFunc0(ThisBase1())() // expected-error {{cannot convert value of type 'ThisBase1' to expected argument type 'ThisDerived1'}}
self.baseFunc0(ThisDerived1())()
self.baseFunc1(42) // expected-error {{instance member 'baseFunc1' cannot be used on type 'ThisDerived1'}}
// TODO(diagnostics): Constraint system is not currently set up to handle this case because overload choice
// would have a type of `(A) -> (Int) -> Void` which then gets fixed up to be `(B) -> (Int) -> Void` when
// the choice is attempted.
self.baseFunc1(ThisBase1())(42) // expected-error {{ambiguous reference to member 'baseFunc1'}}
self.baseFunc1(ThisBase1())(42) // expected-error {{cannot convert value of type 'ThisBase1' to expected argument type 'ThisDerived1'}}
self.baseFunc1(ThisDerived1())(42)
self[0] = 42.0 // expected-error {{instance member 'subscript' cannot be used on type 'ThisDerived1'}}
self.baseStaticVar = 42

View File

@@ -1005,7 +1005,7 @@ var fvs_stubMyOwnFatalError: () {
var fvs_forceTryExplicit: String {
get { "ok" }
set {
return try! failableIdentity("shucks") // expected-error {{unexpected non-void return value in void function}}
return try! failableIdentity("shucks") // expected-error {{cannot convert value of type 'String' to expected argument type '()'}}
}
}

View File

@@ -307,11 +307,7 @@ struct NotEquatable {}
func arrayComparison(_ x: [NotEquatable], y: [NotEquatable], p: UnsafeMutablePointer<NotEquatable>) {
var x = x
// Don't allow implicit array-to-pointer conversions in operators.
let a: Bool = x == y // expected-error{{'<Self where Self : Equatable> (Self.Type) -> (Self, Self) -> Bool' requires that 'NotEquatable' conform to 'Equatable'}}
// expected-error @-1 {{type 'NotEquatable' does not conform to protocol 'Equatable'}}
// expected-note @-2 {{requirement from conditional conformance of '[NotEquatable]' to 'Equatable'}}
// expected-note @-3 {{requirement specified as 'NotEquatable' : 'Equatable'}}
let a: Bool = x == y // expected-error{{operator function '==' requires that 'NotEquatable' conform to 'Equatable'}}
let _: Bool = p == &x // Allowed!
}

View File

@@ -248,7 +248,7 @@ func testFunctionCollectionTypes() {
_ = (Int) -> Int // expected-error {{expected member name or constructor call after type name}} expected-note{{use '.self' to reference the type object}}
_ = @convention(c) () -> Int // expected-error{{expected member name or constructor call after type name}} expected-note{{use '.self' to reference the type object}}
_ = 1 + (@convention(c) () -> Int).self // expected-error{{binary operator '+' cannot be applied to operands of type 'Int' and '(@convention(c) () -> Int).Type'}} // expected-note {{expected an argument list of type '(Int, Int)'}}
_ = 1 + (@convention(c) () -> Int).self // expected-error{{cannot convert value of type '(@convention(c) () -> Int).Type' to expected argument type 'Int'}}
_ = (@autoclosure () -> Int) -> (Int, Int).2 // expected-error {{expected type after '->'}}
_ = ((@autoclosure () -> Int) -> (Int, Int)).1 // expected-error {{type '(@autoclosure () -> Int) -> (Int, Int)' has no member '1'}}
_ = ((inout Int) -> Void).self

View File

@@ -105,8 +105,7 @@ enum Complex {
}
func complex() {
if Complex.A(1) == .B { } // expected-error{{binary operator '==' cannot be applied to operands of type 'Complex' and '_'}}
// expected-note @-1 {{overloads for '==' exist with these partially matching parameter lists: }}
if Complex.A(1) == .B { } // expected-error{{cannot convert value of type 'Complex' to expected argument type 'CustomHashable'}}
}
// Enums with equatable payloads are equatable if they explicitly conform.

View File

@@ -71,7 +71,7 @@ func test_mixed_overload(_ a: A, x: X, y: Y) {
x1 = x
var y1 = a.mixed(y: y) // expected-error {{static member 'mixed' cannot be used on instance of type 'A'}} {{12-12=A.}}
A.mixed(x) // expected-error{{missing argument label 'y:' in call}}
A.mixed(x) // expected-error{{cannot convert value of type 'X' to expected argument type 'A'}}
var x2 = A.mixed(a)(x: x)
x2 = x
var y2 = A.mixed(y: y)
@@ -157,7 +157,7 @@ extension A {
}
class func test_mixed_overload_static(a: A, x: X, y: Y) {
mixed(x) // expected-error{{missing argument label 'y:' in call}}
mixed(x) // expected-error{{cannot convert value of type 'X' to expected argument type 'A'}}
var x2 = mixed(a)(x: x)
x2 = x
var y2 = mixed(y: y)

View File

@@ -600,8 +600,9 @@ func keypath_with_subscripts(_ arr: SubscriptLens<[Int]>,
func keypath_with_incorrect_return_type(_ arr: Lens<Array<Int>>) {
for idx in 0..<arr.count {
// expected-error@-1 {{binary operator '..<' cannot be applied to operands of type 'Int' and 'Lens<Int>'}}
// expected-note@-2 {{expected an argument list of type '(Self, Self)'}}
// expected-error@-1 {{operator function '..<' requires that 'Lens<Int>' conform to 'Strideable'}}
// expected-error@-2 {{operator function '..<' requires that 'Lens<Int>.Stride' conform to 'SignedInteger'}}
// expected-error@-3 {{cannot convert value of type 'Int' to expected argument type 'Lens<Int>'}}
let _ = arr[idx]
}
}

View File

@@ -52,7 +52,9 @@ struct SomeStruct {
init() {
self.init()
self.width = Measurement.self.init(val: width) // expected-error {{cannot convert value of type 'Measurement' to expected argument type 'Int'}}
// expected-error@-1 {{'let' property 'width' may not be initialized directly; use "self.init(...)" or "self = ..." instead}}
self.height = Measurement.self.init(val: height) // expected-error {{cannot convert value of type 'Measurement' to expected argument type 'Int'}}
// expected-error@-1 {{'let' property 'height' may not be initialized directly; use "self.init(...)" or "self = ..." instead}}
}
// Designated initializer

View File

@@ -261,11 +261,12 @@ func useNested(_ ii: Int, hni: HasNested<Int>,
var id = hni.f(1, u: 3.14159)
id = (2, 3.14159)
hni.f(1.5, 3.14159) // expected-error{{missing argument label 'u:' in call}}
// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}}
hni.f(1.5, u: 3.14159) // expected-error{{cannot convert value of type 'Double' to expected argument type 'Int'}}
// Generic constructor of a generic struct
HNI(1, 2.71828) // expected-warning{{unused}}
HNI(1.5, 2.71828) // expected-error{{'Double' is not convertible to 'Int'}}
HNI(1.5, 2.71828) // expected-error{{cannot convert value of type 'Double' to expected argument type 'Int'}}
// Generic function in a nested generic struct
var ids = xis.g(1, u: "Hello", v: 3.14159)

View File

@@ -54,8 +54,7 @@ public struct S<A: P> where A.T == S<A> {
func g(a: S<A>) {
f(a: id(t: a))
// expected-note@-1 {{expected an argument list of type '(a: A.T)'}}
// expected-error@-2 {{cannot invoke 'f' with an argument list of type '(a: S<A>)'}}
// expected-error@-1 {{cannot convert value of type 'S<A>' to expected argument type 'A.T'}}
_ = S<A>.self
}

View File

@@ -60,6 +60,7 @@ let _ = Z.a.stringValue // expected-error {{value of type 'Z' has no member 'str
let _ = X(stringValue: "a") // expected-error {{'X' cannot be constructed because it has no accessible initializers}}
let _ = Y(stringValue: "a") // expected-error {{incorrect argument label in call (have 'stringValue:', expected 'rawValue:')}}
let _ = Z(stringValue: "a") // expected-error {{incorrect argument label in call (have 'stringValue:', expected 'rawValue:')}}
// expected-error@-1 {{cannot convert value of type 'String' to expected argument type 'Int'}}
let _ = X.a.intValue // expected-error {{value of type 'X' has no member 'intValue'}}
let _ = Y.a.intValue // expected-error {{value of type 'Y' has no member 'intValue'; did you mean 'rawValue'?}}
@@ -67,6 +68,7 @@ let _ = Z.a.intValue // expected-error {{value of type 'Z' has no member 'intVal
let _ = X(intValue: 0) // expected-error {{'X' cannot be constructed because it has no accessible initializers}}
let _ = Y(intValue: 0) // expected-error {{incorrect argument label in call (have 'intValue:', expected 'rawValue:')}}
// expected-error@-1 {{cannot convert value of type 'Int' to expected argument type 'String'}}
let _ = Z(intValue: 0) // expected-error {{incorrect argument label in call (have 'intValue:', expected 'rawValue:')}}
// Types which are valid for CodingKey derived conformance should get derivation

View File

@@ -354,7 +354,7 @@ struct SubscriptTest1 {
subscript(arg: Protocol) -> Bool { return true } // expected-note 2 {{declared here}}
subscript(arg: (foo: Bool, bar: (Int, baz: SubClass)), arg2: String) -> Bool { return true }
// expected-note@-1 2 {{declared here}}
// expected-note@-1 3 {{declared here}}
}
func testSubscript1(_ s1 : SubscriptTest1) {
@@ -368,6 +368,7 @@ func testSubscript1(_ s1 : SubscriptTest1) {
// expected-error@-1 {{value of type 'SubscriptTest1' has no property or method named 'subscript'; did you mean to use the subscript operator?}} {{9-10=}} {{10-19=}} {{19-20=[}} {{60-61=]}}
_ = s1.subscript((fo: true, (5, baz: SubClass())), "hello")
// expected-error@-1 {{cannot convert value of type '(fo: Bool, (Int, baz: SubClass))' to expected argument type '(foo: Bool, bar: (Int, baz: SubClass))'}}
// expected-error@-2 {{value of type 'SubscriptTest1' has no property or method named 'subscript'; did you mean to use the subscript operator?}}
_ = s1.subscript(SubSubClass())
// expected-error@-1 {{value of type 'SubscriptTest1' has no property or method named 'subscript'; did you mean to use the subscript operator?}} {{9-10=}} {{10-19=}} {{19-20=[}} {{33-34=]}}
_ = s1.subscript(ClassConformingToProtocol())
@@ -392,17 +393,16 @@ func testSubscript1(_ s1 : SubscriptTest1) {
}
struct SubscriptTest2 {
subscript(a : String, b : Int) -> Int { return 0 }
subscript(a : String, b : Int) -> Int { return 0 } // expected-note {{candidate expects value of type 'Int' at psoition #1}}
// expected-note@-1 {{declared here}}
subscript(a : String, b : String) -> Int { return 0 }
subscript(a : String, b : String) -> Int { return 0 } // expected-note {{candidate expects value of type 'String' at psoition #1}}
}
func testSubscript1(_ s2 : SubscriptTest2) {
_ = s2["foo"] // expected-error {{cannot subscript a value of type 'SubscriptTest2' with an argument of type 'String'}}
// expected-note @-1 {{overloads for 'subscript' exist with these partially matching parameter lists: (String, Int), (String, String)}}
let a = s2["foo", 1.0] // expected-error {{cannot subscript a value of type 'SubscriptTest2' with an argument of type '(String, Double)'}}
// expected-note @-1 {{overloads for 'subscript' exist with these partially matching parameter lists: (String, Int), (String, String)}}
let a = s2["foo", 1.0] // expected-error {{no exact matches in call to subscript}}
_ = s2.subscript("hello", 6)
// expected-error@-1 {{value of type 'SubscriptTest2' has no property or method named 'subscript'; did you mean to use the subscript operator?}} {{9-10=}} {{10-19=}} {{19-20=[}} {{30-31=]}}

View File

@@ -57,7 +57,7 @@ func f() {
typealias A<T1, T2> = MyType<T2, T1> // expected-note {{generic type 'A' declared here}}
typealias B<T1> = MyType<T1, T1> // expected-note {{'T1' declared as parameter to type 'B'}}
typealias B<T1> = MyType<T1, T1>
typealias C<T> = MyType<String, T>
@@ -100,13 +100,13 @@ let _ : F = { a in a } // expected-error {{type of expression is ambiguous with
_ = MyType(a: "foo", b: 42)
_ = A(a: "foo", b: 42)
_ = A<Int, String>(a: "foo", b: 42)
_ = A<String, Int>(a: "foo", // expected-error {{'String' is not convertible to 'Int'}}
b: 42)
_ = A<String, Int>(a: "foo", // expected-error {{cannot convert value of type 'String' to expected argument type 'Int'}}
b: 42) // expected-error {{cannot convert value of type 'Int' to expected argument type 'String'}}
_ = B(a: 12, b: 42)
_ = B(a: 12, b: 42 as Float)
_ = B(a: "foo", b: 42) // expected-error {{generic parameter 'T1' could not be inferred}} expected-note {{explicitly specify the generic arguments to fix this issue}} {{6-6=<Any>}}
_ = B(a: "foo", b: 42) // expected-error {{cannot convert value of type 'Int' to expected argument type 'String'}}
_ = C(a: "foo", b: 42)
_ = C(a: 42, // expected-error {{'Int' is not convertible to 'String'}}
_ = C(a: 42, // expected-error {{cannot convert value of type 'Int' to expected argument type 'String'}}
b: 42)
_ = G(a: "foo", b: 42)
@@ -162,7 +162,7 @@ class GenericClass<T> {
}
func testCaptureInvalid2<S>(s: Int, t: T) -> TA<S> {
return TA(a: t, b: s) // expected-error {{cannot convert return expression of type 'MyType<T, Int>' to return type 'MyType<T, S>'}}
return TA(a: t, b: s) // expected-error {{cannot convert value of type 'Int' to expected argument type 'S'}}
}
struct NestedStruct<U> {
@@ -245,10 +245,10 @@ let _: ConcreteStruct.O<Int> = ConcreteStruct.O<Int>(123)
let _ = GenericClass.TA<Float>(a: 4.0, b: 1) // FIXME
let _ = GenericClass.TA<Float>(a: 1, b: 4.0)
let _ = GenericClass<Int>.TA(a: 4.0, b: 1) // expected-error {{'Double' is not convertible to 'Int'}}
let _ = GenericClass<Int>.TA(a: 4.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
let _ = GenericClass<Int>.TA(a: 1, b: 4.0)
let _ = GenericClass<Int>.TA<Float>(a: 4.0, b: 1) // expected-error {{'Double' is not convertible to 'Int'}}
let _ = GenericClass<Int>.TA<Float>(a: 4.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
let _ = GenericClass<Int>.TA<Float>(a: 1, b: 4.0)
let _: GenericClass.TA = GenericClass.TA(a: 4.0, b: 1)
@@ -263,7 +263,7 @@ let _: GenericClass.TA = GenericClass<Int>.TA(a: 1, b: 4.0)
let _: GenericClass.TA = GenericClass<Int>.TA<Float>(a: 4.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
let _: GenericClass.TA = GenericClass<Int>.TA<Float>(a: 1, b: 4.0)
let _: GenericClass<Int>.TA = GenericClass.TA(a: 4.0, b: 1) // expected-error {{cannot convert value of type 'MyType<Double, Int>' to specified type 'GenericClass<Int>.TA'}}
let _: GenericClass<Int>.TA = GenericClass.TA(a: 4.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
let _: GenericClass<Int>.TA = GenericClass.TA(a: 1, b: 4.0)
let _: GenericClass<Int>.TA = GenericClass.TA<Float>(a: 4.0, b: 1) // expected-error {{cannot assign value of type 'MyType<Float, Int>' to type 'MyType<Int, Int>'}}
@@ -275,7 +275,7 @@ let _: GenericClass<Int>.TA = GenericClass<Int>.TA(a: 1, b: 4.0)
let _: GenericClass<Int>.TA = GenericClass<Int>.TA<Float>(a: 4.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
let _: GenericClass<Int>.TA = GenericClass<Int>.TA<Float>(a: 1, b: 4.0)
let _: GenericClass<Int>.TA<Float> = GenericClass.TA(a: 4.0, b: 1) // expected-error {{cannot convert value of type 'MyType<Double, Int>' to specified type 'GenericClass<Int>.TA<Float>' (aka 'MyType<Int, Float>')}}
let _: GenericClass<Int>.TA<Float> = GenericClass.TA(a: 4.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
let _: GenericClass<Int>.TA<Float> = GenericClass.TA(a: 1, b: 4.0)
let _: GenericClass<Int>.TA<Float> = GenericClass.TA<Float>(a: 4.0, b: 1) // expected-error {{cannot assign value of type 'MyType<Float, Float>' to type 'GenericClass<Int>.TA<Float>' (aka 'MyType<Int, Float>')}}

View File

@@ -609,6 +609,7 @@ class C {
}
_ = C(3) // expected-error {{missing argument label 'other:' in call}}
// expected-error@-1 {{cannot convert value of type 'Int' to expected argument type 'C?'}}
_ = C(other: 3) // expected-error {{cannot convert value of type 'Int' to expected argument type 'C?'}}
//===----------------------------------------------------------------------===//
@@ -743,7 +744,9 @@ func invalidDictionaryLiteral() {
[4].joined(separator: [1]) // expected-error {{cannot convert value of type 'Int' to expected element type 'String'}}
// expected-error@-1 {{cannot convert value of type '[Int]' to expected argument type 'String'}}
[4].joined(separator: [[[1]]]) // expected-error {{cannot convert value of type 'Int' to expected element type 'String'}}
// expected-error@-1 {{cannot convert value of type '[[[Int]]]' to expected argument type 'String'}}
//===----------------------------------------------------------------------===//
// nil/metatype comparisons
@@ -797,11 +800,10 @@ func testParenExprInTheWay() {
if x & 4.0 {} // expected-error {{binary operator '&' cannot be applied to operands of type 'Int' and 'Double'}} expected-note {{expected an argument list of type '(Int, Int)'}}
if (x & 4.0) {} // expected-error {{binary operator '&' cannot be applied to operands of type 'Int' and 'Double'}} expected-note {{expected an argument list of type '(Int, Int)'}}
if !(x & 4.0) {} // expected-error {{binary operator '&' cannot be applied to operands of type 'Int' and 'Double'}}
//expected-note @-1 {{expected an argument list of type '(Int, Int)'}}
if (x & 4.0) {} // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
if !(x & 4.0) {} // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
// expected-error@-1 {{cannot convert value of type 'Int' to expected argument type 'Bool'}}
if x & x {} // expected-error {{'Int' is not convertible to 'Bool'}}
}

View File

@@ -169,6 +169,7 @@ class RDar16666631 {
}
}
let rdar16666631 = RDar16666631(i: 5, d: 6) // expected-error {{incorrect argument label in call (have 'i:d:', expected 'i:s:')}}
// expected-error@-1 {{cannot convert value of type 'Int' to expected argument type 'String'}}
struct S {

View File

@@ -4,10 +4,5 @@ class NotEquatable {}
func test_ArrayOfNotEquatableIsNotEquatable() {
var a = [ NotEquatable(), NotEquatable() ]
// FIXME: This is an awful error.
if a == a {} // expected-error {{'<Self where Self : Equatable> (Self.Type) -> (Self, Self) -> Bool' requires that 'NotEquatable' conform to 'Equatable'}}
// expected-error@-1{{type 'NotEquatable' does not conform to protocol 'Equatable'}}
// expected-note @-2 {{requirement specified as 'NotEquatable' : 'Equatable'}}
// expected-note@-3{{requirement from conditional conformance of '[NotEquatable]' to 'Equatable'}}
if a == a {} // expected-error {{operator function '==' requires that 'NotEquatable' conform to 'Equatable'}}
}

View File

@@ -68,7 +68,7 @@ func patterns(gir: GoodRange<Int>, gtr: GoodTupleIterator) {
for (i, f) in gtr {
sum = sum + i
sumf = sumf + f
sum = sum + f // expected-error {{binary operator '+' cannot be applied to operands of type 'Int' and 'Float'}} expected-note {{expected an argument list of type '(Int, Int)'}}
sum = sum + f // expected-error {{cannot convert value of type 'Float' to expected argument type 'Int'}}
}
for (i, _) : (Int, Float) in gtr { sum = sum + i }

View File

@@ -303,11 +303,11 @@ func conformsToP1<T : P1>(_: T) {}
func conformsToP2<T : P2>(_: T) {}
func conformsToBaseIntAndP2<T : Base<Int> & P2>(_: T) {}
// expected-note@-1 {{where 'T' = 'FakeDerived'}}
// expected-note@-2 {{where 'T' = 'Base<Int>'}}
// expected-note@-2 {{where 'T' = 'T1'}}
func conformsToBaseIntAndP2WithWhereClause<T>(_: T) where T : Base<Int> & P2 {}
// expected-note@-1 {{where 'T' = 'FakeDerived'}}
// expected-note@-2 {{where 'T' = 'Base<Int>'}}
// expected-note@-2 {{where 'T' = 'T1'}}
class FakeDerived : Base<String>, P2 {
required init(classInit: ()) {
@@ -432,10 +432,10 @@ func conformsTo<T1 : P2, T2 : Base<Int> & P2>(
// expected-error@-1 {{global function 'conformsToBaseIntAndP2WithWhereClause' requires that 'FakeDerived' inherit from 'Base<Int>'}}
conformsToBaseIntAndP2(p2Archetype)
// expected-error@-1 {{global function 'conformsToBaseIntAndP2' requires that 'Base<Int>' conform to 'P2'}}
// expected-error@-1 {{global function 'conformsToBaseIntAndP2' requires that 'T1' inherit from 'Base<Int>'}}
conformsToBaseIntAndP2WithWhereClause(p2Archetype)
// expected-error@-1 {{global function 'conformsToBaseIntAndP2WithWhereClause' requires that 'Base<Int>' conform to 'P2'}}
// expected-error@-1 {{global function 'conformsToBaseIntAndP2WithWhereClause' requires that 'T1' inherit from 'Base<Int>'}}
// Good
conformsToAnyObject(anyObject)

View File

@@ -9,5 +9,5 @@ let _: E = .foo
let _: E<Int> = .foo // Ok
let _: E = .bar(42) // Ok
let _: E<String> = .bar(42)
// expected-error@-1 {{member 'bar' in 'E<String>' produces result of type 'E<T>', but context expects 'E<String>'}}
// expected-error@-1 {{cannot convert value of type 'Int' to expected argument type 'String'}}
let _: E<Int> = .bar(42) // Ok

View File

@@ -1,9 +1,8 @@
// RUN: %target-typecheck-verify-swift
func foo(_ msg: Int) {}
func foo(_ msg: Double) {}
func foo(_ msg: Int) {} // expected-note {{candidate expects value of type 'Int' at psoition #0}}
func foo(_ msg: Double) {} // expected-note {{candidate expects value of type 'Double' at psoition #0}}
func rdar38309176(_ errors: inout [String]) {
foo("error: \(errors[0])") // expected-error {{cannot invoke 'foo' with an argument list of type '(String)'}}
// expected-note@-1 {{overloads for 'foo' exist with these partially matching parameter lists: (Double), (Int)}}
foo("error: \(errors[0])") // expected-error {{no exact matches in call to global function 'foo'}}
}

View File

@@ -12,6 +12,5 @@ import Foundation
func baz(bar: Bar) {
max(bar, bar.foo?.x ?? 0)
// expected-error@-1 {{cannot invoke 'max' with an argument list of type '(Bar, Int)'}}
// expected-note@-2 {{expected an argument list of type '(T, T)'}}
// expected-error@-1 {{cannot convert value of type 'Bar' to expected argument type 'Int'}}
}

View File

@@ -1,11 +1,10 @@
// RUN: %target-typecheck-verify-swift
struct Foo<T, U> { // expected-note {{'U' declared as parameter to type 'Foo'}}
struct Foo<T, U> {
var value: U
func bar() -> Foo<T, U> {
return Foo(value)
// expected-error@-1 {{generic parameter 'U' could not be inferred}}
// expected-note@-2 {{explicitly specify the generic arguments to fix this issue}}
// expected-error@-1 {{'Foo<T, U>' requires the types 'T' and 'U' be equivalent}}
}
}