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.
This commit is contained in:
Kavon Farvardin
2024-03-13 17:17:21 -07:00
parent 8a13ced31d
commit 102ccbc70b
15 changed files with 191 additions and 100 deletions

View File

@@ -1,7 +1,5 @@
// RUN: %target-swift-frontend -dump-ast %s | %FileCheck %s
// XFAIL: noncopyable_generics
protocol P {
associatedtype A
@@ -24,34 +22,34 @@ struct ProtocolSubstitution: P {
typealias A = Int
// CHECK: var_decl{{.*}}x1
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> ProtocolSubstitution.A)
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> ProtocolSubstitution.A)
var x1: [S] { S() }
// CHECK: var_decl{{.*}}x2
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> ProtocolSubstitution)
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> ProtocolSubstitution)
var x2: [S] { S() }
}
// CHECK: struct_decl{{.*}}ArchetypeSubstitution
struct ArchetypeSubstitution<A>: P {
// CHECK: var_decl{{.*}}x1
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> A)
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> A)
var x1: [S] { S() }
// CHECK: var_decl{{.*}}x2
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> ArchetypeSubstitution<A>)
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> ArchetypeSubstitution<A>)
var x2: [S] { S() }
}
// CHECK-LABEL: struct_decl{{.*}}ExplicitGenericAttribute
struct ExplicitGenericAttribute<T: P> {
// CHECK: var_decl{{.*}}x1
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> T)
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> T)
@Builder<T>
var x1: [S] { S() }
// CHECK: var_decl{{.*}}x2
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> T.A)
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> T.A)
@Builder<T.A>
var x2: [S] { S() }
}
@@ -63,10 +61,10 @@ extension ConcreteTypeSubstitution: P where Value == Int {
typealias A = Value
// CHECK: var_decl{{.*}}x1
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> ConcreteTypeSubstitution<Int>.A)
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> ConcreteTypeSubstitution<Int>.A)
var x1: [S] { S() }
// CHECK: var_decl{{.*}}x2
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T> T -> ConcreteTypeSubstitution<Int>)
// CHECK: Builder.buildBlock{{.*}}(substitution_map generic_signature=<T where T : Copyable, T : Escapable> T -> ConcreteTypeSubstitution<Int>)
var x2: [S] { S() }
}

View File

@@ -1,8 +1,6 @@
// RUN: %target-typecheck-verify-swift -debug-generic-signatures > %t.dump 2>&1
// RUN: %FileCheck %s < %t.dump
// XFAIL: noncopyable_generics
protocol P1 {}
protocol P2 {}
protocol P3 {}
@@ -20,8 +18,12 @@ func takes_P5<X: P5>(_: X) {}
struct Free<T> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=Free
// CHECK-NEXT: (normal_conformance type="Free<T>" protocol="P2"
// CHECK-NEXT: (requirement "T" conforms_to "P1"))
// CHECK-NEXT: (normal_conformance type="Free<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="Free<T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="Free<T>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" conforms_to "P1"))
extension Free: P2 where T: P1 {}
// expected-note@-1 {{requirement from conditional conformance of 'Free<U>' to 'P2'}}
// expected-note@-2 {{requirement from conditional conformance of 'Free<T>' to 'P2'}}
@@ -35,8 +37,12 @@ func free_bad<U>(_: U) {
struct Constrained<T: P1> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=Constrained
// CHECK-LABEL: ExtensionDecl line={{.*}} base=Constrained
// CHECK-NEXT: (normal_conformance type="Constrained<T>" protocol="P2"
// CHECK-NEXT: (requirement "T" conforms_to "P3"))
// CHECK-NEXT: (normal_conformance type="Constrained<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="Constrained<T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="Constrained<T>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" conforms_to "P3"))
extension Constrained: P2 where T: P3 {} // expected-note {{requirement from conditional conformance of 'Constrained<U>' to 'P2'}}
func constrained_good<U: P1 & P3>(_: U) {
takes_P2(Constrained<U>())
@@ -48,20 +54,32 @@ func constrained_bad<U: P1>(_: U) {
struct RedundantSame<T: P1> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=RedundantSame
// CHECK-LABEL: ExtensionDecl line={{.*}} base=RedundantSame
// CHECK-NEXT: (normal_conformance type="RedundantSame<T>" protocol="P2")
// CHECK-NEXT: (normal_conformance type="RedundantSame<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="RedundantSame<T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="RedundantSame<T>" protocol="Escapable")))
extension RedundantSame: P2 where T: P1 {}
struct RedundantSuper<T: P4> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=RedundantSuper
// CHECK-LABEL: ExtensionDecl line={{.*}} base=RedundantSuper
// CHECK-NEXT: (normal_conformance type="RedundantSuper<T>" protocol="P2")
// CHECK-NEXT: (normal_conformance type="RedundantSuper<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="RedundantSuper<T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="RedundantSuper<T>" protocol="Escapable")))
extension RedundantSuper: P2 where T: P1 {}
struct OverlappingSub<T: P1> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=OverlappingSub
// CHECK-LABEL: ExtensionDecl line={{.*}} base=OverlappingSub
// CHECK-NEXT: (normal_conformance type="OverlappingSub<T>" protocol="P2"
// CHECK-NEXT: (requirement "T" conforms_to "P4"))
// CHECK-NEXT: (normal_conformance type="OverlappingSub<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="OverlappingSub<T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="OverlappingSub<T>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" conforms_to "P4"))
extension OverlappingSub: P2 where T: P4 {} // expected-note {{requirement from conditional conformance of 'OverlappingSub<U>' to 'P2'}}
func overlapping_sub_good<U: P4>(_: U) {
takes_P2(OverlappingSub<U>())
@@ -74,8 +92,12 @@ func overlapping_sub_bad<U: P1>(_: U) {
struct SameType<T> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=SameType
// CHECK-LABEL: ExtensionDecl line={{.*}} base=SameType
// CHECK-NEXT: (normal_conformance type="SameType<T>" protocol="P2"
// CHECK-NEXT: (requirement "T" same_type "Int"))
// CHECK-NEXT: (normal_conformance type="SameType<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="SameType<Int>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="SameType<Int>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" same_type "Int"))
extension SameType: P2 where T == Int {}
// expected-note@-1 {{requirement from conditional conformance of 'SameType<U>' to 'P2'}}
// expected-note@-2 {{requirement from conditional conformance of 'SameType<Float>' to 'P2'}}
@@ -91,8 +113,12 @@ func same_type_bad<U>(_: U) {
struct SameTypeGeneric<T, U> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=SameTypeGeneric
// CHECK-LABEL: ExtensionDecl line={{.*}} base=SameTypeGeneric
// CHECK-NEXT: (normal_conformance type="SameTypeGeneric<T, U>" protocol="P2"
// CHECK-NEXT: (requirement "T" same_type "U"))
// CHECK-NEXT: (normal_conformance type="SameTypeGeneric<T, U>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="SameTypeGeneric<T, T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="SameTypeGeneric<T, T>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" same_type "U"))
extension SameTypeGeneric: P2 where T == U {}
// expected-note@-1 {{requirement from conditional conformance of 'SameTypeGeneric<U, Int>' to 'P2'}}
// expected-note@-2 {{requirement from conditional conformance of 'SameTypeGeneric<Int, Float>' to 'P2'}}
@@ -117,9 +143,13 @@ func same_type_bad<U, V>(_: U, _: V) {
struct Infer<T, U> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=Infer
// CHECK-LABEL: ExtensionDecl line={{.*}} base=Infer
// CHECK-NEXT: (normal_conformance type="Infer<T, U>" protocol="P2"
// CHECK-NEXT: (requirement "T" same_type "Constrained<U>")
// CHECK-NEXT: (requirement "U" conforms_to "P1"))
// CHECK-NEXT: (normal_conformance type="Infer<T, U>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="Infer<Constrained<U>, U>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="Infer<Constrained<U>, U>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" same_type "Constrained<U>")
// CHECK-NEXT: (requirement "U" conforms_to "P1"))
extension Infer: P2 where T == Constrained<U> {}
// expected-note@-1 2 {{requirement from conditional conformance of 'Infer<Constrained<U>, V>' to 'P2'}}
func infer_good<U: P1>(_: U) {
@@ -136,8 +166,12 @@ func infer_bad<U: P1, V>(_: U, _: V) {
struct InferRedundant<T, U: P1> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=InferRedundant
// CHECK-LABEL: ExtensionDecl line={{.*}} base=InferRedundant
// CHECK-NEXT: (normal_conformance type="InferRedundant<T, U>" protocol="P2"
// CHECK-NEXT: (requirement "T" same_type "Constrained<U>"))
// CHECK-NEXT: (normal_conformance type="InferRedundant<T, U>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="InferRedundant<Constrained<U>, U>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="InferRedundant<Constrained<U>, U>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" same_type "Constrained<U>"))
extension InferRedundant: P2 where T == Constrained<U> {}
func infer_redundant_good<U: P1>(_: U) {
takes_P2(InferRedundant<Constrained<U>, U>())
@@ -157,8 +191,12 @@ class C3: C2 {}
struct ClassFree<T> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=ClassFree
// CHECK-LABEL: ExtensionDecl line={{.*}} base=ClassFree
// CHECK-NEXT: (normal_conformance type="ClassFree<T>" protocol="P2"
// CHECK-NEXT: (requirement "T" subclass_of "C1"))
// CHECK-NEXT: (normal_conformance type="ClassFree<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="ClassFree<T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="ClassFree<T>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" subclass_of "C1"))
extension ClassFree: P2 where T: C1 {} // expected-note {{requirement from conditional conformance of 'ClassFree<U>' to 'P2'}}
func class_free_good<U: C1>(_: U) {
takes_P2(ClassFree<U>())
@@ -171,8 +209,12 @@ func class_free_bad<U>(_: U) {
struct ClassMoreSpecific<T: C1> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=ClassMoreSpecific
// CHECK-LABEL: ExtensionDecl line={{.*}} base=ClassMoreSpecific
// CHECK-NEXT: (normal_conformance type="ClassMoreSpecific<T>" protocol="P2"
// CHECK-NEXT: (requirement "T" subclass_of "C3"))
// CHECK-NEXT: (normal_conformance type="ClassMoreSpecific<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="ClassMoreSpecific<T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="ClassMoreSpecific<T>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" subclass_of "C3"))
extension ClassMoreSpecific: P2 where T: C3 {} // expected-note {{requirement from conditional conformance of 'ClassMoreSpecific<U>' to 'P2'}}
func class_more_specific_good<U: C3>(_: U) {
takes_P2(ClassMoreSpecific<U>())
@@ -186,7 +228,11 @@ func class_more_specific_bad<U: C1>(_: U) {
struct ClassLessSpecific<T: C3> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=ClassLessSpecific
// CHECK-LABEL: ExtensionDecl line={{.*}} base=ClassLessSpecific
// CHECK-NEXT: (normal_conformance type="ClassLessSpecific<T>" protocol="P2")
// CHECK-NEXT: (normal_conformance type="ClassLessSpecific<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="ClassLessSpecific<T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="ClassLessSpecific<T>" protocol="Escapable")))
extension ClassLessSpecific: P2 where T: C1 {}
@@ -210,15 +256,23 @@ struct InheritEqual<T> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=InheritEqual
// CHECK-LABEL: ExtensionDecl line={{.*}} base=InheritEqual
// CHECK-NEXT: (normal_conformance type="InheritEqual<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="InheritEqual<T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="InheritEqual<T>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" conforms_to "P1"))
extension InheritEqual: P2 where T: P1 {} // expected-note {{requirement from conditional conformance of 'InheritEqual<U>' to 'P2'}}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=InheritEqual
// CHECK-LABEL: ExtensionDecl line={{.*}} base=InheritEqual
// CHECK-NEXT: (normal_conformance type="InheritEqual<T>" protocol="P5"
// CHECK-NEXT: (assoc_conformance type="Self" proto="P2"
// CHECK-NEXT: (normal_conformance type="InheritEqual<T>" protocol="P2"
// CHECK-NEXT: (requirement "T" conforms_to "P1")))
// CHECK-NEXT: (requirement "T" conforms_to "P1"))
// CHECK-LABEL: (normal_conformance type="InheritEqual<T>" protocol="P5"
// CHECK-LABEL: (assoc_conformance type="Self" proto="P2"
// CHECK-LABEL: (normal_conformance type="InheritEqual<T>" protocol="P2"
// CHECK-LABEL: (assoc_conformance type="Self" proto="Copyable"
// CHECK-LABEL: (builtin_conformance type="InheritEqual<T>" protocol="Copyable"))
// CHECK-LABEL: (assoc_conformance type="Self" proto="Escapable"
// CHECK-LABEL: (builtin_conformance type="InheritEqual<T>" protocol="Escapable"))
// CHECK-LABEL: (requirement "T" conforms_to "P1")))
// CHECK-LABEL: (requirement "T" conforms_to "P1"))
extension InheritEqual: P5 where T: P1 {} // expected-note {{requirement from conditional conformance of 'InheritEqual<U>' to 'P5'}}
func inheritequal_good<U: P1>(_: U) {
takes_P2(InheritEqual<U>())
@@ -243,6 +297,10 @@ struct InheritMore<T> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=InheritMore
// CHECK-LABEL: ExtensionDecl line={{.*}} base=InheritMore
// CHECK-NEXT: (normal_conformance type="InheritMore<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="InheritMore<T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="InheritMore<T>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" conforms_to "P1"))
extension InheritMore: P2 where T: P1 {} // expected-note {{requirement from conditional conformance of 'InheritMore<U>' to 'P2'}}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=InheritMore
@@ -250,6 +308,10 @@ extension InheritMore: P2 where T: P1 {} // expected-note {{requirement from con
// CHECK-NEXT: (normal_conformance type="InheritMore<T>" protocol="P5"
// CHECK-NEXT: (assoc_conformance type="Self" proto="P2"
// CHECK-NEXT: (normal_conformance type="InheritMore<T>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="InheritMore<T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="InheritMore<T>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" conforms_to "P1")))
// CHECK-NEXT: (requirement "T" conforms_to "P4"))
extension InheritMore: P5 where T: P4 {} // expected-note 2 {{requirement from conditional conformance of 'InheritMore<U>' to 'P5'}}
@@ -332,16 +394,24 @@ extension TwoDisjointConformances: P2 where T == String {}
struct RedundancyOrderDependenceGood<T: P1, U> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=RedundancyOrderDependenceGood
// CHECK-LABEL: ExtensionDecl line={{.*}} base=RedundancyOrderDependenceGood
// CHECK-NEXT: (normal_conformance type="RedundancyOrderDependenceGood<T, U>" protocol="P2"
// CHECK-NEXT: (requirement "T" same_type "U"))
// CHECK-NEXT: (normal_conformance type="RedundancyOrderDependenceGood<T, U>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="RedundancyOrderDependenceGood<T, T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="RedundancyOrderDependenceGood<T, T>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" same_type "U"))
extension RedundancyOrderDependenceGood: P2 where U: P1, T == U {}
struct RedundancyOrderDependenceBad<T, U: P1> {}
// CHECK-LABEL: ExtensionDecl line={{.*}} base=RedundancyOrderDependenceBad
// CHECK-LABEL: ExtensionDecl line={{.*}} base=RedundancyOrderDependenceBad
// CHECK-NEXT: (normal_conformance type="RedundancyOrderDependenceBad<T, U>" protocol="P2"
// CHECK-NEXT: (requirement "T" conforms_to "P1")
// CHECK-NEXT: (requirement "T" same_type "U"))
// CHECK-NEXT: (normal_conformance type="RedundancyOrderDependenceBad<T, U>" protocol="P2"
// CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
// CHECK-NEXT: (builtin_conformance type="RedundancyOrderDependenceBad<T, T>" protocol="Copyable"))
// CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
// CHECK-NEXT: (builtin_conformance type="RedundancyOrderDependenceBad<T, T>" protocol="Escapable"))
// CHECK-NEXT: (requirement "T" conforms_to "P1")
// CHECK-NEXT: (requirement "T" same_type "U"))
extension RedundancyOrderDependenceBad: P2 where T: P1, T == U {}
// Checking of conditional requirements for existential conversions.

View File

@@ -1,7 +1,5 @@
// RUN: %target-typecheck-verify-swift %clang-importer-sdk -dump-requirement-machine 2>&1 | %FileCheck %s
// XFAIL: noncopyable_generics
// REQUIRES: objc_interop
import Foundation
@@ -15,9 +13,16 @@ func foo<T : Generic<U>, U>(_: T, _: U) {
// CHECK: Requirement machine for fresh signature < T U >
// CHECK-NEXT: Rewrite system: {
// CHECK-NEXT: - [Copyable].[Copyable] => [Copyable] [permanent]
// CHECK-NEXT: - [Escapable].[Escapable] => [Escapable] [permanent]
// CHECK-NEXT: - τ_0_1.[Copyable] => τ_0_1 [explicit]
// CHECK-NEXT: - τ_0_1.[Escapable] => τ_0_1 [explicit]
// CHECK-NEXT: - τ_0_0.[superclass: Generic<τ_0_1>] => τ_0_0
// CHECK-NEXT: - τ_0_0.[layout: AnyObject] => τ_0_0
// CHECK-NEXT: }
// CHECK: Property map: {
// CHECK-NEXT: [Copyable] => { conforms_to: [Copyable] }
// CHECK-NEXT: [Escapable] => { conforms_to: [Escapable] }
// CHECK-NEXT: τ_0_1 => { conforms_to: [Copyable Escapable] }
// CHECK-NEXT: τ_0_0 => { layout: AnyObject superclass: [superclass: Generic<τ_0_1>] }
// CHECK-NEXT: }

View File

@@ -2,8 +2,6 @@
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -disable-requirement-machine-concrete-contraction 2>&1 | %FileCheck %s
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -disable-requirement-machine-concrete-contraction -dump-requirement-machine 2>&1 | %FileCheck %s --check-prefix=RULE
// XFAIL: noncopyable_generics
protocol P {}
class Base : P {}
@@ -21,13 +19,23 @@ extension G where X : Base, X : P, X == Derived {}
// RULE: + (requirement "\xCF\x84_0_0" same_type "Derived")
// RULE: Rewrite system: {
// RULE-NEXT: - [Copyable].[Copyable] => [Copyable] [permanent]
// RULE-NEXT: - [Escapable].[Escapable] => [Escapable] [permanent]
// RULE-NEXT: - [P].[P] => [P] [permanent]
// RULE-NEXT: - [P].[Copyable] => [P] [explicit]
// RULE-NEXT: - [P].[Escapable] => [P] [explicit]
// RULE-NEXT: - τ_0_0.[Copyable] => τ_0_0 [explicit]
// RULE-NEXT: - τ_0_0.[Escapable] => τ_0_0 [explicit]
// RULE-NEXT: - τ_0_0.[superclass: Base] => τ_0_0 [explicit]
// RULE-NEXT: - τ_0_0.[P] => τ_0_0 [explicit]
// RULE-NEXT: - τ_0_0.[concrete: Derived] => τ_0_0 [explicit]
// RULE-NEXT: - τ_0_0.[layout: _NativeClass] => τ_0_0
// RULE-NEXT: - τ_0_0.[superclass: Derived] => τ_0_0
// RULE-NEXT: - τ_0_0.[concrete: Derived : Copyable] => τ_0_0
// RULE-NEXT: - τ_0_0.[concrete: Derived : Escapable] => τ_0_0
// RULE-NEXT: - τ_0_0.[concrete: Derived : P] => τ_0_0
// RULE-NEXT: - τ_0_0.[concrete: Base : Copyable] => τ_0_0
// RULE-NEXT: - τ_0_0.[concrete: Base : Escapable] => τ_0_0
// RULE-NEXT: - τ_0_0.[concrete: Base : P] => τ_0_0
// RULE-NEXT: }

View File

@@ -1,7 +1,5 @@
// RUN: %target-typecheck-verify-swift
// XFAIL: noncopyable_generics
public protocol P {
associatedtype A
associatedtype B: P
@@ -17,7 +15,7 @@ extension Never: Q, P { // expected-note 2{{through reference here}}
public static func f() -> Any? { nil }
}
extension Q {
public var b: Never { fatalError() } // expected-note {{through reference here}}
extension Q { // expected-note {{through reference here}}
public var b: Never { fatalError() } // expected-note 4{{through reference here}}
}

View File

@@ -2,8 +2,6 @@
// 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
// RUN: %target-swift-frontend -emit-silgen %s -I %t
// XFAIL: noncopyable_generics
import rdar79564324_other
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 {
// CHECK-NEXT: - [P].[P] => [P] [permanent]
// CHECK-NEXT: - [P].A => [P:A] [permanent]
// CHECK-NEXT: - [P:A].[P] => [P:A]
// CHECK-NEXT: - [P].[Copyable] => [P] [explicit]
// CHECK-NEXT: - [P].[Escapable] => [P] [explicit]
// CHECK-NEXT: - [P:A].[Copyable] => [P:A] [explicit]
// CHECK-NEXT: - [P:A].[Escapable] => [P:A] [explicit]
// CHECK-NEXT: - [P].[P:A] => [P:A]
// CHECK-NEXT: - [P:A].A => [P:A].[P:A]
// CHECK-NEXT: - [Copyable].[Copyable] => [Copyable] [permanent]
// CHECK-NEXT: - [Escapable].[Escapable] => [Escapable] [permanent]
// CHECK-NEXT: - τ_0_0.A => τ_0_0
// CHECK-NEXT: - τ_0_1.[P] => τ_0_1
// CHECK-NEXT: - τ_0_1.A => τ_0_0
// CHECK-NEXT: - τ_0_0.[Copyable] => τ_0_0 [explicit]
// CHECK-NEXT: - τ_0_0.[Escapable] => τ_0_0 [explicit]
// CHECK-NEXT: - τ_0_1.[Copyable] => τ_0_1 [explicit]
// CHECK-NEXT: - τ_0_1.[Escapable] => τ_0_1 [explicit]
// CHECK-NEXT: - τ_0_1.[P:A] => τ_0_0
// CHECK-NEXT: - τ_0_0.[P] => τ_0_0
// CHECK-NEXT: - τ_0_0.[P:A] => τ_0_0
// CHECK-NEXT: }
// CHECK: Property map: {
// CHECK-NEXT: [P] => { conforms_to: [P] }
// CHECK-NEXT: [P:A] => { conforms_to: [P] }
// CHECK-NEXT: τ_0_1 => { conforms_to: [P] }
// CHECK-NEXT: τ_0_0 => { conforms_to: [P] }
// CHECK-NEXT: [P] => { conforms_to: [P Copyable Escapable] }
// CHECK-NEXT: [P:A] => { conforms_to: [P Copyable Escapable] }
// CHECK-NEXT: [Copyable] => { conforms_to: [Copyable] }
// CHECK-NEXT: [Escapable] => { conforms_to: [Escapable] }
// CHECK-NEXT: τ_0_1 => { conforms_to: [P Copyable Escapable] }
// CHECK-NEXT: τ_0_0 => { conforms_to: [Copyable Escapable P] }
// CHECK-NEXT: }

View File

@@ -1,7 +1,5 @@
// RUN: %target-typecheck-verify-swift -enable-experimental-feature TupleConformances
// XFAIL: noncopyable_generics
// Because of -enable-experimental-feature TupleConformances
// REQUIRES: asserts

View File

@@ -1,7 +1,5 @@
// RUN: %target-typecheck-verify-swift -dump-requirement-machine 2>&1 | %FileCheck %s
// XFAIL: noncopyable_generics
struct Foo<A, B> {}
protocol P1 {
@@ -29,6 +27,6 @@ struct MergeTest<G : P1a & P2a> {}
// CHECK: - τ_0_0.[P1a:T].[P2:X] => τ_0_0.[P1a:T].[P1:X]
// CHECK: }
// CHECK: Property map: {
// CHECK: τ_0_0 => { conforms_to: [P1a P2a] }
// CHECK: τ_0_0.[P1a:T] => { conforms_to: [P1 P2] }
// CHECK: τ_0_0 => { conforms_to: [P1a P2a Copyable Escapable] }
// CHECK: τ_0_0.[P1a:T] => { conforms_to: [P1 Copyable Escapable P2] }
// CHECK: }

View File

@@ -1,7 +1,5 @@
// RUN: %target-typecheck-verify-swift -dump-requirement-machine 2>&1 | %FileCheck %s
// XFAIL: noncopyable_generics
struct Foo<A, B> {}
protocol P1 {
@@ -29,5 +27,5 @@ struct MergeTest<G : P1 & P2> {
// CHECK-LABEL: Property map: {
// CHECK: [P1:X] => { concrete_type: [concrete: Foo<[P1:Y1], [P1:Z1]>] }
// CHECK: [P2:X] => { concrete_type: [concrete: Foo<[P2:Y2], [P2:Z2]>] }
// CHECK: τ_0_0 => { conforms_to: [P1 P2] }
// CHECK: τ_0_0 => { conforms_to: [P1 P2 Copyable Escapable] }
// CHECK: }

View File

@@ -1,7 +1,5 @@
// RUN: %target-typecheck-verify-swift -dump-requirement-machine 2>&1 | %FileCheck %s
// XFAIL: noncopyable_generics
protocol P1 {
associatedtype T : P1
}
@@ -34,6 +32,6 @@ struct G<T : P2a & P3a> {}
// CHECK: - τ_0_0.[P2a:T].[P2:T].[concrete: X<τ_0_0.[P3a:U].[P1:T]>] => τ_0_0.[P2a:T].[P2:T]
// CHECK: }
// CHECK-LABEL: Property map: {
// CHECK: τ_0_0.[P2a:T] => { conforms_to: [P2] concrete_type: [concrete: X<τ_0_0.[P3a:U]>] }
// CHECK: τ_0_0.[P2a:T].[P2:T] => { concrete_type: [concrete: X<τ_0_0.[P3a:U].[P1:T]>] }
// CHECK: τ_0_0.[P2a:T] => { conforms_to: [P2 Copyable Escapable] concrete_type: [concrete: X<τ_0_0.[P3a:U]>] }
// CHECK: τ_0_0.[P2a:T].[P2:T] => { conforms_to: [Copyable Escapable] concrete_type: [concrete: X<τ_0_0.[P3a:U].[P1:T]>] }
// CHECK: }

View File

@@ -1,7 +1,5 @@
// RUN: %target-typecheck-verify-swift -dump-requirement-machine 2>&1 | %FileCheck %s
// XFAIL: noncopyable_generics
protocol P1 {
associatedtype A : P1
associatedtype B : P1
@@ -58,8 +56,8 @@ struct G<T : P1 & P2> {}
// CHECK: - τ_0_0.[P1:B].[P1:B].[P1:B] => τ_0_0.[P1:B]
// CHECK: }
// CHECK-LABEL: Property map: {
// CHECK: τ_0_0.[P1:A] => { conforms_to: [P1] concrete_type: [concrete: S1] }
// CHECK: τ_0_0.[P1:B] => { conforms_to: [P1] concrete_type: [concrete: S2] }
// CHECK: τ_0_0.[P1:A].[P1:B] => { conforms_to: [P1] concrete_type: [concrete: S2] }
// CHECK: τ_0_0.[P1:B].[P1:B] => { conforms_to: [P1] concrete_type: [concrete: S1] }
// CHECK: τ_0_0.[P1:A] => { conforms_to: [P1 Copyable Escapable] concrete_type: [concrete: S1] }
// CHECK: τ_0_0.[P1:B] => { conforms_to: [P1 Copyable Escapable] concrete_type: [concrete: S2] }
// CHECK: τ_0_0.[P1:A].[P1:B] => { conforms_to: [P1 Copyable Escapable] concrete_type: [concrete: S2] }
// CHECK: τ_0_0.[P1:B].[P1:B] => { conforms_to: [P1 Copyable Escapable] concrete_type: [concrete: S1] }
// CHECK: }

View File

@@ -1,7 +1,5 @@
// RUN: %target-typecheck-verify-swift -dump-requirement-machine 2>&1 | %FileCheck %s
// XFAIL: noncopyable_generics
class Base {}
class Derived : Base {
func derivedMethod() {}
@@ -20,6 +18,8 @@ extension P where Self : Derived {
// CHECK-NEXT: - [P].[P] => [P] [permanent]
// CHECK-NEXT: - [P].[superclass: Base] => [P]
// CHECK-NEXT: - [P].[layout: _NativeClass] => [P]
// CHECK-NEXT: - [Copyable].[Copyable] => [Copyable] [permanent]
// CHECK-NEXT: - [Escapable].[Escapable] => [Escapable] [permanent]
// CHECK-NEXT: - τ_0_0.[P] => τ_0_0
// CHECK-NEXT: - τ_0_0.[superclass: Derived] => τ_0_0
// CHECK-NEXT: - τ_0_0.[superclass: Base] => τ_0_0
@@ -27,5 +27,7 @@ extension P where Self : Derived {
// CHECK-NEXT: }
// CHECK: Property map: {
// CHECK-NEXT: [P] => { conforms_to: [P] layout: _NativeClass superclass: [superclass: Base] }
// CHECK-NEXT: [Copyable] => { conforms_to: [Copyable] }
// CHECK-NEXT: [Escapable] => { conforms_to: [Escapable] }
// CHECK-NEXT: τ_0_0 => { conforms_to: [P] layout: _NativeClass superclass: [superclass: Derived] }
// CHECK-NEXT: }

View File

@@ -1,8 +1,6 @@
// RUN: %target-typecheck-verify-swift -debug-generic-signatures -disable-requirement-machine-reuse 2>&1 | %FileCheck %s
// RUN: %target-typecheck-verify-swift -dump-requirement-machine -disable-requirement-machine-reuse 2>&1 | %FileCheck %s --check-prefix=CHECK-RULE
// XFAIL: noncopyable_generics
// Note: The GSB fails this test, because it doesn't implement unification of
// superclass type constructor arguments.
@@ -51,12 +49,18 @@ func unifySuperclassTest<T : P1 & P2>(_: T) {
// CHECK-RULE: - τ_0_0.B2 => τ_0_0.[P1:B1]
// CHECK-RULE: }
// CHECK-RULE: Property map: {
// CHECK-RULE-NEXT: [P1] => { conforms_to: [P1] }
// CHECK-RULE-NEXT: [P1] => { conforms_to: [P1 Copyable Escapable] }
// CHECK-RULE-NEXT: [P1:A1] => { conforms_to: [Copyable Escapable] }
// CHECK-RULE-NEXT: [P1:B1] => { conforms_to: [Copyable Escapable] }
// CHECK-RULE-NEXT: [P1:X] => { layout: _NativeClass superclass: [superclass: Generic<Int, [P1:A1], [P1:B1]>] }
// CHECK-RULE-NEXT: [P2] => { conforms_to: [P2] }
// CHECK-RULE-NEXT: [P2] => { conforms_to: [P2 Copyable Escapable] }
// CHECK-RULE-NEXT: [P2:A2] => { conforms_to: [Copyable Escapable] }
// CHECK-RULE-NEXT: [P2:B2] => { conforms_to: [Copyable Escapable] }
// CHECK-RULE-NEXT: [P2:X] => { layout: _NativeClass superclass: [superclass: Generic<[P2:A2], String, [P2:B2]>] }
// CHECK-RULE-NEXT: τ_0_0 => { conforms_to: [P1 P2] }
// CHECK-RULE-NEXT: τ_0_0.[P1:A1] => { concrete_type: [concrete: String] }
// CHECK-RULE-NEXT: [Copyable] => { conforms_to: [Copyable] }
// CHECK-RULE-NEXT: [Escapable] => { conforms_to: [Escapable] }
// CHECK-RULE-NEXT: τ_0_0 => { conforms_to: [P1 P2 Copyable Escapable] }
// CHECK-RULE-NEXT: τ_0_0.[P1:A1] => { conforms_to: [Copyable Escapable] concrete_type: [concrete: String] }
// CHECK-RULE-NEXT: τ_0_0.[P1:X] => { layout: _NativeClass superclass: [superclass: Generic<Int, String, τ_0_0.[P1:B1]>] }
// CHECK-RULE-NEXT: τ_0_0.[P2:A2] => { concrete_type: [concrete: Int] }
// CHECK-RULE-NEXT: τ_0_0.[P2:A2] => { conforms_to: [Copyable Escapable] concrete_type: [concrete: Int] }
// CHECK-RULE-NEXT: }

View File

@@ -1,8 +1,6 @@
// RUN: %target-typecheck-verify-swift -debug-generic-signatures -disable-requirement-machine-reuse 2>&1 | %FileCheck %s
// RUN: %target-typecheck-verify-swift -dump-requirement-machine -disable-requirement-machine-reuse 2>&1 | %FileCheck %s --check-prefix=CHECK-RULE
// XFAIL: noncopyable_generics
// Note: The GSB fails this test, because it doesn't implement unification of
// superclass type constructor arguments.
@@ -55,12 +53,18 @@ func unifySuperclassTest<T : P1 & P2>(_: T) {
// CHECK-RULE: - τ_0_0.B2 => τ_0_0.[P1:B1]
// CHECK-RULE: }
// CHECK-RULE: Property map: {
// CHECK-RULE-NEXT: [P1] => { conforms_to: [P1] }
// CHECK-RULE-NEXT: [P1] => { conforms_to: [P1 Copyable Escapable] }
// CHECK-RULE-NEXT: [P1:A1] => { conforms_to: [Copyable Escapable] }
// CHECK-RULE-NEXT: [P1:B1] => { conforms_to: [Copyable Escapable] }
// CHECK-RULE-NEXT: [P1:X] => { layout: _NativeClass superclass: [superclass: Derived<[P1:A1], [P1:B1]>] }
// CHECK-RULE-NEXT: [P2] => { conforms_to: [P2] }
// CHECK-RULE-NEXT: [P2] => { conforms_to: [P2 Copyable Escapable] }
// CHECK-RULE-NEXT: [P2:A2] => { conforms_to: [Copyable Escapable] }
// CHECK-RULE-NEXT: [P2:B2] => { conforms_to: [Copyable Escapable] }
// CHECK-RULE-NEXT: [P2:X] => { layout: _NativeClass superclass: [superclass: Generic<[P2:A2], String, [P2:B2]>] }
// CHECK-RULE-NEXT: τ_0_0 => { conforms_to: [P1 P2] }
// CHECK-RULE-NEXT: τ_0_0.[P2:A2] => { concrete_type: [concrete: Int] }
// CHECK-RULE-NEXT: [Copyable] => { conforms_to: [Copyable] }
// CHECK-RULE-NEXT: [Escapable] => { conforms_to: [Escapable] }
// CHECK-RULE-NEXT: τ_0_0 => { conforms_to: [P1 P2 Copyable Escapable] }
// CHECK-RULE-NEXT: τ_0_0.[P2:A2] => { conforms_to: [Copyable Escapable] concrete_type: [concrete: Int] }
// CHECK-RULE-NEXT: τ_0_0.[P1:X] => { layout: _NativeClass superclass: [superclass: Derived<τ_0_0.[P1:A1], τ_0_0.[P1:B1]>] }
// CHECK-RULE-NEXT: τ_0_0.[P1:A1] => { concrete_type: [concrete: String] }
// CHECK-RULE-NEXT: τ_0_0.[P1:A1] => { conforms_to: [Copyable Escapable] concrete_type: [concrete: String] }
// CHECK-RULE-NEXT: }

View File

@@ -1,7 +1,5 @@
// RUN: %target-typecheck-verify-swift -dump-requirement-machine 2>&1 | %FileCheck %s
// XFAIL: noncopyable_generics
// Note: The GSB fails this test, because it doesn't implement unification of
// superclass type constructor arguments.
@@ -47,12 +45,16 @@ func unifySuperclassTest<T : P1 & P2>(_: T) {
// CHECK: - τ_0_0.[P2:A2].[Q:T] => τ_0_0.[P1:A1]
// CHECK-NEXT: }
// CHECK: Property map: {
// CHECK-NEXT: [P1] => { conforms_to: [P1] }
// CHECK-NEXT: [P1] => { conforms_to: [P1 Copyable Escapable] }
// CHECK-NEXT: [P1:X] => { layout: _NativeClass superclass: [superclass: Base<[P1:A1]>] }
// CHECK-NEXT: [P2] => { conforms_to: [P2] }
// CHECK-NEXT: [P1:A1] => { conforms_to: [Copyable Escapable] }
// CHECK-NEXT: [P2] => { conforms_to: [P2 Copyable Escapable] }
// CHECK-NEXT: [P2:X] => { layout: _NativeClass superclass: [superclass: Derived<[P2:A2]>] }
// CHECK-NEXT: [P2:A2] => { conforms_to: [Q] }
// CHECK-NEXT: [Q] => { conforms_to: [Q] }
// CHECK-NEXT: τ_0_0 => { conforms_to: [P1 P2] }
// CHECK-NEXT: [P2:A2] => { conforms_to: [Q Copyable Escapable] }
// CHECK-NEXT: [Copyable] => { conforms_to: [Copyable] }
// CHECK-NEXT: [Escapable] => { conforms_to: [Escapable] }
// CHECK-NEXT: [Q] => { conforms_to: [Q Copyable Escapable] }
// CHECK-NEXT: [Q:T] => { conforms_to: [Copyable Escapable] }
// CHECK-NEXT: τ_0_0 => { conforms_to: [P1 P2 Copyable Escapable] }
// CHECK-NEXT: τ_0_0.[P1:X] => { layout: _NativeClass superclass: [superclass: Derived<τ_0_0.[P2:A2]>] }
// CHECK-NEXT: }