mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Gardening: Migrate test suite to GH issues: Sema (1/2)
This commit is contained in:
@@ -207,13 +207,14 @@ extension Container {
|
|||||||
fileprivate class PrivateGenericUser<T> where T: PrivateInnerClass {} // expected-error {{generic class cannot be declared fileprivate because its generic requirement uses a private type}} {{none}}
|
fileprivate class PrivateGenericUser<T> where T: PrivateInnerClass {} // expected-error {{generic class cannot be declared fileprivate because its generic requirement uses a private type}} {{none}}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate struct SR2579 {
|
// https://github.com/apple/swift/issues/45184
|
||||||
|
fileprivate struct C_45184 {
|
||||||
private struct Inner {
|
private struct Inner {
|
||||||
private struct InnerPrivateType {}
|
private struct InnerPrivateType {}
|
||||||
var innerProperty = InnerPrivateType() // expected-error {{property must be declared private because its type 'SR2579.Inner.InnerPrivateType' uses a private type}}
|
var innerProperty = InnerPrivateType() // expected-error {{property must be declared private because its type 'C_45184.Inner.InnerPrivateType' uses a private type}}
|
||||||
}
|
}
|
||||||
// FIXME: We need better errors when one access violation results in more
|
// FIXME: We need better errors when one access violation results in more
|
||||||
// downstream.
|
// downstream.
|
||||||
private var outerProperty = Inner().innerProperty // expected-error {{property cannot be declared in this context because its type 'SR2579.Inner.InnerPrivateType' uses a private type}}
|
private var outerProperty = Inner().innerProperty // expected-error {{property cannot be declared in this context because its type 'C_45184.Inner.InnerPrivateType' uses a private type}}
|
||||||
var outerProperty2 = Inner().innerProperty // expected-error {{property must be declared private because its type 'SR2579.Inner.InnerPrivateType' uses a private type}}
|
var outerProperty2 = Inner().innerProperty // expected-error {{property must be declared private because its type 'C_45184.Inner.InnerPrivateType' uses a private type}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ _ = genericString("Hello")
|
|||||||
let genericInt = GenericType<Set<Int>>(collection: [1, 2, 3])
|
let genericInt = GenericType<Set<Int>>(collection: [1, 2, 3])
|
||||||
_ = genericInt(initialValue: 1)
|
_ = genericInt(initialValue: 1)
|
||||||
|
|
||||||
// SR-11386
|
// https://github.com/apple/swift/issues/53787
|
||||||
|
|
||||||
class C<T> {}
|
class C<T> {}
|
||||||
protocol P1 {}
|
protocol P1 {}
|
||||||
extension C where T : P1 { // expected-note {{where 'T' = 'Int'}}
|
extension C where T : P1 { // expected-note {{where 'T' = 'Int'}}
|
||||||
|
|||||||
@@ -199,7 +199,8 @@ func testIUO(a: SimpleCallable!, b: MultipleArgsCallable!, c: Extended!,
|
|||||||
_ = try? h { throw DummyError() }
|
_ = try? h { throw DummyError() }
|
||||||
}
|
}
|
||||||
|
|
||||||
// SR-11778
|
// https://github.com/apple/swift/issues/54185
|
||||||
|
|
||||||
struct DoubleANumber {
|
struct DoubleANumber {
|
||||||
func callAsFunction(_ x: Int, completion: (Int) -> Void = { _ in }) {
|
func callAsFunction(_ x: Int, completion: (Int) -> Void = { _ in }) {
|
||||||
completion(x + x)
|
completion(x + x)
|
||||||
@@ -211,7 +212,8 @@ func testDefaults(_ x: DoubleANumber) {
|
|||||||
x(5, completion: { _ in })
|
x(5, completion: { _ in })
|
||||||
}
|
}
|
||||||
|
|
||||||
// SR-11881
|
// https://github.com/apple/swift/issues/54296
|
||||||
|
|
||||||
struct IUOCallable {
|
struct IUOCallable {
|
||||||
static var callable: IUOCallable { IUOCallable() }
|
static var callable: IUOCallable { IUOCallable() }
|
||||||
func callAsFunction(_ x: Int) -> IUOCallable! { nil }
|
func callAsFunction(_ x: Int) -> IUOCallable! { nil }
|
||||||
@@ -235,12 +237,14 @@ func testAccessControl(_ x: PrivateCallable) {
|
|||||||
x(5) // expected-error {{'callAsFunction' is inaccessible due to 'private' protection level}}
|
x(5) // expected-error {{'callAsFunction' is inaccessible due to 'private' protection level}}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SR_11909 {
|
// https://github.com/apple/swift/issues/54327
|
||||||
static let s = SR_11909()
|
do {
|
||||||
func callAsFunction(_ x: Int = 0) -> SR_11909 { SR_11909() }
|
struct S {
|
||||||
}
|
static let s = S()
|
||||||
|
func callAsFunction(_ x: Int = 0) -> S {}
|
||||||
|
}
|
||||||
|
|
||||||
func testDefaultsWithUMEs(_ x: SR_11909) {
|
// Test default argument with 'UnresolvedMemberExpr'.
|
||||||
let _: SR_11909 = .s()
|
let _: S = .s()
|
||||||
let _: SR_11909 = .s(5)
|
let _: S = .s(5)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// RUN: %target-swift-frontend -emit-silgen -verify -primary-file %s %S/Inputs/circularity_multifile_error_helper.swift
|
// RUN: %target-swift-frontend -emit-silgen -verify -primary-file %s %S/Inputs/circularity_multifile_error_helper.swift
|
||||||
|
|
||||||
// SR-4594
|
// https://github.com/apple/swift/issues/47171
|
||||||
|
|
||||||
struct A {
|
struct A {
|
||||||
var b: AnUndefinedType // expected-error {{cannot find type 'AnUndefinedType' in scope}}
|
var b: AnUndefinedType // expected-error {{cannot find type 'AnUndefinedType' in scope}}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// RUN: %target-typecheck-verify-swift
|
// RUN: %target-typecheck-verify-swift
|
||||||
|
|
||||||
// SR-838:
|
// https://github.com/apple/swift/issues/43450
|
||||||
// expression test_seconds() was too complex to be solved in reasonable time
|
// Expression in 'test_seconds' was too complex to be solved in reasonable time
|
||||||
|
|
||||||
struct Nano : CustomStringConvertible {
|
struct Nano : CustomStringConvertible {
|
||||||
var value: Int64 = 0
|
var value: Int64 = 0
|
||||||
init(_ x: Int64) { self.value = x }
|
init(_ x: Int64) { self.value = x }
|
||||||
@@ -30,8 +31,8 @@ func test_seconds() {
|
|||||||
print((u_minute + u_second + Nano(500)) + " = " + (1.i + 1.s + 500.ns))
|
print((u_minute + u_second + Nano(500)) + " = " + (1.i + 1.s + 500.ns))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SR-2102:
|
// https://github.com/apple/swift/issues/44710:
|
||||||
// DictionaryExpr was too complex to be solved in reasonable time
|
// 'DictionaryExpr' was too complex to be solved in reasonable time
|
||||||
|
|
||||||
let M_PI: Double = 3.1415926535897931
|
let M_PI: Double = 3.1415926535897931
|
||||||
let M_E : Double = 2.7182818284590451
|
let M_E : Double = 2.7182818284590451
|
||||||
@@ -74,14 +75,16 @@ var operations: Dictionary<String, Operation> = [
|
|||||||
"=": .equals,
|
"=": .equals,
|
||||||
]
|
]
|
||||||
|
|
||||||
// SR-1794
|
// https://github.com/apple/swift/issues/44403
|
||||||
struct P {
|
do {
|
||||||
let x: Float
|
struct P {
|
||||||
let y: Float
|
let x: Float
|
||||||
}
|
let y: Float
|
||||||
|
}
|
||||||
|
|
||||||
func sr1794(pt: P, p0: P, p1: P) -> Bool {
|
func f(pt: P, p0: P, p1: P) -> Bool {
|
||||||
return (pt.x - p0.x) * (p1.y - p0.y) - (pt.y - p0.y) * (p1.x - p0.x) < 0.0
|
return (pt.x - p0.x) * (p1.y - p0.y) - (pt.y - p0.y) * (p1.x - p0.x) < 0.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests for partial contextual type application in sub-expressions
|
// Tests for partial contextual type application in sub-expressions
|
||||||
@@ -94,18 +97,18 @@ let v5 = ([1 + 2 + 3, 4] as [UInt32]) + ([2 * 3] as [UInt32])
|
|||||||
let v6 = [1 + 2 + 3, 4] as Set<UInt32>
|
let v6 = [1 + 2 + 3, 4] as Set<UInt32>
|
||||||
let v7: [UInt32] = [55 * 8, 0]
|
let v7: [UInt32] = [55 * 8, 0]
|
||||||
|
|
||||||
// SR-3668
|
// https://github.com/apple/swift/issues/46253
|
||||||
// "Expression was too complex" errors for short dictionary literals
|
// "Expression was too complex" errors for short dictionary literals
|
||||||
// of simple closure expressions
|
// of simple closure expressions
|
||||||
|
|
||||||
let sr3668Dict1: Dictionary<Int, (Int, Int) -> Bool> =
|
let _: Dictionary<Int, (Int, Int) -> Bool> =
|
||||||
[ 0: { $0 == $1 }, 1: { $0 == $1 }, 2: { $0 == $1 }, 3: { $0 == $1 },
|
[ 0: { $0 == $1 }, 1: { $0 == $1 }, 2: { $0 == $1 }, 3: { $0 == $1 },
|
||||||
4: { $0 == $1 }, 5: { $0 == $1 }, 6: { $0 == $1 }, 7: { $0 == $1 },
|
4: { $0 == $1 }, 5: { $0 == $1 }, 6: { $0 == $1 }, 7: { $0 == $1 },
|
||||||
8: { $0 == $1 }, 9: { $0 == $1 }, 10: { $0 == $1 }, 11: { $0 == $1 },
|
8: { $0 == $1 }, 9: { $0 == $1 }, 10: { $0 == $1 }, 11: { $0 == $1 },
|
||||||
12: { $0 == $1 }, 13: { $0 == $1 }, 14: { $0 == $1 }, 15: { $0 == $1 },
|
12: { $0 == $1 }, 13: { $0 == $1 }, 14: { $0 == $1 }, 15: { $0 == $1 },
|
||||||
16: { $0 == $1 }, 17: { $0 == $1 }, 18: { $0 == $1 }, 19: { $0 == $1 } ]
|
16: { $0 == $1 }, 17: { $0 == $1 }, 18: { $0 == $1 }, 19: { $0 == $1 } ]
|
||||||
|
|
||||||
let sr3668Dict2: [Int: (Int, Int) -> Bool] =
|
let _: [Int: (Int, Int) -> Bool] =
|
||||||
[ 0: { $0 != $1 }, 1: { $0 != $1 }, 2: { $0 != $1 }, 3: { $0 != $1 },
|
[ 0: { $0 != $1 }, 1: { $0 != $1 }, 2: { $0 != $1 }, 3: { $0 != $1 },
|
||||||
4: { $0 != $1 }, 5: { $0 != $1 }, 6: { $0 != $1 }, 7: { $0 != $1 },
|
4: { $0 != $1 }, 5: { $0 != $1 }, 6: { $0 != $1 }, 7: { $0 != $1 },
|
||||||
8: { $0 != $1 }, 9: { $0 != $1 }, 10: { $0 != $1 }, 11: { $0 != $1 },
|
8: { $0 != $1 }, 9: { $0 != $1 }, 10: { $0 != $1 }, 11: { $0 != $1 },
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
// RUN: %target-typecheck-verify-swift
|
// RUN: %target-typecheck-verify-swift
|
||||||
// RUN: %empty-directory(%t)
|
// RUN: %empty-directory(%t)
|
||||||
// RUN: %target-swift-frontend -primary-file %s %S/Inputs/composition_extension_usage.swift -emit-module-path %t/P-partial.swiftmodule -module-name SR11227 -enable-testing
|
// RUN: %target-swift-frontend -primary-file %s %S/Inputs/composition_extension_usage.swift -emit-module-path %t/P-partial.swiftmodule -module-name M -enable-testing
|
||||||
// RUN: %target-swift-frontend -primary-file %S/Inputs/composition_extension_usage.swift %s -emit-module-path %t/S-partial.swiftmodule -module-name SR11227 -enable-testing
|
// RUN: %target-swift-frontend -primary-file %S/Inputs/composition_extension_usage.swift %s -emit-module-path %t/S-partial.swiftmodule -module-name M -enable-testing
|
||||||
// RUN: %target-swift-frontend -merge-modules -emit-module %t/P-partial.swiftmodule %t/S-partial.swiftmodule -o %t/SR11227.swiftmodule
|
// RUN: %target-swift-frontend -merge-modules -emit-module %t/P-partial.swiftmodule %t/S-partial.swiftmodule -o %t/M.swiftmodule
|
||||||
|
|
||||||
|
// https://github.com/apple/swift/issues/53628
|
||||||
|
|
||||||
protocol P1 {}
|
protocol P1 {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// RUN: %target-typecheck-verify-swift -swift-version 4
|
// RUN: %target-typecheck-verify-swift -swift-version 4
|
||||||
|
|
||||||
//=-------------- SR-7295 --------------=/
|
// https://github.com/apple/swift/issues/49843
|
||||||
class sr7295 {
|
class C_49843 {
|
||||||
func doSomething(a: (() -> Void)? = nil, completion: @escaping ((String, Error?) -> Void)) {}
|
func doSomething(a: (() -> Void)? = nil, completion: @escaping ((String, Error?) -> Void)) {}
|
||||||
func doSomething(b: @escaping ((String, Error?, Bool) -> Void)) {}
|
func doSomething(b: @escaping ((String, Error?, Bool) -> Void)) {}
|
||||||
func a() {
|
func a() {
|
||||||
|
|||||||
@@ -8,14 +8,17 @@ if (x > y) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sr7307(_ value: Bool) {
|
// https://github.com/apple/swift/issues/49855
|
||||||
let negated = !value
|
do {
|
||||||
defer { // expected-warning {{'defer' statement at end of scope always executes immediately}}{{5-10=do}}
|
func f(_ value: Bool) {
|
||||||
print("negated value is \(negated)")
|
let negated = !value
|
||||||
}
|
defer { // expected-warning {{'defer' statement at end of scope always executes immediately}}{{7-12=do}}
|
||||||
}
|
print("negated value is \(negated)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sr7307(true)
|
f(true)
|
||||||
|
}
|
||||||
|
|
||||||
defer { // No note
|
defer { // No note
|
||||||
print("end of program.")
|
print("end of program.")
|
||||||
|
|||||||
@@ -1,26 +1,25 @@
|
|||||||
// RUN: %target-typecheck-verify-swift
|
// RUN: %target-typecheck-verify-swift
|
||||||
|
|
||||||
enum Key: Int {
|
// https://github.com/apple/swift/issues/48727
|
||||||
case aKey
|
do {
|
||||||
case anotherKey // expected-note {{'anotherKey' declared here}}
|
enum Key: Int {
|
||||||
}
|
case aKey
|
||||||
|
case anotherKey // expected-note {{'anotherKey' declared here}}
|
||||||
class sr6175 {
|
|
||||||
var dict: [Key: String] = [:]
|
|
||||||
func what() -> Void {
|
|
||||||
dict[.notAKey] = "something" // expected-error {{type 'Key' has no member 'notAKey'; did you mean 'anotherKey'?}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subscript(i: Int) -> Int {
|
|
||||||
return i*i
|
|
||||||
}
|
|
||||||
subscript(j: Double) -> Double {
|
|
||||||
get { return j*j }
|
|
||||||
set {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let s = sr6175()
|
class C {
|
||||||
let one: Int = 1
|
var dict: [Key: String] = [:]
|
||||||
// Should choose the settable subscript to find a problem with, not the get-only subscript
|
func what() -> Void {
|
||||||
s[one] = 2.5 // expected-error {{cannot convert value of type 'Int' to expected argument type 'Double'}}
|
dict[.notAKey] = "something" // expected-error {{type 'Key' has no member 'notAKey'; did you mean 'anotherKey'?}}
|
||||||
|
}
|
||||||
|
|
||||||
|
subscript(i: Int) -> Int { get {} }
|
||||||
|
|
||||||
|
subscript(j: Double) -> Double { get {} set {} }
|
||||||
|
}
|
||||||
|
|
||||||
|
let c = C()
|
||||||
|
let one: Int = 1
|
||||||
|
// Should choose the settable subscript to find a problem with, not the get-only subscript
|
||||||
|
c[one] = 2.5 // expected-error {{cannot convert value of type 'Int' to expected argument type 'Double'}}
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ takesOptMutableRaw(&arr) // expected-error {{cannot use inout expression here; a
|
|||||||
// expected-note@-1 {{implicit argument conversion from '[Int8]' to 'UnsafeMutableRawPointer?' produces a pointer valid only for the duration of the call to 'takesOptMutableRaw'}}
|
// expected-note@-1 {{implicit argument conversion from '[Int8]' to 'UnsafeMutableRawPointer?' produces a pointer valid only for the duration of the call to 'takesOptMutableRaw'}}
|
||||||
// expected-note@-2 {{use the 'withUnsafeMutableBytes' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope}}
|
// expected-note@-2 {{use the 'withUnsafeMutableBytes' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope}}
|
||||||
|
|
||||||
// FIXME(SR-9100): This currently uses inout-to-pointer instead of array-to-pointer.
|
// FIXME: This currently uses inout-to-pointer instead of array-to-pointer
|
||||||
|
// (https://github.com/apple/swift/issues/51597).
|
||||||
takesOptMutableRaw(&optionalArr)
|
takesOptMutableRaw(&optionalArr)
|
||||||
|
|
||||||
takesOptConst(arr) // expected-error {{cannot pass '[Int8]' to parameter; argument #1 must be a pointer that outlives the call to 'takesOptConst'}}
|
takesOptConst(arr) // expected-error {{cannot pass '[Int8]' to parameter; argument #1 must be a pointer that outlives the call to 'takesOptConst'}}
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ takesOptMutableRaw(&arr) // expected-warning {{cannot use inout expression here;
|
|||||||
// expected-note@-1 {{implicit argument conversion from '[Int8]' to 'UnsafeMutableRawPointer?' produces a pointer valid only for the duration of the call to 'takesOptMutableRaw'}}
|
// expected-note@-1 {{implicit argument conversion from '[Int8]' to 'UnsafeMutableRawPointer?' produces a pointer valid only for the duration of the call to 'takesOptMutableRaw'}}
|
||||||
// expected-note@-2 {{use the 'withUnsafeMutableBytes' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope}}
|
// expected-note@-2 {{use the 'withUnsafeMutableBytes' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope}}
|
||||||
|
|
||||||
// FIXME(SR-9100): This currently uses inout-to-pointer instead of array-to-pointer.
|
// FIXME: This currently uses inout-to-pointer instead of array-to-pointer
|
||||||
|
// (https://github.com/apple/swift/issues/51597).
|
||||||
takesOptMutableRaw(&optionalArr)
|
takesOptMutableRaw(&optionalArr)
|
||||||
|
|
||||||
takesOptConst(arr) // expected-warning {{cannot pass '[Int8]' to parameter; argument #1 must be a pointer that outlives the call to 'takesOptConst'}}
|
takesOptConst(arr) // expected-warning {{cannot pass '[Int8]' to parameter; argument #1 must be a pointer that outlives the call to 'takesOptConst'}}
|
||||||
|
|||||||
@@ -73,15 +73,17 @@ _ = p =*= &o
|
|||||||
func rdar25963182(_ bytes: [UInt8] = nil) {}
|
func rdar25963182(_ bytes: [UInt8] = nil) {}
|
||||||
// expected-error@-1 {{nil default argument value cannot be converted to type}}
|
// expected-error@-1 {{nil default argument value cannot be converted to type}}
|
||||||
|
|
||||||
// SR-13262
|
// https://github.com/apple/swift/issues/55702
|
||||||
struct SR13262_S {}
|
do {
|
||||||
|
struct S {}
|
||||||
|
|
||||||
func SR13262(_ x: Int) {}
|
func returnVoid(_ x: Int) {}
|
||||||
func SR13262_Int(_ x: Int) -> Int { 0 }
|
func returnInt(_ x: Int) -> Int {}
|
||||||
func SR13262_SF(_ x: Int) -> SR13262_S { SR13262_S() }
|
func returnS(_ x: Int) -> S {}
|
||||||
|
|
||||||
func testSR13262(_ arr: [Int]) {
|
let arr: [Int]
|
||||||
for x in arr where SR13262(x) {} // expected-error {{cannot convert value of type '()' to expected condition type 'Bool'}}
|
|
||||||
for x in arr where SR13262_Int(x) {} // expected-error {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}} {{22-22=(}} {{36-36= != 0)}}
|
for x in arr where returnVoid(x) {} // expected-error {{cannot convert value of type '()' to expected condition type 'Bool'}}
|
||||||
for x in arr where SR13262_SF(x) {} // expected-error {{cannot convert value of type 'SR13262_S' to expected condition type 'Bool'}}
|
for x in arr where returnInt(x) {} // expected-error {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}} {{22-22=(}} {{34-34= != 0)}}
|
||||||
|
for x in arr where returnS(x) {} // expected-error {{cannot convert value of type 'S' to expected condition type 'Bool'}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,10 +104,13 @@ func warnCollectionOfIUOToAnyCoercion(_ a: Int!) { // expected-note 2{{implicitl
|
|||||||
// expected-note@-7 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{40-40= as Any}}
|
// expected-note@-7 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{40-40= as Any}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func takesAny_sr10199(_ x: Any) {}
|
// https://github.com/apple/swift/issues/52599
|
||||||
|
do {
|
||||||
|
func takesAny(_ x: Any) {}
|
||||||
|
|
||||||
let fn_sr10199: (() -> Int?)! = { return nil }
|
let fn: (() -> Int?)! = { return nil }
|
||||||
takesAny_sr10199(fn_sr10199()) // expected-warning {{expression implicitly coerced from 'Int?' to 'Any'}}
|
takesAny(fn()) // expected-warning {{expression implicitly coerced from 'Int?' to 'Any'}}
|
||||||
// expected-note@-1 {{provide a default value to avoid this warning}}
|
// expected-note@-1 {{provide a default value to avoid this warning}}
|
||||||
// expected-note@-2 {{force-unwrap the value to avoid this warning}}
|
// expected-note@-2 {{force-unwrap the value to avoid this warning}}
|
||||||
// expected-note@-3 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}
|
// expected-note@-3 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// RUN: %target-typecheck-verify-swift
|
// RUN: %target-typecheck-verify-swift
|
||||||
|
|
||||||
// SR-5163
|
// https://github.com/apple/swift/issues/47739
|
||||||
func sr5163() {
|
do {
|
||||||
func foo(_ x: Int) -> Int? { return 1 }
|
func foo(_ x: Int) -> Int? { return 1 }
|
||||||
|
|
||||||
func fn() {
|
func fn() {
|
||||||
@@ -11,17 +11,18 @@ func sr5163() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SR-6726
|
// https://github.com/apple/swift/issues/49275
|
||||||
|
|
||||||
var foo: Int?
|
var foo: Int?
|
||||||
|
|
||||||
func test() {
|
test: do {
|
||||||
guard let bar = foo else {
|
guard let bar = foo else {
|
||||||
return
|
break test
|
||||||
}
|
}
|
||||||
let foo = String(bar) // expected-warning {{initialization of immutable value 'foo' was never used; consider replacing with assignment to '_' or removing it}}
|
let foo = String(bar) // expected-warning {{initialization of immutable value 'foo' was never used; consider replacing with assignment to '_' or removing it}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SR-7660
|
// https://github.com/apple/swift/issues/50200
|
||||||
class C {
|
class C {
|
||||||
var variable: Int?
|
var variable: Int?
|
||||||
func f() {
|
func f() {
|
||||||
@@ -30,16 +31,16 @@ class C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SR-7517
|
// https://github.com/apple/swift/issues/50059
|
||||||
func testExample() {
|
do {
|
||||||
let app = app2 // expected-error {{use of local variable 'app2' before its declaration}}
|
let app = app2 // expected-error {{use of local variable 'app2' before its declaration}}
|
||||||
let app2 = app // expected-note {{'app2' declared here}}
|
let app2 = app // expected-note {{'app2' declared here}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SR-8447
|
// https://github.com/apple/swift/issues/50968
|
||||||
func test_circular() {
|
func test_circular() {
|
||||||
let obj = sr8447 // expected-error {{use of local variable 'sr8447' before its declaration}}
|
let obj = x // expected-error {{use of local variable 'x' before its declaration}}
|
||||||
let _ = obj.prop, sr8447 // expected-note {{'sr8447' declared here}} expected-error {{type annotation missing in pattern}}
|
let _ = obj.prop, x // expected-note {{'x' declared here}} expected-error {{type annotation missing in pattern}}
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|||||||
@@ -641,7 +641,8 @@ func f(a : FooClass, b : LetStructMembers) {
|
|||||||
b.f = 42 // expected-error {{cannot assign to value: 'f' is a method}}
|
b.f = 42 // expected-error {{cannot assign to value: 'f' is a method}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SR-2354: Reject subscript declarations with mutable parameters.
|
// https://github.com/apple/swift/issues/44961
|
||||||
|
// Reject subscript declarations with mutable parameters.
|
||||||
class MutableSubscripts {
|
class MutableSubscripts {
|
||||||
var x : Int = 0
|
var x : Int = 0
|
||||||
|
|
||||||
@@ -656,9 +657,10 @@ class MutableSubscripts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SR-4214: Misleading location-less diagnostic when closure parameter type
|
// https://github.com/apple/swift/issues/46797
|
||||||
// is inferred to be inout.
|
// Misleading location-less diagnostic when closure parameter type is inferred
|
||||||
func sr4214() {
|
// to be 'inout'.
|
||||||
|
do {
|
||||||
func sequence<T>(_ x : T, _ f : (T) -> T) -> T {
|
func sequence<T>(_ x : T, _ f : (T) -> T) -> T {
|
||||||
return f(x)
|
return f(x)
|
||||||
}
|
}
|
||||||
@@ -718,14 +720,16 @@ struct S {
|
|||||||
|
|
||||||
struct Nested {
|
struct Nested {
|
||||||
func foo() {
|
func foo() {
|
||||||
// SR-11786: Make sure we don't offer the 'self.' fix-it here.
|
// https://github.com/apple/swift/issues/54196
|
||||||
|
// Make sure we don't offer the 'self.' fix-it here.
|
||||||
let x = 0 // expected-note {{change 'let' to 'var' to make it mutable}}
|
let x = 0 // expected-note {{change 'let' to 'var' to make it mutable}}
|
||||||
x += 1 // expected-error {{left side of mutating operator isn't mutable: 'x' is a 'let' constant}}
|
x += 1 // expected-error {{left side of mutating operator isn't mutable: 'x' is a 'let' constant}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func bar() {
|
func bar() {
|
||||||
// SR-11787: Make sure we insert "self." in the right location.
|
// https://github.com/apple/swift/issues/54197
|
||||||
|
// Make sure we insert 'self.' in the right location.
|
||||||
let x = 0 // expected-note 3{{change 'let' to 'var' to make it mutable}}
|
let x = 0 // expected-note 3{{change 'let' to 'var' to make it mutable}}
|
||||||
x += 1 // expected-error {{left side of mutating operator isn't mutable: 'x' is a 'let' constant}}
|
x += 1 // expected-error {{left side of mutating operator isn't mutable: 'x' is a 'let' constant}}
|
||||||
// expected-note@-1 {{add explicit 'self.' to refer to mutable property of 'S'}} {{5-5=self.}}
|
// expected-note@-1 {{add explicit 'self.' to refer to mutable property of 'S'}} {{5-5=self.}}
|
||||||
@@ -736,7 +740,8 @@ struct S {
|
|||||||
x = 1 // expected-error {{cannot assign to value: 'x' is a 'let' constant}}
|
x = 1 // expected-error {{cannot assign to value: 'x' is a 'let' constant}}
|
||||||
// expected-note@-1 {{add explicit 'self.' to refer to mutable property of 'S'}} {{5-5=self.}}
|
// expected-note@-1 {{add explicit 'self.' to refer to mutable property of 'S'}} {{5-5=self.}}
|
||||||
|
|
||||||
// SR-11788: Insert "Type." for a static property.
|
// https://github.com/apple/swift/issues/54198
|
||||||
|
// Insert 'Type.' for a static property.
|
||||||
let y = 0 // expected-note {{change 'let' to 'var' to make it mutable}}
|
let y = 0 // expected-note {{change 'let' to 'var' to make it mutable}}
|
||||||
y += 1 // expected-error {{left side of mutating operator isn't mutable: 'y' is a 'let' constant}}
|
y += 1 // expected-error {{left side of mutating operator isn't mutable: 'y' is a 'let' constant}}
|
||||||
// expected-note@-1 {{add explicit 'S.' to refer to mutable static property of 'S'}} {{5-5=S.}}
|
// expected-note@-1 {{add explicit 'S.' to refer to mutable static property of 'S'}} {{5-5=S.}}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// RUN: %target-swift-frontend -typecheck -verify -primary-file %s
|
// RUN: %target-swift-frontend -typecheck -verify -primary-file %s
|
||||||
// [SR-12745]
|
|
||||||
// rdar://problem/62957095
|
// rdar://problem/62957095
|
||||||
|
// https://github.com/apple/swift/issues/55190
|
||||||
|
|
||||||
struct S1 {
|
struct S1 {
|
||||||
var x : Int = 0
|
var x : Int = 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,10 @@ struct TestInitSubscript {
|
|||||||
var color: Color
|
var color: Color
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/apple/swift/issues/58201
|
||||||
|
|
||||||
@propertyWrapper
|
@propertyWrapper
|
||||||
public class SR_15940Bar<Value> {
|
public class W_58201<Value> {
|
||||||
private var _value: Value
|
private var _value: Value
|
||||||
|
|
||||||
public var wrappedValue: Value {
|
public var wrappedValue: Value {
|
||||||
@@ -64,20 +66,20 @@ public class SR_15940Bar<Value> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECK-LABEL: struct_decl{{.*}}SR_15940_A
|
// CHECK-LABEL: struct_decl{{.*}}S1_58201
|
||||||
struct SR_15940_A {
|
struct S1_58201 {
|
||||||
// CHECK: argument_list implicit labels=wrappedValue:
|
// CHECK: argument_list implicit labels=wrappedValue:
|
||||||
// CHECK-NEXT: argument label=wrappedValue
|
// CHECK-NEXT: argument label=wrappedValue
|
||||||
// CHECK-NEXT: autoclosure_expr implicit type='() -> Bool?' discriminator=0 captures=(<opaque_value> ) escaping
|
// CHECK-NEXT: autoclosure_expr implicit type='() -> Bool?' discriminator=0 captures=(<opaque_value> ) escaping
|
||||||
// CHECK: autoclosure_expr implicit type='() -> Bool?' discriminator=1 escaping
|
// CHECK: autoclosure_expr implicit type='() -> Bool?' discriminator=1 escaping
|
||||||
@SR_15940Bar var a: Bool?
|
@W_58201 var a: Bool?
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECK-LABEL: struct_decl{{.*}}SR_15940_B
|
// CHECK-LABEL: struct_decl{{.*}}S2_58201
|
||||||
struct SR_15940_B {
|
struct S2_58201 {
|
||||||
// CHECK: argument_list implicit labels=wrappedValue:
|
// CHECK: argument_list implicit labels=wrappedValue:
|
||||||
// CHECK-NEXT: argument label=wrappedValue
|
// CHECK-NEXT: argument label=wrappedValue
|
||||||
// CHECK-NEXT: autoclosure_expr implicit type='() -> Bool' location={{.*}}.swift:[[@LINE+2]]:30 range=[{{.+}}] discriminator=0 captures=(<opaque_value> ) escaping
|
// CHECK-NEXT: autoclosure_expr implicit type='() -> Bool' location={{.*}}.swift:[[@LINE+2]]:26 range=[{{.+}}] discriminator=0 captures=(<opaque_value> ) escaping
|
||||||
// CHECK: autoclosure_expr implicit type='() -> Bool' location={{.*}}.swift:[[@LINE+1]]:30 range=[{{.+}}] discriminator=1 escaping
|
// CHECK: autoclosure_expr implicit type='() -> Bool' location={{.*}}.swift:[[@LINE+1]]:26 range=[{{.+}}] discriminator=1 escaping
|
||||||
@SR_15940Bar var b: Bool = false
|
@W_58201 var b: Bool = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
// RUN: %target-typecheck-verify-swift
|
// RUN: %target-typecheck-verify-swift
|
||||||
|
|
||||||
// SR-1062:
|
protocol EmptyProtocol {}
|
||||||
|
struct EmptyStruct {}
|
||||||
|
|
||||||
|
// https://github.com/apple/swift/issues/43674
|
||||||
// Coercion in single expression closure with invalid signature caused segfault
|
// Coercion in single expression closure with invalid signature caused segfault
|
||||||
protocol SR_1062_EmptyProtocol {}
|
do {
|
||||||
|
struct G<T: EmptyProtocol> {}
|
||||||
|
|
||||||
struct SR_1062_EmptyStruct {}
|
let _ = { (_: G<EmptyStruct>) -> Void in // expected-error{{type 'EmptyStruct' does not conform to protocol 'EmptyProtocol'}}
|
||||||
struct SR_1062_GenericStruct<T: SR_1062_EmptyProtocol> {}
|
EmptyStruct() as EmptyStruct
|
||||||
|
}
|
||||||
let _ = { (_: SR_1062_GenericStruct<SR_1062_EmptyStruct>) -> Void in // expected-error{{type 'SR_1062_EmptyStruct' does not conform to protocol 'SR_1062_EmptyProtocol'}}
|
|
||||||
SR_1062_EmptyStruct() as SR_1062_EmptyStruct
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ class C0 {
|
|||||||
// Check diagnostics changes.
|
// Check diagnostics changes.
|
||||||
let _ = min(Int(3), Float(2.5)) // expected-error{{conflicting arguments to generic parameter 'T' ('Int' vs. 'Float')}}
|
let _ = min(Int(3), Float(2.5)) // expected-error{{conflicting arguments to generic parameter 'T' ('Int' vs. 'Float')}}
|
||||||
|
|
||||||
// SR-11429
|
// https://github.com/apple/swift/issues/53830
|
||||||
func testIntermediateCoercions() {
|
func testIntermediateCoercions() {
|
||||||
_ = (f1 as (Int, Int) -> Int)(a: 0, b: 1) // expected-error {{extraneous argument labels 'a:b:' in call}}
|
_ = (f1 as (Int, Int) -> Int)(a: 0, b: 1) // expected-error {{extraneous argument labels 'a:b:' in call}}
|
||||||
_ = (f1 as (Int, Int) -> Int)(0, 1)
|
_ = (f1 as (Int, Int) -> Int)(0, 1)
|
||||||
|
|||||||
@@ -169,7 +169,9 @@ class CircularValidationWithTypo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crash with invalid extension that has not been bound -- https://bugs.swift.org/browse/SR-8984
|
// https://github.com/apple/swift/issues/51488
|
||||||
|
// Crash with invalid extension that has not been bound
|
||||||
|
|
||||||
protocol PP {}
|
protocol PP {}
|
||||||
|
|
||||||
func boo() {
|
func boo() {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// RUN: %target-swift-frontend -emit-module -o %t/ModuleA.swiftmodule %S/Inputs/where_clause_across_module_boundaries_module.swift
|
// RUN: %target-swift-frontend -emit-module -o %t/ModuleA.swiftmodule %S/Inputs/where_clause_across_module_boundaries_module.swift
|
||||||
// RUN: %target-typecheck-verify-swift -I %t
|
// RUN: %target-typecheck-verify-swift -I %t
|
||||||
|
|
||||||
// SR-15807:
|
// https://github.com/apple/swift/issues/58084
|
||||||
// Associated Type Inference fails across module boundaries
|
// Associated Type Inference fails across module boundaries
|
||||||
// Self bounds from where clause cannot be accessed across modules.
|
// Self bounds from where clause cannot be accessed across modules.
|
||||||
// This test is intended to test whether it can use generic signature to get self bounds.
|
// This test is intended to test whether it can use generic signature to get self bounds.
|
||||||
|
|||||||
Reference in New Issue
Block a user