Skip to content

Commit f58896c

Browse files
committed
[test] Update tests for new stdlib
1 parent 0b13cdf commit f58896c

9 files changed

+54
-29
lines changed

test/Generics/inverse_generics.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,15 @@ let global__new__: any PPP & ~Copyable = SSS()
486486

487487
struct Example<T> {}
488488

489-
struct TestResolution {
490-
var maybeNC: NC? = nil // expected-error {{type 'NC' does not conform to protocol 'Copyable'}}
491-
var maybeIOUNC: NC! = nil // expected-error {{type 'NC' does not conform to protocol 'Copyable'}}
489+
struct TestResolution1 { // expected-note {{consider adding '~Copyable' to struct 'TestResolution1'}}
490+
var maybeNC: NC? = nil // expected-error {{stored property 'maybeNC' of 'Copyable'-conforming struct 'TestResolution1' has non-Copyable type 'NC?'}}
491+
}
492+
493+
struct TestResolution2 { // expected-note {{consider adding '~Copyable' to struct 'TestResolution2'}}
494+
var maybeIOUNC: NC! = nil // expected-error {{stored property 'maybeIOUNC' of 'Copyable'-conforming struct 'TestResolution2' has non-Copyable type 'NC?'}}
495+
}
496+
497+
struct TestResolution3 {
492498
var arrayNC: [NC] = [] // expected-error {{type 'NC' does not conform to protocol 'Copyable'}}
493499
var dictNC: [String: NC] = [:] // expected-error {{type 'NC' does not conform to protocol 'Copyable'}}
494500
var exampleNC: Example<NC> = Example() // expected-error {{type 'NC' does not conform to protocol 'Copyable'}}

test/IDE/complete_in_closures.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ var foo = {
335335
func testWithMemoryRebound(_ bar: UnsafePointer<UInt64>) {
336336
_ = bar.withMemoryRebound(to: Int64.self, capacity: 3) { ptr in
337337
return ptr #^SINGLE_EXPR_CLOSURE_CONTEXT^#
338-
// SINGLE_EXPR_CLOSURE_CONTEXT-DAG: Decl[InstanceMethod]/CurrNominal/IsSystem/TypeRelation[Invalid]: .deallocate()[#Void#]; name=deallocate()
339-
// SINGLE_EXPR_CLOSURE_CONTEXT-DAG: Decl[InstanceVar]/CurrNominal/IsSystem: .pointee[#Int64#]; name=pointee
338+
// SINGLE_EXPR_CLOSURE_CONTEXT-DAG: Decl[InstanceMethod]/CurrNominal/IsSystem/TypeRelation[Convertible]: .deallocate[#() -> ()#]; name=deallocate
339+
// SINGLE_EXPR_CLOSURE_CONTEXT-DAG: Decl[InstanceVar]/CurrNominal/IsSystem/TypeRelation[Convertible]: .pointee[#Int64#]; name=pointee
340340
}
341341
}
342342

test/IDE/complete_swift_key_path_optional_root.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ let _ : KeyPath<Person?, String> = \.#^TYPE_INFER_DOT_OPTIONAL^#
2525
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.bestFriend[#Person?#]; name=bestFriend
2626
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.itself[#Person#]; name=itself
2727
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[Subscript]/CurrNominal: ?[{#(index): Int#}][#Int#]; name=[:]
28-
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: unsafelyUnwrapped[#Person#]; name=unsafelyUnwrapped
2928
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: optMember[#String#]; name=optMember
29+
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: unsafelyUnwrapped[#Person#]; name=unsafelyUnwrapped
3030
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: debugDescription[#String#]; name=debugDescription
3131
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: customMirror[#Mirror#]; name=customMirror
3232

@@ -37,8 +37,8 @@ let _ : KeyPath<Person?, String> = \Person?.#^TYPE_DOT_OPTIONAL^#
3737
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.bestFriend[#Person?#]; name=bestFriend
3838
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.itself[#Person#]; name=itself
3939
// PERSONTYPE-DOT-OPT-NEXT: Decl[Subscript]/CurrNominal: ?[{#(index): Int#}][#Int#]; name=[:]
40-
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: unsafelyUnwrapped[#Person#]; name=unsafelyUnwrapped
4140
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: optMember[#String#]; name=optMember
41+
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: unsafelyUnwrapped[#Person#]; name=unsafelyUnwrapped
4242
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: debugDescription[#String#]; name=debugDescription
4343
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: customMirror[#Mirror#]; name=customMirror
4444

test/SILGen/borrow_from_load_expr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public struct FA<T> {
1212
public subscript(_ int: Int) -> T {
1313
// CHECK-LABEL: sil [ossa] @read : {{.*}} {
1414
// function_ref UnsafeMutablePointer.subscript.unsafeAddressor
15-
// CHECK: [[ADDRESSOR:%[^,]+]] = function_ref @$sSpyxSicilu
15+
// CHECK: [[ADDRESSOR:%[^,]+]] = function_ref @$sSpsRiczrlEyxSicilu
1616
// CHECK: [[POINTER:%[^,]+]] = apply [[ADDRESSOR]]
1717
// CHECK: [[RAW_POINTER:%[^,]+]] = struct_extract [[POINTER]]
1818
// CHECK: [[ADDR:%[^,]+]] = pointer_to_address [[RAW_POINTER]]

test/SILGen/closures.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ class SuperSub : SuperBase {
614614
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
615615
// CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] [[INNER]]([[ARG_COPY]])
616616
// CHECK: [[CVT:%.*]] = convert_escape_to_noescape [not_guaranteed] [[PA]]
617-
// CHECK: [[TRY_APPLY_AUTOCLOSURE:%.*]] = function_ref @$ss2qqoiyxxSg_xyKXKtKlF :
617+
// CHECK: [[TRY_APPLY_AUTOCLOSURE:%.*]] = function_ref @$ss2qqoiyxxSgn_xyKXKtKRiczlF :
618618
// CHECK: try_apply [[TRY_APPLY_AUTOCLOSURE]]<()>({{.*}}, {{.*}}, [[CVT]]) : {{.*}}, normal [[NORMAL_BB:bb1]], error [[ERROR_BB:bb2]]
619619
// CHECK: [[NORMAL_BB]]{{.*}}
620620
// CHECK: } // end sil function '[[INNER_FUNC_1]]'
@@ -643,7 +643,7 @@ class SuperSub : SuperBase {
643643
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
644644
// CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] [[INNER]]([[ARG_COPY]])
645645
// CHECK: [[CVT:%.*]] = convert_escape_to_noescape [not_guaranteed] [[PA]] :
646-
// CHECK: [[TRY_APPLY_FUNC:%.*]] = function_ref @$ss2qqoiyxxSg_xyKXKtKlF :
646+
// CHECK: [[TRY_APPLY_FUNC:%.*]] = function_ref @$ss2qqoiyxxSgn_xyKXKtKRiczlF :
647647
// CHECK: try_apply [[TRY_APPLY_FUNC]]<()>({{.*}}, {{.*}}, [[CVT]]) : {{.*}}, normal [[NORMAL_BB:bb1]], error [[ERROR_BB:bb2]]
648648
// CHECK: [[NORMAL_BB]]{{.*}}
649649
// CHECK: } // end sil function '[[INNER_FUNC_1]]'

test/SILOptimizer/access_marker_verify.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ func testOpenExistential(p: PBar) {
939939
// CHECK-NOT: begin_access
940940
// CHECK: inject_enum_addr [[Q0]] : $*Optional<any Q>, #Optional.some!enumelt
941941
// CHECK-NOT: begin_access
942-
// CHECK: apply %{{.*}}<any Q>([[Q0]], {{.*}}) : $@convention(method) <τ_0_0> (@in_guaranteed Optional<τ_0_0>, _OptionalNilComparisonType, @thin Optional<τ_0_0>.Type) -> Bool
942+
// CHECK: apply %{{.*}}<any Q>([[Q0]], {{.*}}) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed Optional<τ_0_0>, _OptionalNilComparisonType, @thin Optional<τ_0_0>.Type) -> Bool
943943
// CHECK: [[Q:%.*]] = alloc_stack [lexical] [var_decl] $any Q, let, name "q"
944944
// CHECK: [[OPT_Q:%.*]] = alloc_stack $Optional<any Q>
945945
// CHECK-NOT: begin_access
@@ -1030,7 +1030,7 @@ func testPointerInit(x: Int, y: UnsafeMutablePointer<Int>) {
10301030
// CHECK-LABEL: sil hidden [ossa] @$s20access_marker_verify15testPointerInit1x1yySi_SpySiGtF : $@convention(thin) (Int, UnsafeMutablePointer<Int>) -> () {
10311031
// CHECK: bb0(%0 : $Int, %1 : $UnsafeMutablePointer<Int>):
10321032
// call addressor
1033-
// CHECK: [[POINTEE:%.*]] = apply %{{.*}}<Int>(%1) : $@convention(method) <τ_0_0> (UnsafeMutablePointer<τ_0_0>) -> UnsafeMutablePointer<τ_0_0>
1033+
// CHECK: [[POINTEE:%.*]] = apply %{{.*}}<Int>(%1) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (UnsafeMutablePointer<τ_0_0>) -> UnsafeMutablePointer<τ_0_0>
10341034
// CHECK: [[RAWPTR:%.*]] = struct_extract [[POINTEE]] : $UnsafeMutablePointer<Int>, #UnsafeMutablePointer._rawValue
10351035
// CHECK: [[ADR:%.*]] = pointer_to_address [[RAWPTR]] : $Builtin.RawPointer to [strict] $*Int
10361036
// CHECK: [[ACCESS:%.*]] = begin_access [modify] [unsafe] [[ADR]] : $*Int

test/Sema/moveonly_illegal_types.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ func illegalTypes<T>(_ t: T) {
6060

6161
_ = t as! ValBox<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
6262

63-
let _: Optional<MO> // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
64-
let _: MO? // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
65-
let _: MO?? // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
66-
let _: MO! // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
67-
let _: MO?! // expected-error {{type 'MO' does not conform to protocol 'Copyable'}}
63+
let _: Optional<MO>
64+
let _: MO?
65+
let _: MO??
66+
let _: MO!
67+
let _: MO?!
6868

6969
let _: Klass & MO // expected-error {{non-protocol, non-class type 'MO' cannot be used within a protocol-constrained type}}
7070
let _: any MO // expected-error {{'any' has no effect on concrete type 'MO'}}

test/Sema/moveonly_restrictions.swift

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ struct MoveOnlyStruct { // expected-note {{struct 'MoveOnlyStruct' has '~Copyabl
1717

1818
class C {
1919
var copyable: CopyableKlass? = nil
20-
var moveOnlyC: MoveOnlyKlass? = nil // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
21-
var moveOnlyS: MoveOnlyStruct? = nil // expected-error {{type 'MoveOnlyStruct' does not conform to protocol 'Copyable'}}
20+
var moveOnlyC: MoveOnlyKlass? = nil
21+
var moveOnlyS: MoveOnlyStruct? = nil
22+
var copyableCs: [CopyableKlass] = []
23+
var moveOnlyCs: [MoveOnlyKlass] = [] // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
24+
var moveOnlySs: [MoveOnlyStruct] = [] // expected-error {{type 'MoveOnlyStruct' does not conform to protocol 'Copyable'}}
2225
}
2326

2427
@_moveOnly
2528
class CMoveOnly {
2629
var copyable: CopyableKlass? = nil
27-
var moveOnlyC: MoveOnlyKlass? = nil // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
28-
var moveOnlyS: MoveOnlyStruct? = nil // expected-error {{type 'MoveOnlyStruct' does not conform to protocol 'Copyable'}}
30+
var moveOnlyC: MoveOnlyKlass? = nil
31+
var moveOnlyS: MoveOnlyStruct? = nil
32+
var copyableCs: [CopyableKlass] = []
33+
var moveOnlyCs: [MoveOnlyKlass] = [] // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
34+
var moveOnlySs: [MoveOnlyStruct] = [] // expected-error {{type 'MoveOnlyStruct' does not conform to protocol 'Copyable'}}
2935
}
3036

3137
struct OptionalGrandField<T> { // expected-note {{consider adding '~Copyable' to generic struct 'OptionalGrandField'}}
@@ -44,12 +50,17 @@ struct SCopyable {
4450

4551
struct S { // expected-note {{consider adding '~Copyable' to struct 'S'}}
4652
var copyable: CopyableKlass
47-
var moveOnly2: MoveOnlyStruct? // expected-error {{type 'MoveOnlyStruct' does not conform to protocol 'Copyable'}}
48-
var moveOnly: MoveOnlyStruct // expected-error {{stored property 'moveOnly' of 'Copyable'-conforming struct 'S' has non-Copyable type 'MoveOnlyStruct'}}
53+
var moveOnly2: MoveOnlyStruct? // expected-error {{stored property 'moveOnly2' of 'Copyable'-conforming struct 'S' has non-Copyable type 'MoveOnlyStruct?'}}
54+
// FIXME(NCG): Shouldn't this be also an error?
55+
var moveOnly: MoveOnlyStruct
4956
var moveOnly3: OptionalGrandField<MoveOnlyKlass> // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
5057
var moveOnly3: OptionalGrandField<MoveOnlyStruct> // expected-error {{type 'MoveOnlyStruct' does not conform to protocol 'Copyable'}}
5158
}
5259

60+
struct S2 { // expected-note {{consider adding '~Copyable' to struct 'S2'}}
61+
var moveOnly: MoveOnlyStruct // expected-error {{stored property 'moveOnly' of 'Copyable'-conforming struct 'S2' has non-Copyable type 'MoveOnlyStruct'}}
62+
}
63+
5364
@_moveOnly
5465
struct SMoveOnly {
5566
var copyable: CopyableKlass
@@ -85,13 +96,17 @@ extension MoveOnlyStruct {
8596
func foo() {
8697
class C2 {
8798
var copyable: CopyableKlass? = nil
88-
var moveOnly: MoveOnlyKlass? = nil // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
99+
var moveOnly: MoveOnlyKlass? = nil
100+
var copyables: [CopyableKlass] = []
101+
var moveOnlies: [MoveOnlyKlass] = [] // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
89102
}
90103

91104
@_moveOnly
92105
class C2MoveOnly {
93106
var copyable: CopyableKlass? = nil
94-
var moveOnly: MoveOnlyKlass? = nil // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
107+
var moveOnly: MoveOnlyKlass? = nil
108+
var copyables: [CopyableKlass] = []
109+
var moveOnlies: [MoveOnlyKlass] = [] // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
95110
}
96111

97112
struct S2 { // expected-note {{consider adding '~Copyable' to struct 'S2'}}
@@ -118,13 +133,17 @@ func foo() {
118133
{
119134
class C3 {
120135
var copyable: CopyableKlass? = nil
121-
var moveOnly: MoveOnlyKlass? = nil // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
136+
var moveOnly: MoveOnlyKlass? = nil
137+
var copyables: [CopyableKlass] = []
138+
var moveOnlies: [MoveOnlyKlass] = [] // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
122139
}
123140

124141
@_moveOnly
125142
class C3MoveOnly {
126143
var copyable: CopyableKlass? = nil
127-
var moveOnly: MoveOnlyKlass? = nil // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
144+
var moveOnly: MoveOnlyKlass? = nil
145+
var copyables: [CopyableKlass] = []
146+
var moveOnlies: [MoveOnlyKlass] = [] // expected-error {{type 'MoveOnlyKlass' does not conform to protocol 'Copyable'}}
128147
}
129148

130149
struct S3 { // expected-note {{consider adding '~Copyable' to struct 'S3'}}

test/SourceKit/DocSupport/doc_clang_module.swift.response

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5652,8 +5652,8 @@ var FooSubUnnamedEnumeratorA1: Int { get }
56525652
key.conforms: [
56535653
{
56545654
key.kind: source.lang.swift.ref.protocol,
5655-
key.name: "_Pointer",
5656-
key.usr: "s:s8_PointerP"
5655+
key.name: "Copyable",
5656+
key.usr: "s:s8CopyableP"
56575657
}
56585658
]
56595659
},

0 commit comments

Comments
 (0)