Skip to content

Commit d98a761

Browse files
committed
Gardening: Migrate test suite to GH issues: Sema (1/2)
1 parent 5534019 commit d98a761

21 files changed

+152
-118
lines changed

test/Sema/accessibility_private.swift

+5-4
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,14 @@ extension Container {
207207
fileprivate class PrivateGenericUser<T> where T: PrivateInnerClass {} // expected-error {{generic class cannot be declared fileprivate because its generic requirement uses a private type}} {{none}}
208208
}
209209

210-
fileprivate struct SR2579 {
210+
// https://github.com/apple/swift/issues/45184
211+
fileprivate struct C_45184 {
211212
private struct Inner {
212213
private struct InnerPrivateType {}
213-
var innerProperty = InnerPrivateType() // expected-error {{property must be declared private because its type 'SR2579.Inner.InnerPrivateType' uses a private type}}
214+
var innerProperty = InnerPrivateType() // expected-error {{property must be declared private because its type 'C_45184.Inner.InnerPrivateType' uses a private type}}
214215
}
215216
// FIXME: We need better errors when one access violation results in more
216217
// downstream.
217-
private var outerProperty = Inner().innerProperty // expected-error {{property cannot be declared in this context because its type 'SR2579.Inner.InnerPrivateType' uses a private type}}
218-
var outerProperty2 = Inner().innerProperty // expected-error {{property must be declared private because its type 'SR2579.Inner.InnerPrivateType' uses a private type}}
218+
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}}
219+
var outerProperty2 = Inner().innerProperty // expected-error {{property must be declared private because its type 'C_45184.Inner.InnerPrivateType' uses a private type}}
219220
}

test/Sema/call_as_function_generic.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ _ = genericString("Hello")
4242
let genericInt = GenericType<Set<Int>>(collection: [1, 2, 3])
4343
_ = genericInt(initialValue: 1)
4444

45-
// SR-11386
45+
// https://github.com/apple/swift/issues/53787
46+
4647
class C<T> {}
4748
protocol P1 {}
4849
extension C where T : P1 { // expected-note {{where 'T' = 'Int'}}

test/Sema/call_as_function_simple.swift

+13-9
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ func testIUO(a: SimpleCallable!, b: MultipleArgsCallable!, c: Extended!,
199199
_ = try? h { throw DummyError() }
200200
}
201201

202-
// SR-11778
202+
// https://github.com/apple/swift/issues/54185
203+
203204
struct DoubleANumber {
204205
func callAsFunction(_ x: Int, completion: (Int) -> Void = { _ in }) {
205206
completion(x + x)
@@ -211,7 +212,8 @@ func testDefaults(_ x: DoubleANumber) {
211212
x(5, completion: { _ in })
212213
}
213214

214-
// SR-11881
215+
// https://github.com/apple/swift/issues/54296
216+
215217
struct IUOCallable {
216218
static var callable: IUOCallable { IUOCallable() }
217219
func callAsFunction(_ x: Int) -> IUOCallable! { nil }
@@ -235,12 +237,14 @@ func testAccessControl(_ x: PrivateCallable) {
235237
x(5) // expected-error {{'callAsFunction' is inaccessible due to 'private' protection level}}
236238
}
237239

238-
struct SR_11909 {
239-
static let s = SR_11909()
240-
func callAsFunction(_ x: Int = 0) -> SR_11909 { SR_11909() }
241-
}
240+
// https://github.com/apple/swift/issues/54327
241+
do {
242+
struct S {
243+
static let s = S()
244+
func callAsFunction(_ x: Int = 0) -> S {}
245+
}
242246

243-
func testDefaultsWithUMEs(_ x: SR_11909) {
244-
let _: SR_11909 = .s()
245-
let _: SR_11909 = .s(5)
247+
// Test default argument with 'UnresolvedMemberExpr'.
248+
let _: S = .s()
249+
let _: S = .s(5)
246250
}

test/Sema/circularity_multifile_error.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %target-swift-frontend -emit-silgen -verify -primary-file %s %S/Inputs/circularity_multifile_error_helper.swift
22

3-
// SR-4594
3+
// https://github.com/apple/swift/issues/47171
44

55
struct A {
66
var b: AnUndefinedType // expected-error {{cannot find type 'AnUndefinedType' in scope}}

test/Sema/complex_expressions.swift

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// RUN: %target-typecheck-verify-swift
22

3-
// SR-838:
4-
// expression test_seconds() was too complex to be solved in reasonable time
3+
// https://github.com/apple/swift/issues/43450
4+
// Expression in 'test_seconds' was too complex to be solved in reasonable time
5+
56
struct Nano : CustomStringConvertible {
67
var value: Int64 = 0
78
init(_ x: Int64) { self.value = x }
@@ -30,8 +31,8 @@ func test_seconds() {
3031
print((u_minute + u_second + Nano(500)) + " = " + (1.i + 1.s + 500.ns))
3132
}
3233

33-
// SR-2102:
34-
// DictionaryExpr was too complex to be solved in reasonable time
34+
// https://github.com/apple/swift/issues/44710:
35+
// 'DictionaryExpr' was too complex to be solved in reasonable time
3536

3637
let M_PI: Double = 3.1415926535897931
3738
let M_E : Double = 2.7182818284590451
@@ -74,14 +75,16 @@ var operations: Dictionary<String, Operation> = [
7475
"=": .equals,
7576
]
7677

77-
// SR-1794
78-
struct P {
79-
let x: Float
80-
let y: Float
81-
}
78+
// https://github.com/apple/swift/issues/44403
79+
do {
80+
struct P {
81+
let x: Float
82+
let y: Float
83+
}
8284

83-
func sr1794(pt: P, p0: P, p1: P) -> Bool {
84-
return (pt.x - p0.x) * (p1.y - p0.y) - (pt.y - p0.y) * (p1.x - p0.x) < 0.0
85+
func f(pt: P, p0: P, p1: P) -> Bool {
86+
return (pt.x - p0.x) * (p1.y - p0.y) - (pt.y - p0.y) * (p1.x - p0.x) < 0.0
87+
}
8588
}
8689

8790
// 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])
9497
let v6 = [1 + 2 + 3, 4] as Set<UInt32>
9598
let v7: [UInt32] = [55 * 8, 0]
9699

97-
// SR-3668
100+
// https://github.com/apple/swift/issues/46253
98101
// "Expression was too complex" errors for short dictionary literals
99102
// of simple closure expressions
100103

101-
let sr3668Dict1: Dictionary<Int, (Int, Int) -> Bool> =
104+
let _: Dictionary<Int, (Int, Int) -> Bool> =
102105
[ 0: { $0 == $1 }, 1: { $0 == $1 }, 2: { $0 == $1 }, 3: { $0 == $1 },
103106
4: { $0 == $1 }, 5: { $0 == $1 }, 6: { $0 == $1 }, 7: { $0 == $1 },
104107
8: { $0 == $1 }, 9: { $0 == $1 }, 10: { $0 == $1 }, 11: { $0 == $1 },
105108
12: { $0 == $1 }, 13: { $0 == $1 }, 14: { $0 == $1 }, 15: { $0 == $1 },
106109
16: { $0 == $1 }, 17: { $0 == $1 }, 18: { $0 == $1 }, 19: { $0 == $1 } ]
107110

108-
let sr3668Dict2: [Int: (Int, Int) -> Bool] =
111+
let _: [Int: (Int, Int) -> Bool] =
109112
[ 0: { $0 != $1 }, 1: { $0 != $1 }, 2: { $0 != $1 }, 3: { $0 != $1 },
110113
4: { $0 != $1 }, 5: { $0 != $1 }, 6: { $0 != $1 }, 7: { $0 != $1 },
111114
8: { $0 != $1 }, 9: { $0 != $1 }, 10: { $0 != $1 }, 11: { $0 != $1 },

test/Sema/composition_extension.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// RUN: %target-typecheck-verify-swift
22
// RUN: %empty-directory(%t)
3-
// 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
4-
// 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
5-
// RUN: %target-swift-frontend -merge-modules -emit-module %t/P-partial.swiftmodule %t/S-partial.swiftmodule -o %t/SR11227.swiftmodule
3+
// 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
4+
// 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
5+
// RUN: %target-swift-frontend -merge-modules -emit-module %t/P-partial.swiftmodule %t/S-partial.swiftmodule -o %t/M.swiftmodule
6+
7+
// https://github.com/apple/swift/issues/53628
68

79
protocol P1 {}
810

test/Sema/diag_ambiguous_overloads_swift4.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-typecheck-verify-swift -swift-version 4
22

3-
//=-------------- SR-7295 --------------=/
4-
class sr7295 {
3+
// https://github.com/apple/swift/issues/49843
4+
class C_49843 {
55
func doSomething(a: (() -> Void)? = nil, completion: @escaping ((String, Error?) -> Void)) {}
66
func doSomething(b: @escaping ((String, Error?, Bool) -> Void)) {}
77
func a() {

test/Sema/diag_defer_block_end.swift

+10-7
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ if (x > y) {
88
}
99
}
1010

11-
func sr7307(_ value: Bool) {
12-
let negated = !value
13-
defer { // expected-warning {{'defer' statement at end of scope always executes immediately}}{{5-10=do}}
14-
print("negated value is \(negated)")
15-
}
16-
}
11+
// https://github.com/apple/swift/issues/49855
12+
do {
13+
func f(_ value: Bool) {
14+
let negated = !value
15+
defer { // expected-warning {{'defer' statement at end of scope always executes immediately}}{{7-12=do}}
16+
print("negated value is \(negated)")
17+
}
18+
}
1719

18-
sr7307(true)
20+
f(true)
21+
}
1922

2023
defer { // No note
2124
print("end of program.")
+20-21
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
// RUN: %target-typecheck-verify-swift
22

3-
enum Key: Int {
4-
case aKey
5-
case anotherKey // expected-note {{'anotherKey' declared here}}
6-
}
7-
8-
class sr6175 {
9-
var dict: [Key: String] = [:]
10-
func what() -> Void {
11-
dict[.notAKey] = "something" // expected-error {{type 'Key' has no member 'notAKey'; did you mean 'anotherKey'?}}
12-
}
13-
14-
subscript(i: Int) -> Int {
15-
return i*i
3+
// https://github.com/apple/swift/issues/48727
4+
do {
5+
enum Key: Int {
6+
case aKey
7+
case anotherKey // expected-note {{'anotherKey' declared here}}
168
}
17-
subscript(j: Double) -> Double {
18-
get { return j*j }
19-
set {}
9+
10+
class C {
11+
var dict: [Key: String] = [:]
12+
func what() -> Void {
13+
dict[.notAKey] = "something" // expected-error {{type 'Key' has no member 'notAKey'; did you mean 'anotherKey'?}}
14+
}
15+
16+
subscript(i: Int) -> Int { get {} }
17+
18+
subscript(j: Double) -> Double { get {} set {} }
2019
}
21-
}
2220

23-
let s = sr6175()
24-
let one: Int = 1
25-
// Should choose the settable subscript to find a problem with, not the get-only subscript
26-
s[one] = 2.5 // expected-error {{cannot convert value of type 'Int' to expected argument type 'Double'}}
21+
let c = C()
22+
let one: Int = 1
23+
// Should choose the settable subscript to find a problem with, not the get-only subscript
24+
c[one] = 2.5 // expected-error {{cannot convert value of type 'Int' to expected argument type 'Double'}}
25+
}

test/Sema/diag_non_ephemeral.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ takesOptMutableRaw(&arr) // expected-error {{cannot use inout expression here; a
4747
// expected-note@-1 {{implicit argument conversion from '[Int8]' to 'UnsafeMutableRawPointer?' produces a pointer valid only for the duration of the call to 'takesOptMutableRaw'}}
4848
// expected-note@-2 {{use the 'withUnsafeMutableBytes' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope}}
4949

50-
// FIXME(SR-9100): This currently uses inout-to-pointer instead of array-to-pointer.
50+
// FIXME: This currently uses inout-to-pointer instead of array-to-pointer
51+
// (https://github.com/apple/swift/issues/51597).
5152
takesOptMutableRaw(&optionalArr)
5253

5354
takesOptConst(arr) // expected-error {{cannot pass '[Int8]' to parameter; argument #1 must be a pointer that outlives the call to 'takesOptConst'}}

test/Sema/diag_non_ephemeral_warning.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ takesOptMutableRaw(&arr) // expected-warning {{cannot use inout expression here;
4747
// expected-note@-1 {{implicit argument conversion from '[Int8]' to 'UnsafeMutableRawPointer?' produces a pointer valid only for the duration of the call to 'takesOptMutableRaw'}}
4848
// expected-note@-2 {{use the 'withUnsafeMutableBytes' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope}}
4949

50-
// FIXME(SR-9100): This currently uses inout-to-pointer instead of array-to-pointer.
50+
// FIXME: This currently uses inout-to-pointer instead of array-to-pointer
51+
// (https://github.com/apple/swift/issues/51597).
5152
takesOptMutableRaw(&optionalArr)
5253

5354
takesOptConst(arr) // expected-warning {{cannot pass '[Int8]' to parameter; argument #1 must be a pointer that outlives the call to 'takesOptConst'}}

test/Sema/diag_type_conversion.swift

+11-9
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,17 @@ _ = p =*= &o
7373
func rdar25963182(_ bytes: [UInt8] = nil) {}
7474
// expected-error@-1 {{nil default argument value cannot be converted to type}}
7575

76-
// SR-13262
77-
struct SR13262_S {}
76+
// https://github.com/apple/swift/issues/55702
77+
do {
78+
struct S {}
7879

79-
func SR13262(_ x: Int) {}
80-
func SR13262_Int(_ x: Int) -> Int { 0 }
81-
func SR13262_SF(_ x: Int) -> SR13262_S { SR13262_S() }
80+
func returnVoid(_ x: Int) {}
81+
func returnInt(_ x: Int) -> Int {}
82+
func returnS(_ x: Int) -> S {}
8283

83-
func testSR13262(_ arr: [Int]) {
84-
for x in arr where SR13262(x) {} // expected-error {{cannot convert value of type '()' to expected condition type 'Bool'}}
85-
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)}}
86-
for x in arr where SR13262_SF(x) {} // expected-error {{cannot convert value of type 'SR13262_S' to expected condition type 'Bool'}}
84+
let arr: [Int]
85+
86+
for x in arr where returnVoid(x) {} // expected-error {{cannot convert value of type '()' to expected condition type 'Bool'}}
87+
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)}}
88+
for x in arr where returnS(x) {} // expected-error {{cannot convert value of type 'S' to expected condition type 'Bool'}}
8789
}

test/Sema/diag_unintended_optional_behavior_swift_5.swift

+10-7
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ func warnCollectionOfIUOToAnyCoercion(_ a: Int!) { // expected-note 2{{implicitl
104104
// expected-note@-7 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{40-40= as Any}}
105105
}
106106

107-
func takesAny_sr10199(_ x: Any) {}
108-
109-
let fn_sr10199: (() -> Int?)! = { return nil }
110-
takesAny_sr10199(fn_sr10199()) // expected-warning {{expression implicitly coerced from 'Int?' to 'Any'}}
111-
// expected-note@-1 {{provide a default value to avoid this warning}}
112-
// expected-note@-2 {{force-unwrap the value to avoid this warning}}
113-
// expected-note@-3 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}
107+
// https://github.com/apple/swift/issues/52599
108+
do {
109+
func takesAny(_ x: Any) {}
110+
111+
let fn: (() -> Int?)! = { return nil }
112+
takesAny(fn()) // expected-warning {{expression implicitly coerced from 'Int?' to 'Any'}}
113+
// expected-note@-1 {{provide a default value to avoid this warning}}
114+
// expected-note@-2 {{force-unwrap the value to avoid this warning}}
115+
// expected-note@-3 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}
116+
}

test/Sema/diag_use_before_declaration.swift

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-typecheck-verify-swift
22

3-
// SR-5163
4-
func sr5163() {
3+
// https://github.com/apple/swift/issues/47739
4+
do {
55
func foo(_ x: Int) -> Int? { return 1 }
66

77
func fn() {
@@ -11,17 +11,18 @@ func sr5163() {
1111
}
1212
}
1313

14-
// SR-6726
14+
// https://github.com/apple/swift/issues/49275
15+
1516
var foo: Int?
1617

17-
func test() {
18+
test: do {
1819
guard let bar = foo else {
19-
return
20+
break test
2021
}
2122
let foo = String(bar) // expected-warning {{initialization of immutable value 'foo' was never used; consider replacing with assignment to '_' or removing it}}
2223
}
2324

24-
// SR-7660
25+
// https://github.com/apple/swift/issues/50200
2526
class C {
2627
var variable: Int?
2728
func f() {
@@ -30,16 +31,16 @@ class C {
3031
}
3132
}
3233

33-
// SR-7517
34-
func testExample() {
34+
// https://github.com/apple/swift/issues/50059
35+
do {
3536
let app = app2 // expected-error {{use of local variable 'app2' before its declaration}}
3637
let app2 = app // expected-note {{'app2' declared here}}
3738
}
3839

39-
// SR-8447
40+
// https://github.com/apple/swift/issues/50968
4041
func test_circular() {
41-
let obj = sr8447 // expected-error {{use of local variable 'sr8447' before its declaration}}
42-
let _ = obj.prop, sr8447 // expected-note {{'sr8447' declared here}} expected-error {{type annotation missing in pattern}}
42+
let obj = x // expected-error {{use of local variable 'x' before its declaration}}
43+
let _ = obj.prop, x // expected-note {{'x' declared here}} expected-error {{type annotation missing in pattern}}
4344
}
4445

4546
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)