Gardening: Migrate test suite to GH issues: Sema (1/2)

This commit is contained in:
Anthony Latsis
2022-09-02 06:08:33 +03:00
parent 5534019db4
commit d98a76172d
21 changed files with 152 additions and 118 deletions

View File

@@ -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 struct SR2579 {
// https://github.com/apple/swift/issues/45184
fileprivate struct C_45184 {
private struct Inner {
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
// 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}}
var outerProperty2 = Inner().innerProperty // expected-error {{property must be declared private 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 'C_45184.Inner.InnerPrivateType' uses a private type}}
}

View File

@@ -42,7 +42,8 @@ _ = genericString("Hello")
let genericInt = GenericType<Set<Int>>(collection: [1, 2, 3])
_ = genericInt(initialValue: 1)
// SR-11386
// https://github.com/apple/swift/issues/53787
class C<T> {}
protocol P1 {}
extension C where T : P1 { // expected-note {{where 'T' = 'Int'}}

View File

@@ -199,7 +199,8 @@ func testIUO(a: SimpleCallable!, b: MultipleArgsCallable!, c: Extended!,
_ = try? h { throw DummyError() }
}
// SR-11778
// https://github.com/apple/swift/issues/54185
struct DoubleANumber {
func callAsFunction(_ x: Int, completion: (Int) -> Void = { _ in }) {
completion(x + x)
@@ -211,7 +212,8 @@ func testDefaults(_ x: DoubleANumber) {
x(5, completion: { _ in })
}
// SR-11881
// https://github.com/apple/swift/issues/54296
struct IUOCallable {
static var callable: IUOCallable { IUOCallable() }
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}}
}
struct SR_11909 {
static let s = SR_11909()
func callAsFunction(_ x: Int = 0) -> SR_11909 { SR_11909() }
}
// https://github.com/apple/swift/issues/54327
do {
struct S {
static let s = S()
func callAsFunction(_ x: Int = 0) -> S {}
}
func testDefaultsWithUMEs(_ x: SR_11909) {
let _: SR_11909 = .s()
let _: SR_11909 = .s(5)
// Test default argument with 'UnresolvedMemberExpr'.
let _: S = .s()
let _: S = .s(5)
}

View File

@@ -1,6 +1,6 @@
// 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 {
var b: AnUndefinedType // expected-error {{cannot find type 'AnUndefinedType' in scope}}

View File

@@ -1,7 +1,8 @@
// RUN: %target-typecheck-verify-swift
// SR-838:
// expression test_seconds() was too complex to be solved in reasonable time
// https://github.com/apple/swift/issues/43450
// Expression in 'test_seconds' was too complex to be solved in reasonable time
struct Nano : CustomStringConvertible {
var value: Int64 = 0
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))
}
// SR-2102:
// DictionaryExpr was too complex to be solved in reasonable time
// https://github.com/apple/swift/issues/44710:
// 'DictionaryExpr' was too complex to be solved in reasonable time
let M_PI: Double = 3.1415926535897931
let M_E : Double = 2.7182818284590451
@@ -74,14 +75,16 @@ var operations: Dictionary<String, Operation> = [
"=": .equals,
]
// SR-1794
struct P {
// https://github.com/apple/swift/issues/44403
do {
struct P {
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
}
}
// 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 v7: [UInt32] = [55 * 8, 0]
// SR-3668
// https://github.com/apple/swift/issues/46253
// "Expression was too complex" errors for short dictionary literals
// 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 },
4: { $0 == $1 }, 5: { $0 == $1 }, 6: { $0 == $1 }, 7: { $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 },
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 },
4: { $0 != $1 }, 5: { $0 != $1 }, 6: { $0 != $1 }, 7: { $0 != $1 },
8: { $0 != $1 }, 9: { $0 != $1 }, 10: { $0 != $1 }, 11: { $0 != $1 },

View File

@@ -1,8 +1,10 @@
// RUN: %target-typecheck-verify-swift
// 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/Inputs/composition_extension_usage.swift %s -emit-module-path %t/S-partial.swiftmodule -module-name SR11227 -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 -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 M -enable-testing
// 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 {}

View File

@@ -1,7 +1,7 @@
// RUN: %target-typecheck-verify-swift -swift-version 4
//=-------------- SR-7295 --------------=/
class sr7295 {
// https://github.com/apple/swift/issues/49843
class C_49843 {
func doSomething(a: (() -> Void)? = nil, completion: @escaping ((String, Error?) -> Void)) {}
func doSomething(b: @escaping ((String, Error?, Bool) -> Void)) {}
func a() {

View File

@@ -8,14 +8,17 @@ if (x > y) {
}
}
func sr7307(_ value: Bool) {
// https://github.com/apple/swift/issues/49855
do {
func f(_ value: Bool) {
let negated = !value
defer { // expected-warning {{'defer' statement at end of scope always executes immediately}}{{5-10=do}}
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
print("end of program.")

View File

@@ -1,26 +1,25 @@
// RUN: %target-typecheck-verify-swift
enum Key: Int {
// https://github.com/apple/swift/issues/48727
do {
enum Key: Int {
case aKey
case anotherKey // expected-note {{'anotherKey' declared here}}
}
}
class sr6175 {
class C {
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 {}
}
}
subscript(i: Int) -> Int { get {} }
let s = sr6175()
let one: Int = 1
// Should choose the settable subscript to find a problem with, not the get-only subscript
s[one] = 2.5 // expected-error {{cannot convert value of type 'Int' to expected argument type 'Double'}}
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'}}
}

View File

@@ -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@-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)
takesOptConst(arr) // expected-error {{cannot pass '[Int8]' to parameter; argument #1 must be a pointer that outlives the call to 'takesOptConst'}}

View File

@@ -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@-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)
takesOptConst(arr) // expected-warning {{cannot pass '[Int8]' to parameter; argument #1 must be a pointer that outlives the call to 'takesOptConst'}}

View File

@@ -73,15 +73,17 @@ _ = p =*= &o
func rdar25963182(_ bytes: [UInt8] = nil) {}
// expected-error@-1 {{nil default argument value cannot be converted to type}}
// SR-13262
struct SR13262_S {}
// https://github.com/apple/swift/issues/55702
do {
struct S {}
func SR13262(_ x: Int) {}
func SR13262_Int(_ x: Int) -> Int { 0 }
func SR13262_SF(_ x: Int) -> SR13262_S { SR13262_S() }
func returnVoid(_ x: Int) {}
func returnInt(_ x: Int) -> Int {}
func returnS(_ x: Int) -> S {}
func testSR13262(_ 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 SR13262_SF(x) {} // expected-error {{cannot convert value of type 'SR13262_S' to expected condition type 'Bool'}}
let arr: [Int]
for x in arr where returnVoid(x) {} // expected-error {{cannot convert value of type '()' 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'}}
}

View File

@@ -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}}
}
func takesAny_sr10199(_ x: Any) {}
// https://github.com/apple/swift/issues/52599
do {
func takesAny(_ x: Any) {}
let fn_sr10199: (() -> Int?)! = { return nil }
takesAny_sr10199(fn_sr10199()) // expected-warning {{expression implicitly coerced from 'Int?' to 'Any'}}
// expected-note@-1 {{provide a default 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}}
let fn: (() -> Int?)! = { return nil }
takesAny(fn()) // expected-warning {{expression implicitly coerced from 'Int?' to 'Any'}}
// expected-note@-1 {{provide a default 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}}
}

View File

@@ -1,7 +1,7 @@
// RUN: %target-typecheck-verify-swift
// SR-5163
func sr5163() {
// https://github.com/apple/swift/issues/47739
do {
func foo(_ x: Int) -> Int? { return 1 }
func fn() {
@@ -11,17 +11,18 @@ func sr5163() {
}
}
// SR-6726
// https://github.com/apple/swift/issues/49275
var foo: Int?
func test() {
test: do {
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}}
}
// SR-7660
// https://github.com/apple/swift/issues/50200
class C {
var variable: Int?
func f() {
@@ -30,16 +31,16 @@ class C {
}
}
// SR-7517
func testExample() {
// https://github.com/apple/swift/issues/50059
do {
let app = app2 // expected-error {{use of local variable 'app2' before its declaration}}
let app2 = app // expected-note {{'app2' declared here}}
}
// SR-8447
// https://github.com/apple/swift/issues/50968
func test_circular() {
let obj = sr8447 // expected-error {{use of local variable 'sr8447' before its declaration}}
let _ = obj.prop, sr8447 // expected-note {{'sr8447' declared here}} expected-error {{type annotation missing in pattern}}
let obj = x // expected-error {{use of local variable 'x' before its declaration}}
let _ = obj.prop, x // expected-note {{'x' declared here}} expected-error {{type annotation missing in pattern}}
}
//===----------------------------------------------------------------------===//

View File

@@ -641,7 +641,8 @@ func f(a : FooClass, b : LetStructMembers) {
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 {
var x : Int = 0
@@ -656,9 +657,10 @@ class MutableSubscripts {
}
// SR-4214: Misleading location-less diagnostic when closure parameter type
// is inferred to be inout.
func sr4214() {
// https://github.com/apple/swift/issues/46797
// Misleading location-less diagnostic when closure parameter type is inferred
// to be 'inout'.
do {
func sequence<T>(_ x : T, _ f : (T) -> T) -> T {
return f(x)
}
@@ -718,14 +720,16 @@ struct S {
struct Nested {
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}}
x += 1 // expected-error {{left side of mutating operator isn't mutable: 'x' is a 'let' constant}}
}
}
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}}
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.}}
@@ -736,7 +740,8 @@ struct S {
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.}}
// 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}}
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.}}

View File

@@ -1,6 +1,8 @@
// RUN: %target-swift-frontend -typecheck -verify -primary-file %s
// [SR-12745]
// rdar://problem/62957095
// https://github.com/apple/swift/issues/55190
struct S1 {
var x : Int = 0
}

View File

@@ -48,8 +48,10 @@ struct TestInitSubscript {
var color: Color
}
// https://github.com/apple/swift/issues/58201
@propertyWrapper
public class SR_15940Bar<Value> {
public class W_58201<Value> {
private var _value: Value
public var wrappedValue: Value {
@@ -64,20 +66,20 @@ public class SR_15940Bar<Value> {
}
}
// CHECK-LABEL: struct_decl{{.*}}SR_15940_A
struct SR_15940_A {
// CHECK-LABEL: struct_decl{{.*}}S1_58201
struct S1_58201 {
// CHECK: argument_list implicit labels=wrappedValue:
// CHECK-NEXT: argument label=wrappedValue
// CHECK-NEXT: autoclosure_expr implicit type='() -> Bool?' discriminator=0 captures=(<opaque_value> ) 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
struct SR_15940_B {
// CHECK-LABEL: struct_decl{{.*}}S2_58201
struct S2_58201 {
// CHECK: argument_list implicit labels=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: autoclosure_expr implicit type='() -> Bool' location={{.*}}.swift:[[@LINE+1]]:30 range=[{{.+}}] discriminator=1 escaping
@SR_15940Bar var b: Bool = false
// 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]]:26 range=[{{.+}}] discriminator=1 escaping
@W_58201 var b: Bool = false
}

View File

@@ -1,12 +1,14 @@
// 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
protocol SR_1062_EmptyProtocol {}
do {
struct G<T: EmptyProtocol> {}
struct SR_1062_EmptyStruct {}
struct SR_1062_GenericStruct<T: SR_1062_EmptyProtocol> {}
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
let _ = { (_: G<EmptyStruct>) -> Void in // expected-error{{type 'EmptyStruct' does not conform to protocol 'EmptyProtocol'}}
EmptyStruct() as EmptyStruct
}
}

View File

@@ -205,7 +205,7 @@ class C0 {
// Check diagnostics changes.
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() {
_ = (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)

View File

@@ -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 {}
func boo() {

View File

@@ -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-typecheck-verify-swift -I %t
// SR-15807:
// https://github.com/apple/swift/issues/58084
// Associated Type Inference fails across module boundaries
// 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.