mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Gardening: Migrate test suite to GH issues: Constraints (1/5)
This commit is contained in:
@@ -43,7 +43,9 @@ let e1fix = ns1 as FooError // expected-error {{'NSError' is not convertible to
|
||||
let esub = ns1 as Error
|
||||
let esub2 = ns1 as? Error // expected-warning{{conditional cast from 'NSError' to 'any Error' always succeeds}}
|
||||
|
||||
// SR-1562 / rdar://problem/26370984
|
||||
// rdar://problem/26370984
|
||||
// https://github.com/apple/swift/issues/44171
|
||||
|
||||
enum MyError : Error {
|
||||
case failed
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// SR-9611: Array type locally interferes with array literals.
|
||||
/// https://github.com/apple/swift/issues/52057
|
||||
/// `Array` type locally interferes with array literals
|
||||
|
||||
struct Array { }
|
||||
|
||||
func foo() {
|
||||
|
||||
@@ -71,18 +71,20 @@ func f23798944() {
|
||||
}
|
||||
}
|
||||
|
||||
.sr_3506 = 0 // expected-error {{type 'Int' has no member 'sr_3506'}}
|
||||
|
||||
// SR-1553
|
||||
// https://github.com/apple/swift/issues/46094
|
||||
do {
|
||||
.x = 0 // expected-error {{type 'Int' has no member 'x'}}
|
||||
}
|
||||
|
||||
// https://github.com/apple/swift/issues/44162
|
||||
func returnsVoid() {}
|
||||
_ = returnsVoid() // expected-warning {{using '_' to ignore the result of a Void-returning function is redundant}}{{1-5=}}
|
||||
|
||||
// SR-14003
|
||||
class SR14003 {
|
||||
var callback: ((SR14003) -> Void)!
|
||||
// https://github.com/apple/swift/issues/56396
|
||||
class С_56396 {
|
||||
var callback: ((С_56396) -> Void)!
|
||||
|
||||
func setCallback(_ callback: @escaping (Self) -> Void) {
|
||||
self.callback = callback // expected-error {{cannot assign value of type '(Self) -> Void' to type '((SR14003) -> Void)?'}}
|
||||
self.callback = callback // expected-error {{cannot assign value of type '(Self) -> Void' to type '((С_56396) -> Void)?'}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ func owl3() {
|
||||
Owl<Spoon>().eat(Mince(), with:Spoon())
|
||||
}
|
||||
|
||||
// "Can't access associated types through class-constrained generic parameters"
|
||||
// (https://bugs.swift.org/browse/SR-726)
|
||||
// https://github.com/apple/swift/issues/43341
|
||||
// Can't access associated types through class-constrained generic parameters
|
||||
func spoon<S: Spoon>(_ s: S) {
|
||||
let _: S.Runcee?
|
||||
}
|
||||
|
||||
// SR-4143
|
||||
// https://github.com/apple/swift/issues/46726
|
||||
|
||||
protocol SameTypedDefault {
|
||||
associatedtype X
|
||||
@@ -109,15 +109,15 @@ struct UsesSameTypedDefaultDerivedWithoutSatisfyingReqts: SameTypedDefaultDerive
|
||||
static var y: YType { return YType() }
|
||||
}
|
||||
|
||||
// SR-12199
|
||||
// https://github.com/apple/swift/issues/54624
|
||||
|
||||
protocol SR_12199_P1 {
|
||||
protocol P1_54624 {
|
||||
associatedtype Assoc // expected-note {{'Assoc' declared here}}
|
||||
}
|
||||
|
||||
enum SR_12199_E {}
|
||||
enum E_54624 {}
|
||||
|
||||
protocol SR_12199_P2: SR_12199_P1 where Assoc == SR_12199_E {
|
||||
associatedtype Assoc: SR_12199_E // expected-error {{type 'Self.Assoc' constrained to non-protocol, non-class type 'SR_12199_E'}}
|
||||
// expected-warning@-1 {{redeclaration of associated type 'Assoc' from protocol 'SR_12199_P1' is better expressed as a 'where' clause on the protocol}}
|
||||
protocol P2_54624: P1_54624 where Assoc == E_54624 {
|
||||
associatedtype Assoc: E_54624 // expected-error {{type 'Self.Assoc' constrained to non-protocol, non-class type 'E_54624'}}
|
||||
// expected-warning@-1 {{redeclaration of associated type 'Assoc' from protocol 'P1_54624' is better expressed as a 'where' clause on the protocol}}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ func test_contextual_member_with_availability() {
|
||||
@available(*, unavailable)
|
||||
func unavailableFunction(_ x: Int) -> Bool { true } // expected-note {{'unavailableFunction' has been explicitly marked unavailable here}}
|
||||
|
||||
// SR-13260: Availability checking not working in the where clause of a for
|
||||
// loop.
|
||||
func sr13260(_ arr: [Int]) {
|
||||
/// https://github.com/apple/swift/issues/55700
|
||||
/// Availability checking not working in the `where` clause of a `for` loop
|
||||
func f_55700(_ arr: [Int]) {
|
||||
for x in arr where unavailableFunction(x) {} // expected-error {{'unavailableFunction' is unavailable}}
|
||||
}
|
||||
|
||||
@@ -395,15 +395,17 @@ func rdar60501780() {
|
||||
}
|
||||
}
|
||||
|
||||
// SR-15161
|
||||
func SR15161_as(e: Error?) {
|
||||
let _ = e as? NSError // Ok
|
||||
}
|
||||
// https://github.com/apple/swift/issues/57484
|
||||
do {
|
||||
func as1(e: Error?) {
|
||||
let _ = e as? NSError // Ok
|
||||
}
|
||||
|
||||
func SR15161_is(e: Error?) {
|
||||
_ = e is NSError // expected-warning{{checking a value with optional type '(any Error)?' against type 'NSError' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}
|
||||
}
|
||||
func as2(e: Error?) {
|
||||
let _ = e as! NSError // expected-warning{{forced cast from '(any Error)?' to 'NSError' only unwraps and bridges; did you mean to use '!' with 'as'?}}
|
||||
}
|
||||
|
||||
func SR15161_as_1(e: Error?) {
|
||||
let _ = e as! NSError // expected-warning{{forced cast from '(any Error)?' to 'NSError' only unwraps and bridges; did you mean to use '!' with 'as'?}}
|
||||
func is1(e: Error?) {
|
||||
_ = e is NSError // expected-warning{{checking a value with optional type '(any Error)?' against type 'NSError' succeeds whenever the value is non-nil; did you mean to use '!= nil'?}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,9 @@ func test(_ a : CFString!, b : CFString) {
|
||||
let r22507759: NSObject! = "test" as NSString
|
||||
let _: NSString! = unsafeDowncast(r22507759) // expected-error {{missing argument for parameter 'to' in call}}
|
||||
|
||||
// rdar://problem/29496775 / SR-3319
|
||||
func sr3319(f: CGFloat, n: NSNumber) {
|
||||
// rdar://problem/29496775
|
||||
// https://github.com/apple/swift/issues/45907
|
||||
func f_45907(f: CGFloat, n: NSNumber) {
|
||||
let _ = [f].map { $0 as NSNumber }
|
||||
let _ = [n].map { $0 as! CGFloat }
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ func rdar29907555(_ value: Any!) -> String {
|
||||
// expected-note@-2 {{provide a default value to avoid this warning}}
|
||||
}
|
||||
|
||||
struct SR3715 {
|
||||
// https://github.com/apple/swift/issues/46300
|
||||
struct S_46300 {
|
||||
var overloaded: Int! // expected-note {{implicitly unwrapped property 'overloaded' declared here}}
|
||||
|
||||
func overloaded(_ x: Int) {}
|
||||
@@ -73,8 +74,9 @@ class MoviesViewController {
|
||||
}
|
||||
}
|
||||
|
||||
// SR-15053
|
||||
func SR15053<T : Numeric>(_ a: T, _ b: T) -> T {
|
||||
// https://github.com/apple/swift/issues/57380
|
||||
|
||||
func f1_57380<T : Numeric>(_ a: T, _ b: T) -> T {
|
||||
(a + b) / 2 // expected-note {{overloads for '/' exist with these partially matching parameter lists: (Int, Int)}}
|
||||
// expected-error@-1 {{binary operator '/' cannot be applied to operands of type 'T' and 'Int'}}
|
||||
}
|
||||
@@ -89,7 +91,7 @@ func %% (_ lhs: Float, _ rhs: Float) -> Float {
|
||||
lhs / rhs
|
||||
}
|
||||
|
||||
func SR15053<T : Numeric>(_ a: T, _ b: T) {
|
||||
func f2_57380<T : Numeric>(_ a: T, _ b: T) {
|
||||
(a + b) %% 2 // expected-error {{cannot convert value of type 'T' to expected argument type 'Int'}}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,9 @@ func testDefaultExistentials() {
|
||||
// expected-error@-1{{heterogeneous collection literal could only be inferred to '[AnyHashable : String]'}}
|
||||
}
|
||||
|
||||
// SR-4952, rdar://problem/32330004 - Assertion failure during swift::ASTVisitor<::FailureDiagnosis,...>::visit
|
||||
/// rdar://problem/32330004
|
||||
/// https://github.com/apple/swift/issues/47529
|
||||
/// Assertion failure during `swift::ASTVisitor<::FailureDiagnosis,...>::visit`
|
||||
func rdar32330004_1() -> [String: Any] {
|
||||
return ["a""one": 1, "two": 2, "three": 3] // expected-note {{did you mean to use a dictionary literal instead?}}
|
||||
// expected-error@-1 {{expected ',' separator}}
|
||||
|
||||
@@ -408,22 +408,25 @@ func testAnyObjectAmbiguity(_ x: AnyObject) {
|
||||
_ = x.ambiguousMethodParam // expected-error {{ambiguous use of 'ambiguousMethodParam'}}
|
||||
_ = x.unambiguousMethodParam
|
||||
|
||||
// SR-12799: Don't emit a "single-element" tuple error.
|
||||
// https://github.com/apple/swift/issues/55244
|
||||
// Don't emit a single-element tuple error.
|
||||
_ = x[singleCandidate: 0]
|
||||
|
||||
_ = x[ambiguousSubscript: 0] // expected-error {{ambiguous use of 'subscript(ambiguousSubscript:)'}}
|
||||
_ = x[ambiguousSubscript: 0] as Int
|
||||
_ = x[ambiguousSubscript: 0] as String
|
||||
|
||||
// SR-8611: Make sure we can coalesce subscripts with the same types and
|
||||
// selectors through AnyObject lookup.
|
||||
// https://github.com/apple/swift/issues/51126
|
||||
// Make sure we can coalesce subscripts with the same types and selectors
|
||||
// through AnyObject lookup.
|
||||
_ = x[unambiguousSubscript: ""]
|
||||
|
||||
// But not if they have different selectors.
|
||||
_ = x[differentSelectors: 0] // expected-error {{ambiguous use of 'subscript(differentSelectors:)}}
|
||||
}
|
||||
|
||||
// SR-11648
|
||||
// https://github.com/apple/swift/issues/54059
|
||||
|
||||
class HasMethodWithDefault {
|
||||
@objc func hasDefaultParam(_ x: Int = 0) {}
|
||||
}
|
||||
@@ -432,7 +435,9 @@ func testAnyObjectWithDefault(_ x: AnyObject) {
|
||||
x.hasDefaultParam()
|
||||
}
|
||||
|
||||
// SR-11829: Don't perform dynamic lookup for callAsFunction.
|
||||
/// https://github.com/apple/swift/issues/54241
|
||||
/// Don't perform dynamic lookup for `callAsFunction`.
|
||||
|
||||
class ClassWithObjcCallAsFunction {
|
||||
@objc func callAsFunction() {}
|
||||
}
|
||||
@@ -462,6 +467,7 @@ func test_dynamic_subscript_accepts_type_name_argument() {
|
||||
func testAnyObjectConstruction(_ x: AnyObject) {
|
||||
AnyObject() // expected-error {{type 'AnyObject' cannot be instantiated}}
|
||||
|
||||
// FIXME(SR-15210): This should also be rejected.
|
||||
// https://github.com/apple/swift/issues/57532
|
||||
// FIXME: This should also be rejected.
|
||||
_ = type(of: x).init()
|
||||
}
|
||||
|
||||
@@ -172,7 +172,8 @@ struct EnumElementPatternFromContextualType<T> {
|
||||
}
|
||||
}
|
||||
|
||||
// SR-14408
|
||||
// https://github.com/apple/swift/issues/56765
|
||||
|
||||
enum CompassPoint {
|
||||
case North(Int)
|
||||
case South
|
||||
|
||||
@@ -82,11 +82,13 @@ func rdar_59703585() {
|
||||
// expected-error@-1 {{cannot assign value of type '(UnsafePointer<Int8>, UnsafeMutableRawPointer?) -> ()' to type 'Fn?' (aka 'Optional<@convention(c) (Optional<UnsafePointer<Int8>>, Optional<UnsafeMutableRawPointer>) -> ()>')}}
|
||||
}
|
||||
|
||||
// SR-14869
|
||||
var v1: (inout Float) -> ()
|
||||
v1 = { (_: inout Int) in }
|
||||
// expected-error@-1{{cannot assign value of type '(inout Int) -> ()' to type '(inout Float) -> ()'}}
|
||||
// https://github.com/apple/swift/issues/57216
|
||||
do {
|
||||
var v1: (inout Float) -> ()
|
||||
v1 = { (_: inout Int) in }
|
||||
// expected-error@-1{{cannot assign value of type '(inout Int) -> ()' to type '(inout Float) -> ()'}}
|
||||
|
||||
var v2: (Int , inout Float) -> ()
|
||||
v2 = { (_: Int, _: inout Int) in }
|
||||
// expected-error@-1{{cannot assign value of type '(Int, inout Int) -> ()' to type '(Int, inout Float) -> ()'}}
|
||||
var v2: (Int , inout Float) -> ()
|
||||
v2 = { (_: Int, _: inout Int) in }
|
||||
// expected-error@-1{{cannot assign value of type '(Int, inout Int) -> ()' to type '(Int, inout Float) -> ()'}}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// RUN: %target-swift-frontend -typecheck %s
|
||||
|
||||
// SR-5120 / rdar://problem/32618740
|
||||
// rdar://problem/32618740
|
||||
// https://github.com/apple/swift/issues/47696
|
||||
|
||||
protocol InitCollection: Collection {
|
||||
init(_ array: [Iterator.Element])
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ func bar<T, U>(_ x: U, y: T) -> (Derived, Int) where U: Base<T>, U: Derived {
|
||||
return (x, y)
|
||||
}
|
||||
|
||||
// SR-7551 captures a crash on this code.
|
||||
// https://github.com/apple/swift/issues/50093 captures a crash on this code.
|
||||
class IntegerClass : ExpressibleByIntegerLiteral, Equatable {
|
||||
required init(integerLiteral value: Int) { }
|
||||
static func ==(lhs: IntegerClass, rhs: IntegerClass) -> Bool { return true }
|
||||
|
||||
@@ -200,9 +200,9 @@ func testImmutableUnsafePointer(_ p: UnsafePointer<Int>) {
|
||||
p[0] = 1 // expected-error {{cannot assign through subscript: subscript is get-only}}
|
||||
}
|
||||
|
||||
// <https://bugs.swift.org/browse/SR-7> Inferring closure param type to
|
||||
// inout crashes compiler
|
||||
let g = { x in f0(x) } // expected-error{{passing value of type 'Int' to an inout parameter requires explicit '&'}} {{19-19=&}}
|
||||
/// https://github.com/apple/swift/issues/42633
|
||||
/// Inferring closure param type to `inout` crashes compiler
|
||||
let _ = { x in f0(x) } // expected-error{{passing value of type 'Int' to an inout parameter requires explicit '&'}} {{19-19=&}}
|
||||
|
||||
// <rdar://problem/17245353> Crash with optional closure taking inout
|
||||
func rdar17245353() {
|
||||
@@ -242,7 +242,8 @@ func wump<T>(to: T, _ body: (G<T>) -> ()) {}
|
||||
wump(to: 0, { $0[] = 0 })
|
||||
// expected-error@-1 {{missing argument for parameter #1 in call}}
|
||||
|
||||
// SR-13732
|
||||
// https://github.com/apple/swift/issues/56129
|
||||
|
||||
extension MutableCollection {
|
||||
public mutating func writePrefix<I: IteratorProtocol>(from source: inout I)
|
||||
-> (writtenCount: Int, afterLastWritten: Index)
|
||||
|
||||
@@ -194,8 +194,9 @@ func overloadedMethod<T>() {} // expected-note {{in call to function 'overloaded
|
||||
overloadedMethod()
|
||||
// expected-error@-1 {{generic parameter 'T' could not be inferred}}
|
||||
|
||||
// Ensure we select the overload of '??' returning T? rather than T.
|
||||
func SR3817(_ d: [String : Any], _ s: String, _ t: String) -> Any {
|
||||
/// https://github.com/apple/swift/issues/46402
|
||||
/// Ensure we select the overload of `??` returning `T?` rather than `T`.
|
||||
func f_46402(_ d: [String : Any], _ s: String, _ t: String) -> Any {
|
||||
if let r = d[s] ?? d[t] {
|
||||
return r
|
||||
} else {
|
||||
|
||||
@@ -416,8 +416,9 @@ func rdar_50512161() {
|
||||
}
|
||||
}
|
||||
|
||||
// SR-11609: Compiler crash on missing conformance for default param
|
||||
func test_sr_11609() {
|
||||
// https://github.com/apple/swift/issues/54017
|
||||
// Compiler crash on missing conformance for default param
|
||||
do {
|
||||
func foo<T : Initable>(_ x: T = .init()) -> T { x } // expected-note {{where 'T' = 'String'}}
|
||||
let _: String = foo()
|
||||
// expected-error@-1 {{local function 'foo' requires that 'String' conform to 'Initable'}}
|
||||
@@ -520,14 +521,15 @@ case test(cond: Bool, v: Int64)
|
||||
}
|
||||
}
|
||||
|
||||
// SR-15970
|
||||
protocol SR15970_P {}
|
||||
struct SR15970_S {}
|
||||
// https://github.com/apple/swift/issues/58231
|
||||
|
||||
func SR15970_F(x: Int) -> SR15970_P {
|
||||
return SR15970_S() // expected-error{{return expression of type 'SR15970_S' does not conform to 'SR15970_P'}}
|
||||
protocol P_58231 {}
|
||||
struct S_58231 {}
|
||||
|
||||
func f1_58231(x: Int) -> P_58231 {
|
||||
return S_58231() // expected-error{{return expression of type 'S_58231' does not conform to 'P_58231'}}
|
||||
}
|
||||
|
||||
func SR15970_F1(x: Int) -> SR15970_P? {
|
||||
return SR15970_S() // expected-error{{return expression of type 'SR15970_S' does not conform to 'SR15970_P'}}
|
||||
func f2_58231(x: Int) -> P_58231? {
|
||||
return S_58231() // expected-error{{return expression of type 'S_58231' does not conform to 'P_58231'}}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,9 @@ print(mbuilders.methodBuilder(13))
|
||||
// CHECK: ("propertyBuilder", 12)
|
||||
print(mbuilders.propertyBuilder)
|
||||
|
||||
// SR-11439: Operator builders
|
||||
// https://github.com/apple/swift/issues/53840
|
||||
// Operator builders
|
||||
|
||||
infix operator ^^^
|
||||
func ^^^ (lhs: Int, @TupleBuilder rhs: (Int) -> (String, Int)) -> (String, Int) {
|
||||
return rhs(lhs)
|
||||
|
||||
@@ -232,7 +232,8 @@ func test_56221372() -> some P {
|
||||
})
|
||||
}
|
||||
|
||||
struct SR11440 {
|
||||
// https://github.com/apple/swift/issues/53841
|
||||
struct S_53841 {
|
||||
typealias ReturnsTuple<T> = () -> (T, T)
|
||||
subscript<T, U>(@TupleBuilder x: ReturnsTuple<T>) -> (ReturnsTuple<U>) -> Void { //expected-note {{in call to 'subscript(_:)'}}
|
||||
return { _ in }
|
||||
@@ -261,8 +262,9 @@ struct SR11440 {
|
||||
|
||||
func acceptInt(_: Int, _: () -> Void) { }
|
||||
|
||||
// SR-11350 crash due to improper recontextualization.
|
||||
func erroneousSR11350(x: Int) {
|
||||
// https://github.com/apple/swift/issues/53751
|
||||
// Crash due to improper recontextualization.
|
||||
func erroneous_53751(x: Int) {
|
||||
tuplify(true) { b in
|
||||
17
|
||||
x + 25
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
// REQUIRES: rdar65007946
|
||||
|
||||
// https://github.com/apple/swift/issues/52724
|
||||
|
||||
struct A {
|
||||
static func * (lhs: A, rhs: A) -> B { return B() }
|
||||
static func * (lhs: B, rhs: A) -> B { return B() }
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s
|
||||
|
||||
// https://github.com/apple/swift/issues/52995
|
||||
|
||||
protocol Nested {
|
||||
associatedtype U // expected-note {{protocol requires nested type 'U'; do you want to add it?}}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/53125
|
||||
|
||||
typealias T1 = Int
|
||||
typealias T2 = Float
|
||||
typealias T3 = Bool
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// SR-10757
|
||||
// https://github.com/apple/swift/issues/53147
|
||||
|
||||
struct Parser<A> {
|
||||
let run: (inout Substring) -> A?
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/53296
|
||||
|
||||
protocol ViewDataSource: class {
|
||||
func foo<T>() -> [T]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/53305
|
||||
|
||||
struct Data {
|
||||
init<S: Sequence>(_: S) where S.Element == UInt8 {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/54705
|
||||
|
||||
enum Time {
|
||||
case milliseconds(Int)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-swift-frontend -typecheck -verify %s
|
||||
|
||||
// https://github.com/apple/swift/issues/54799
|
||||
|
||||
public protocol MyProtocol {}
|
||||
|
||||
public struct MyProtocolImpl: MyProtocol {}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/54820
|
||||
|
||||
protocol Protocol {
|
||||
associatedtype Index: Comparable
|
||||
subscript(bounds: Range<Index>) -> Int { get }
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/54962
|
||||
|
||||
@propertyWrapper
|
||||
@dynamicMemberLookup
|
||||
struct Binding<Value> {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/55410
|
||||
|
||||
protocol P {}
|
||||
typealias T = (P) -> Void
|
||||
let x: T! = [1, 2, 3].reversed().reduce()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// SR-13183: Make sure we don't incorrectly split the constraint system without
|
||||
// https://github.com/apple/swift/issues/55623
|
||||
// Make sure we don't incorrectly split the constraint system without
|
||||
// considering that a result builder type var may connect the inside of a
|
||||
// closure body with the enclosing expression.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// SR-13815
|
||||
// https://github.com/apple/swift/issues/56212
|
||||
|
||||
enum E {
|
||||
case foo(String)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/56348
|
||||
|
||||
protocol TheProtocol {}
|
||||
struct TheType1: TheProtocol {}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// SR-13992
|
||||
// https://github.com/apple/swift/issues/56387
|
||||
|
||||
protocol V {}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: %target-swift-frontend -dump-ast %s | %FileCheck %s
|
||||
|
||||
// https://bugs.swift.org/browse/SR-15742
|
||||
// https://github.com/apple/swift/issues/58019
|
||||
|
||||
func fetch() {
|
||||
// CHECK: open_existential_expr implicit type='Void'
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-swift-emit-silgen %s -verify | %FileCheck %s
|
||||
|
||||
// https://github.com/apple/swift/issues/45309
|
||||
|
||||
func f<T>(_: () -> T) {}
|
||||
func f<T>(_: @autoclosure () -> T) {}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/47241
|
||||
|
||||
struct M<T> where T : Collection { // expected-note {{where 'T' = 'X.Y'}}
|
||||
static func f(a: T, b: T) -> [E<T.Iterator.Element>] {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/47827
|
||||
|
||||
protocol P {}
|
||||
class Helper {}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck %s
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
// https://github.com/apple/swift/issues/49646
|
||||
|
||||
import Foundation
|
||||
|
||||
class C : NSObject, NSWobbling {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift -swift-version 4
|
||||
|
||||
// https://github.com/apple/swift/issues/49968
|
||||
|
||||
protocol X {
|
||||
var foo: Int { get }
|
||||
var bar: Int { get }
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/50410
|
||||
|
||||
protocol Proto {}
|
||||
class Base {}
|
||||
class Test : Base, Proto {}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// SR-7884
|
||||
// https://github.com/apple/swift/issues/50419
|
||||
|
||||
func f<T>(_ x: T) -> T {
|
||||
return x
|
||||
}
|
||||
@@ -13,7 +14,8 @@ func f<T>(_ x: T?) -> T? {
|
||||
let r = f(1)
|
||||
let _ = r! // expected-error {{cannot force unwrap value of non-optional type 'Int'}}
|
||||
|
||||
// SR-7899
|
||||
// https://github.com/apple/swift/issues/50434
|
||||
|
||||
func testLazySequence(_ lazySequence: LazySequence<[Int]>?) {
|
||||
let value = lazySequence?.compactMap({ $0 as? Int }).first // expected-warning {{conditional cast from 'Int' to 'Int' always succeeds}}
|
||||
let _: Int = value!
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// https://github.com/apple/swift/issues/51599
|
||||
|
||||
func test(_ a: [Int], _ f: ((Int) -> Bool)?) {
|
||||
_ = a.filter(f!)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s
|
||||
|
||||
// https://github.com/apple/swift/issues/52072
|
||||
|
||||
class BaseClass {}
|
||||
class SubClass: BaseClass {}
|
||||
struct Box<T> { init(_: T.Type) {} }
|
||||
|
||||
@@ -117,14 +117,17 @@ func r23670252(_ dictionary: [String : AnyObject], someObject: AnyObject) {
|
||||
}
|
||||
|
||||
|
||||
// SR-718 - Type mismatch reported as extraneous parameter
|
||||
struct SR718 {
|
||||
subscript(b : Int) -> Int
|
||||
{ return 0 }
|
||||
subscript(a a : UInt) -> Int { return 0 }
|
||||
}
|
||||
// https://github.com/apple/swift/issues/43333
|
||||
// Type mismatch reported as extraneous parameter
|
||||
do {
|
||||
struct S {
|
||||
subscript(b : Int) -> Int
|
||||
{ return 0 }
|
||||
subscript(a a : UInt) -> Int { return 0 }
|
||||
}
|
||||
|
||||
SR718()[a: Int()] // expected-error {{cannot convert value of type 'Int' to expected argument type 'UInt'}}
|
||||
S()[a: Int()] // expected-error {{cannot convert value of type 'Int' to expected argument type 'UInt'}}
|
||||
}
|
||||
|
||||
// rdar://problem/25601561 - Qol: Bad diagnostic for failed assignment from Any to more specific type
|
||||
|
||||
@@ -166,8 +169,10 @@ func rdar_45819956() {
|
||||
// expected-error@-1 {{cannot pass an inout argument to a subscript; use 'withUnsafeMutablePointer' to explicitly convert argument to a pointer}}
|
||||
}
|
||||
|
||||
// rdar://problem/45825806 - [SR-7190] Array-to-pointer in subscript arg crashes compiler
|
||||
func rdar_45825806() {
|
||||
// rdar://problem/45825806
|
||||
// https://github.com/apple/swift/issues/49738
|
||||
// Array-to-pointer in subscript arg crashes compiler
|
||||
do {
|
||||
struct S {
|
||||
subscript(takesPtr ptr: UnsafePointer<Int>) -> Int {
|
||||
get { return 0 }
|
||||
|
||||
@@ -52,15 +52,17 @@ class B {
|
||||
}
|
||||
}
|
||||
|
||||
// SR-2484: Bad diagnostic for incorrectly calling private init
|
||||
class SR_2484 {
|
||||
/// https://github.com/apple/swift/issues/45089
|
||||
/// Bad diagnostic for incorrectly calling private `init`
|
||||
|
||||
class C_45089 {
|
||||
private init() {} // expected-note {{'init()' declared here}}
|
||||
private init(a: Int) {}
|
||||
}
|
||||
|
||||
class Impl_2484 : SR_2484 {
|
||||
class Impl_45089 : C_45089 {
|
||||
init() {
|
||||
super.init() // expected-error {{'SR_2484' initializer is inaccessible due to 'private' protection level}}
|
||||
super.init() // expected-error {{'C_45089' initializer is inaccessible due to 'private' protection level}}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -201,8 +201,9 @@ func foo(_ pair: (Int, Int)) -> Victory<(x: Int, y: Int)> {
|
||||
}
|
||||
|
||||
|
||||
// https://bugs.swift.org/browse/SR-596
|
||||
// Compiler crashes when accessing a non-existent property of a closure parameter
|
||||
// https://github.com/apple/swift/issues/43213
|
||||
// Compiler crashes when accessing a non-existent property of a closure
|
||||
// parameter
|
||||
func call(_ f: (C) -> Void) {}
|
||||
func makeRequest() {
|
||||
call { obj in
|
||||
@@ -242,7 +243,9 @@ let _ = (x, (y, 0))
|
||||
takesRValue((x, (y, 0)))
|
||||
takesAny((x, (y, 0)))
|
||||
|
||||
// SR-2600 - Closure cannot infer tuple parameter names
|
||||
// https://github.com/apple/swift/issues/45205
|
||||
// Closure cannot infer tuple parameter names
|
||||
|
||||
typealias Closure<A, B> = ((a: A, b: B)) -> String
|
||||
|
||||
func invoke<A, B>(a: A, b: B, _ closure: Closure<A,B>) {
|
||||
@@ -321,7 +324,7 @@ struct DupLabelSubscript {
|
||||
let dupLabelSubscriptStruct = DupLabelSubscript()
|
||||
let _ = dupLabelSubscriptStruct[foo: 5, foo: 5] // ok
|
||||
|
||||
// SR-12869
|
||||
// https://github.com/apple/swift/issues/55316
|
||||
|
||||
var dict: [String: (Int, Int)] = [:]
|
||||
let bignum: Int64 = 1337
|
||||
|
||||
@@ -178,7 +178,7 @@ func test_magic_defaults() {
|
||||
let _: String = generic_with_magic()
|
||||
}
|
||||
|
||||
// SR-16069
|
||||
// https://github.com/apple/swift/issues/58330
|
||||
func test_allow_same_type_between_dependent_types() {
|
||||
struct Default : P {
|
||||
typealias X = Int
|
||||
|
||||
@@ -79,8 +79,11 @@ foo(type(of: G.T.self)) // Ok
|
||||
let _: Any = type(of: G.T.self) // Ok
|
||||
foo(type(of: bar())) // expected-error {{ambiguous use of 'bar()'}}
|
||||
|
||||
struct SR10696 {
|
||||
func bar(_ s: SR10696.Type) {
|
||||
type(of: s)() // expected-error {{type 'SR10696.Type' has no member 'init'}}
|
||||
// https://github.com/apple/swift/issues/53093
|
||||
do {
|
||||
struct S {
|
||||
func bar(_ s: S.Type) {
|
||||
type(of: s)() // expected-error {{type 'S.Type' has no member 'init'}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@ func givesPtr(_ str: String) {
|
||||
var d = 0.0
|
||||
var arr = [1, 2, 3]
|
||||
|
||||
// SR-9090: Allow double optional promotion for pointer conversions.
|
||||
// https://github.com/apple/swift/issues/51587
|
||||
// Allow double optional promotion for pointer conversions.
|
||||
|
||||
takesDoubleOptionalPtr(&arr)
|
||||
takesDoubleOptionalPtr(arr)
|
||||
takesDoubleOptionalPtr(str)
|
||||
@@ -35,12 +37,15 @@ func givesPtr(_ str: String) {
|
||||
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('Int' and 'Double') are expected to be equal}}
|
||||
}
|
||||
|
||||
// SR12382
|
||||
func SR12382(_ x: UnsafeMutablePointer<Double>??) {}
|
||||
// https://github.com/apple/swift/issues/54818
|
||||
do {
|
||||
func f(_ x: UnsafeMutablePointer<Double>??) {}
|
||||
|
||||
var i = 0
|
||||
SR12382(&i) // expected-error {{cannot convert value of type 'UnsafeMutablePointer<Int>' to expected argument type 'UnsafeMutablePointer<Double>'}}
|
||||
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('Int' and 'Double') are expected to be equal}}
|
||||
var i = 0
|
||||
f(&i)
|
||||
// expected-error@-1 {{cannot convert value of type 'UnsafeMutablePointer<Int>' to expected argument type 'UnsafeMutablePointer<Double>'}}
|
||||
// expected-note@-2 {{arguments to generic parameter 'Pointee' ('Int' and 'Double') are expected to be equal}}
|
||||
}
|
||||
|
||||
//problem/68254165 - Bad diagnostic when using String init(decodingCString:) with an incorrect pointer type
|
||||
func rdar68254165(ptr: UnsafeMutablePointer<Int8>) {
|
||||
|
||||
@@ -69,7 +69,7 @@ let _: ((Int) -> Int, (@escaping (Int) -> Int) -> ()) -> () = withoutActuallyEsc
|
||||
// Failing to propagate @noescape into non-single-expression
|
||||
// closure passed to withoutActuallyEscaping
|
||||
|
||||
// https://bugs.swift.org/browse/SR-7886
|
||||
// https://github.com/apple/swift/issues/50421
|
||||
|
||||
class Box<T> {
|
||||
let value: T
|
||||
|
||||
Reference in New Issue
Block a user