Skip to content

Commit 4f905cc

Browse files
committed
Test: updates for NoncopyableGenerics
These tests of the type system are being updated because of the new presence of Copyable and Escapable conformances & conformance requirements. (cherry picked from commit 102ccbc)
1 parent 8dae28c commit 4f905cc

15 files changed

+191
-100
lines changed

test/Constraints/result_builder_generic_infer.swift

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-swift-frontend -dump-ast %s | %FileCheck %s
22

3-
// XFAIL: noncopyable_generics
4-
53
protocol P {
64
associatedtype A
75

@@ -24,34 +22,34 @@ struct ProtocolSubstitution: P {
2422
typealias A = Int
2523

2624
// CHECK: var_decl{{.*}}x1
27-
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> ProtocolSubstitution.A)
25+
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> ProtocolSubstitution.A)
2826
var x1: [S] { S() }
2927

3028
// CHECK: var_decl{{.*}}x2
31-
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> ProtocolSubstitution)
29+
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> ProtocolSubstitution)
3230
var x2: [S] { S() }
3331
}
3432

3533
// CHECK: struct_decl{{.*}}ArchetypeSubstitution
3634
struct ArchetypeSubstitution<A>: P {
3735
// CHECK: var_decl{{.*}}x1
38-
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> A)
36+
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> A)
3937
var x1: [S] { S() }
4038

4139
// CHECK: var_decl{{.*}}x2
42-
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> ArchetypeSubstitution<A>)
40+
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> ArchetypeSubstitution<A>)
4341
var x2: [S] { S() }
4442
}
4543

4644
// CHECK-LABEL: struct_decl{{.*}}ExplicitGenericAttribute
4745
struct ExplicitGenericAttribute<T: P> {
4846
// CHECK: var_decl{{.*}}x1
49-
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> T)
47+
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> T)
5048
@Builder<T>
5149
var x1: [S] { S() }
5250

5351
// CHECK: var_decl{{.*}}x2
54-
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> T.A)
52+
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> T.A)
5553
@Builder<T.A>
5654
var x2: [S] { S() }
5755
}
@@ -63,10 +61,10 @@ extension ConcreteTypeSubstitution: P where Value == Int {
6361
typealias A = Value
6462

6563
// CHECK: var_decl{{.*}}x1
66-
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> ConcreteTypeSubstitution<Int>.A)
64+
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> ConcreteTypeSubstitution<Int>.A)
6765
var x1: [S] { S() }
6866

6967
// CHECK: var_decl{{.*}}x2
70-
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> ConcreteTypeSubstitution<Int>)
68+
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> ConcreteTypeSubstitution<Int>)
7169
var x2: [S] { S() }
7270
}

test/Generics/conditional_conformances.swift

Lines changed: 104 additions & 34 deletions
Large diffs are not rendered by default.

test/Generics/generic_objc_superclass.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-typecheck-verify-swift %clang-importer-sdk -dump-requirement-machine 2>&1 | %FileCheck %s
22

3-
// XFAIL: noncopyable_generics
4-
53
// REQUIRES: objc_interop
64

75
import Foundation
@@ -15,9 +13,16 @@ func foo<T : Generic<U>, U>(_: T, _: U) {
1513

1614
// CHECK: Requirement machine for fresh signature < T U >
1715
// CHECK-NEXT: Rewrite system: {
16+
// CHECK-NEXT: - [Copyable].[Copyable] => [Copyable] [permanent]
17+
// CHECK-NEXT: - [Escapable].[Escapable] => [Escapable] [permanent]
18+
// CHECK-NEXT: - τ_0_1.[Copyable] => τ_0_1 [explicit]
19+
// CHECK-NEXT: - τ_0_1.[Escapable] => τ_0_1 [explicit]
1820
// CHECK-NEXT: - τ_0_0.[superclass: Generic<τ_0_1>] => τ_0_0
1921
// CHECK-NEXT: - τ_0_0.[layout: AnyObject] => τ_0_0
2022
// CHECK-NEXT: }
2123
// CHECK: Property map: {
24+
// CHECK-NEXT: [Copyable] => { conforms_to: [Copyable] }
25+
// CHECK-NEXT: [Escapable] => { conforms_to: [Escapable] }
26+
// CHECK-NEXT: τ_0_1 => { conforms_to: [Copyable Escapable] }
2227
// CHECK-NEXT: τ_0_0 => { layout: AnyObject superclass: [superclass: Generic<τ_0_1>] }
2328
// CHECK-NEXT: }

test/Generics/minimal_conformances_compare_concrete.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -disable-requirement-machine-concrete-contraction 2>&1 | %FileCheck %s
33
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -disable-requirement-machine-concrete-contraction -dump-requirement-machine 2>&1 | %FileCheck %s --check-prefix=RULE
44

5-
// XFAIL: noncopyable_generics
6-
75
protocol P {}
86

97
class Base : P {}
@@ -21,13 +19,23 @@ extension G where X : Base, X : P, X == Derived {}
2119
// RULE: + (requirement "\xCF\x84_0_0" same_type "Derived")
2220

2321
// RULE: Rewrite system: {
22+
// RULE-NEXT: - [Copyable].[Copyable] => [Copyable] [permanent]
23+
// RULE-NEXT: - [Escapable].[Escapable] => [Escapable] [permanent]
2424
// RULE-NEXT: - [P].[P] => [P] [permanent]
25+
// RULE-NEXT: - [P].[Copyable] => [P] [explicit]
26+
// RULE-NEXT: - [P].[Escapable] => [P] [explicit]
27+
// RULE-NEXT: - τ_0_0.[Copyable] => τ_0_0 [explicit]
28+
// RULE-NEXT: - τ_0_0.[Escapable] => τ_0_0 [explicit]
2529
// RULE-NEXT: - τ_0_0.[superclass: Base] => τ_0_0 [explicit]
2630
// RULE-NEXT: - τ_0_0.[P] => τ_0_0 [explicit]
2731
// RULE-NEXT: - τ_0_0.[concrete: Derived] => τ_0_0 [explicit]
2832
// RULE-NEXT: - τ_0_0.[layout: _NativeClass] => τ_0_0
2933
// RULE-NEXT: - τ_0_0.[superclass: Derived] => τ_0_0
34+
// RULE-NEXT: - τ_0_0.[concrete: Derived : Copyable] => τ_0_0
35+
// RULE-NEXT: - τ_0_0.[concrete: Derived : Escapable] => τ_0_0
3036
// RULE-NEXT: - τ_0_0.[concrete: Derived : P] => τ_0_0
37+
// RULE-NEXT: - τ_0_0.[concrete: Base : Copyable] => τ_0_0
38+
// RULE-NEXT: - τ_0_0.[concrete: Base : Escapable] => τ_0_0
3139
// RULE-NEXT: - τ_0_0.[concrete: Base : P] => τ_0_0
3240
// RULE-NEXT: }
3341

test/Generics/rdar123013710.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-typecheck-verify-swift
22

3-
// XFAIL: noncopyable_generics
4-
53
public protocol P {
64
associatedtype A
75
associatedtype B: P
@@ -17,7 +15,7 @@ extension Never: Q, P { // expected-note 2{{through reference here}}
1715
public static func f() -> Any? { nil }
1816
}
1917

20-
extension Q {
21-
public var b: Never { fatalError() } // expected-note {{through reference here}}
18+
extension Q { // expected-note {{through reference here}}
19+
public var b: Never { fatalError() } // expected-note 4{{through reference here}}
2220
}
2321

test/Generics/rdar79564324.swift

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// RUN: %target-swift-frontend -emit-module %S/Inputs/rdar79564324_other.swift -emit-module-path %t/rdar79564324_other.swiftmodule -dump-requirement-machine 2>&1 | %FileCheck %s
33
// RUN: %target-swift-frontend -emit-silgen %s -I %t
44

5-
// XFAIL: noncopyable_generics
6-
75
import rdar79564324_other
86

97
public func test<T : P>(_ t: T) where T == T.A {
@@ -28,18 +26,30 @@ public func test<T : P>(_ t: T) where T == T.A {
2826
// CHECK-NEXT: - [P].[P] => [P] [permanent]
2927
// CHECK-NEXT: - [P].A => [P:A] [permanent]
3028
// CHECK-NEXT: - [P:A].[P] => [P:A]
29+
// CHECK-NEXT: - [P].[Copyable] => [P] [explicit]
30+
// CHECK-NEXT: - [P].[Escapable] => [P] [explicit]
31+
// CHECK-NEXT: - [P:A].[Copyable] => [P:A] [explicit]
32+
// CHECK-NEXT: - [P:A].[Escapable] => [P:A] [explicit]
3133
// CHECK-NEXT: - [P].[P:A] => [P:A]
3234
// CHECK-NEXT: - [P:A].A => [P:A].[P:A]
35+
// CHECK-NEXT: - [Copyable].[Copyable] => [Copyable] [permanent]
36+
// CHECK-NEXT: - [Escapable].[Escapable] => [Escapable] [permanent]
3337
// CHECK-NEXT: - τ_0_0.A => τ_0_0
3438
// CHECK-NEXT: - τ_0_1.[P] => τ_0_1
3539
// CHECK-NEXT: - τ_0_1.A => τ_0_0
40+
// CHECK-NEXT: - τ_0_0.[Copyable] => τ_0_0 [explicit]
41+
// CHECK-NEXT: - τ_0_0.[Escapable] => τ_0_0 [explicit]
42+
// CHECK-NEXT: - τ_0_1.[Copyable] => τ_0_1 [explicit]
43+
// CHECK-NEXT: - τ_0_1.[Escapable] => τ_0_1 [explicit]
3644
// CHECK-NEXT: - τ_0_1.[P:A] => τ_0_0
3745
// CHECK-NEXT: - τ_0_0.[P] => τ_0_0
3846
// CHECK-NEXT: - τ_0_0.[P:A] => τ_0_0
3947
// CHECK-NEXT: }
4048
// CHECK: Property map: {
41-
// CHECK-NEXT: [P] => { conforms_to: [P] }
42-
// CHECK-NEXT: [P:A] => { conforms_to: [P] }
43-
// CHECK-NEXT: τ_0_1 => { conforms_to: [P] }
44-
// CHECK-NEXT: τ_0_0 => { conforms_to: [P] }
49+
// CHECK-NEXT: [P] => { conforms_to: [P Copyable Escapable] }
50+
// CHECK-NEXT: [P:A] => { conforms_to: [P Copyable Escapable] }
51+
// CHECK-NEXT: [Copyable] => { conforms_to: [Copyable] }
52+
// CHECK-NEXT: [Escapable] => { conforms_to: [Escapable] }
53+
// CHECK-NEXT: τ_0_1 => { conforms_to: [P Copyable Escapable] }
54+
// CHECK-NEXT: τ_0_0 => { conforms_to: [Copyable Escapable P] }
4555
// CHECK-NEXT: }

test/Generics/tuple-conformances.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -enable-experimental-feature TupleConformances
22

3-
// XFAIL: noncopyable_generics
4-
53
// Because of -enable-experimental-feature TupleConformances
64
// REQUIRES: asserts
75

test/Generics/unify_associated_types.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -dump-requirement-machine 2>&1 | %FileCheck %s
22

3-
// XFAIL: noncopyable_generics
4-
53
struct Foo<A, B> {}
64

75
protocol P1 {
@@ -29,6 +27,6 @@ struct MergeTest<G : P1a & P2a> {}
2927
// CHECK: - τ_0_0.[P1a:T].[P2:X] => τ_0_0.[P1a:T].[P1:X]
3028
// CHECK: }
3129
// CHECK: Property map: {
32-
// CHECK: τ_0_0 => { conforms_to: [P1a P2a] }
33-
// CHECK: τ_0_0.[P1a:T] => { conforms_to: [P1 P2] }
30+
// CHECK: τ_0_0 => { conforms_to: [P1a P2a Copyable Escapable] }
31+
// CHECK: τ_0_0.[P1a:T] => { conforms_to: [P1 Copyable Escapable P2] }
3432
// CHECK: }

test/Generics/unify_concrete_types_1.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -dump-requirement-machine 2>&1 | %FileCheck %s
22

3-
// XFAIL: noncopyable_generics
4-
53
struct Foo<A, B> {}
64

75
protocol P1 {
@@ -29,5 +27,5 @@ struct MergeTest<G : P1 & P2> {
2927
// CHECK-LABEL: Property map: {
3028
// CHECK: [P1:X] => { concrete_type: [concrete: Foo<[P1:Y1], [P1:Z1]>] }
3129
// CHECK: [P2:X] => { concrete_type: [concrete: Foo<[P2:Y2], [P2:Z2]>] }
32-
// CHECK: τ_0_0 => { conforms_to: [P1 P2] }
30+
// CHECK: τ_0_0 => { conforms_to: [P1 P2 Copyable Escapable] }
3331
// CHECK: }

test/Generics/unify_nested_types_3.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -dump-requirement-machine 2>&1 | %FileCheck %s
22

3-
// XFAIL: noncopyable_generics
4-
53
protocol P1 {
64
associatedtype T : P1
75
}
@@ -34,6 +32,6 @@ struct G<T : P2a & P3a> {}
3432
// CHECK: - τ_0_0.[P2a:T].[P2:T].[concrete: X<τ_0_0.[P3a:U].[P1:T]>] => τ_0_0.[P2a:T].[P2:T]
3533
// CHECK: }
3634
// CHECK-LABEL: Property map: {
37-
// CHECK: τ_0_0.[P2a:T] => { conforms_to: [P2] concrete_type: [concrete: X<τ_0_0.[P3a:U]>] }
38-
// CHECK: τ_0_0.[P2a:T].[P2:T] => { concrete_type: [concrete: X<τ_0_0.[P3a:U].[P1:T]>] }
35+
// CHECK: τ_0_0.[P2a:T] => { conforms_to: [P2 Copyable Escapable] concrete_type: [concrete: X<τ_0_0.[P3a:U]>] }
36+
// CHECK: τ_0_0.[P2a:T].[P2:T] => { conforms_to: [Copyable Escapable] concrete_type: [concrete: X<τ_0_0.[P3a:U].[P1:T]>] }
3937
// CHECK: }

0 commit comments

Comments
 (0)