From 4d4f55c16fda48a6aa34c2f2a3cc906a35677794 Mon Sep 17 00:00:00 2001 From: Ben Cohen Date: Sun, 26 Oct 2025 12:56:46 -0700 Subject: [PATCH] Allow Equatable: ~Escapable --- stdlib/public/core/Equatable.swift | 4 +- .../anyhashable_and_operator_filtering.swift | 2 +- test/Constraints/rdar158063151.swift | 2 +- .../run-call-genericEquatable-x2-to-bool.sil | 2 +- test/SILGen/enum_equatable_witness.swift | 16 +- test/SILGen/pack_iteration.swift | 4 +- .../SILGen/synthesized_conformance_enum.swift | 2 +- .../synthesized_conformance_struct.swift | 2 +- .../doc_clang_module.swift.response | 42 ++-- .../doc_clang_module.swift.sub.response | 6 +- .../doc_swift_module.swift.response | 229 ++++++++++-------- test/SymbolGraph/Module/ThirdOrder.swift | 4 +- ...tability-stdlib-source-base.swift.expected | 8 +- .../stability-stdlib-abi-without-asserts.test | 7 +- test/stdlib/NoncopyableEquatable.swift | 54 ++++- 15 files changed, 220 insertions(+), 164 deletions(-) diff --git a/stdlib/public/core/Equatable.swift b/stdlib/public/core/Equatable.swift index 0692b931f1a18..19f84d8b7ca5d 100644 --- a/stdlib/public/core/Equatable.swift +++ b/stdlib/public/core/Equatable.swift @@ -164,7 +164,7 @@ /// let c = a /// print(c === a, c === b, separator: ", ") /// // Prints "true, false" -public protocol Equatable: ~Copyable { +public protocol Equatable: ~Copyable, ~Escapable { /// Returns a Boolean value indicating whether two values are equal. /// /// Equality is the inverse of inequality. For any values `a` and `b`, @@ -176,7 +176,7 @@ public protocol Equatable: ~Copyable { static func == (lhs: borrowing Self, rhs: borrowing Self) -> Bool } -extension Equatable where Self: ~Copyable { +extension Equatable where Self: ~Copyable & ~Escapable { /// Returns a Boolean value indicating whether two values are not equal. /// /// Inequality is the inverse of equality. For any values `a` and `b`, `a != b` diff --git a/test/Constraints/anyhashable_and_operator_filtering.swift b/test/Constraints/anyhashable_and_operator_filtering.swift index c23a360b78a60..14fdb0d73f08c 100644 --- a/test/Constraints/anyhashable_and_operator_filtering.swift +++ b/test/Constraints/anyhashable_and_operator_filtering.swift @@ -26,5 +26,5 @@ func test(arr: [any P]) { // CHECK: sil private [ossa] @$s34anyhashable_and_operator_filtering4test3arrySayAA1P_pG_tFyAaD_pXEfU_ // CHECK: [[LHS_ARG:%.*]] = alloc_stack $E // CHECK: [[RHS_ARG:%.*]] = alloc_stack $E -// CHECK: [[GENERIC_OP:%.*]] = witness_method $E, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool +// CHECK: [[GENERIC_OP:%.*]] = witness_method $E, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool // CHECK-NEXT: apply [[GENERIC_OP]]([[LHS_ARG]], [[RHS_ARG]], {{.*}}) diff --git a/test/Constraints/rdar158063151.swift b/test/Constraints/rdar158063151.swift index 42b51ff059056..b8761773bc9f4 100644 --- a/test/Constraints/rdar158063151.swift +++ b/test/Constraints/rdar158063151.swift @@ -8,7 +8,7 @@ struct Value: Equatable, ExpressibleByNilLiteral { } // CHECK-LABEL: sil hidden [ossa] @$s13rdar1580631514test1vyAA5ValueV_tF : $@convention(thin) (Value) -> () -// CHECK: [[EQUALS_REF:%.*]] = witness_method $Value, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool +// CHECK: [[EQUALS_REF:%.*]] = witness_method $Value, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool // CHECK-NEXT: apply [[EQUALS_REF]]({{.*}}) func test(v: Value) { _ = v == nil diff --git a/test/IRGen/async/run-call-genericEquatable-x2-to-bool.sil b/test/IRGen/async/run-call-genericEquatable-x2-to-bool.sil index f9f63071616b6..5cc103fb18161 100644 --- a/test/IRGen/async/run-call-genericEquatable-x2-to-bool.sil +++ b/test/IRGen/async/run-call-genericEquatable-x2-to-bool.sil @@ -25,7 +25,7 @@ sil public_external @printBool : $@convention(thin) (Bool) -> () sil hidden @genericEquatableAndGenericEquatableToBool : $@async @convention(thin) (@in_guaranteed T, @in_guaranteed T) -> Bool { bb0(%0 : $*T, %1 : $*T): %4 = metatype $@thick T.Type - %5 = witness_method $T, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool : $@convention(witness_method: Equatable) <τ_0_0 where τ_0_0 : Equatable> (@in_guaranteed τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> Bool + %5 = witness_method $T, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool : $@convention(witness_method: Equatable) <τ_0_0 where τ_0_0 : Equatable> (@in_guaranteed τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> Bool %6 = apply %5(%0, %1, %4) : $@convention(witness_method: Equatable) <τ_0_0 where τ_0_0 : Equatable> (@in_guaranteed τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> Bool return %6 : $Bool } diff --git a/test/SILGen/enum_equatable_witness.swift b/test/SILGen/enum_equatable_witness.swift index 04ea8a57ff28b..e7f8621b6fa18 100644 --- a/test/SILGen/enum_equatable_witness.swift +++ b/test/SILGen/enum_equatable_witness.swift @@ -48,15 +48,15 @@ public enum Alphabet : String { // CHECK-LABEL: sil [ossa] @$s4main14check_alphabetySiAA8AlphabetOF : $@convention(thin) (Alphabet) -> Int { public func check_alphabet(_ state : Alphabet) -> Int { - // FRAGILE: witness_method $Alphabet, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool - // RESILIENT: witness_method $Alphabet, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool + // FRAGILE: witness_method $Alphabet, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool + // RESILIENT: witness_method $Alphabet, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool return state == .E ? 1 : 0 } // CHECK-LABEL: sil [ossa] @$s4main9compareItySbAA8AlphabetO_ADtF : $@convention(thin) (Alphabet, Alphabet) -> Bool { public func compareIt(_ state : Alphabet, _ rhs: Alphabet) -> Bool { - // FRAGILE: witness_method $Alphabet, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool - // RESILIENT: witness_method $Alphabet, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool + // FRAGILE: witness_method $Alphabet, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool + // RESILIENT: witness_method $Alphabet, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool return state == rhs } @@ -67,14 +67,14 @@ public enum AlphabetInt : Int { // CHECK-LABEL: sil [ossa] @$s4main18check_alphabet_intySiAA11AlphabetIntOF : $@convention(thin) (AlphabetInt) -> Int { public func check_alphabet_int(_ state : AlphabetInt) -> Int { - // FRAGILE: witness_method $AlphabetInt, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool - // RESILIENT: witness_method $AlphabetInt, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool + // FRAGILE: witness_method $AlphabetInt, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool + // RESILIENT: witness_method $AlphabetInt, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool return state == .E ? 1 : 0 } // CHECK-LABEL: sil [ossa] @$s4main9compareItySbAA11AlphabetIntO_ADtF : $@convention(thin) (AlphabetInt, AlphabetInt) -> Bool { public func compareIt(_ state : AlphabetInt, _ rhs: AlphabetInt) -> Bool { - // FRAGILE: witness_method $AlphabetInt, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool - // RESILIENT: witness_method $AlphabetInt, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool + // FRAGILE: witness_method $AlphabetInt, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool + // RESILIENT: witness_method $AlphabetInt, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool return state == rhs } diff --git a/test/SILGen/pack_iteration.swift b/test/SILGen/pack_iteration.swift index 52075f2b50659..53861390cc48e 100644 --- a/test/SILGen/pack_iteration.swift +++ b/test/SILGen/pack_iteration.swift @@ -84,8 +84,8 @@ func iterateTrivial(over element: repeat each Element) { // CHECK: tuple_pack_element_addr [[DYN_PACK_IDX]] of [[STACK1]] : $*(repeat each Element) as $*@pack_element("[[UUID]]") each Element // CHECK: tuple_pack_element_addr [[DYN_PACK_IDX]] of [[STACK2]] : $*(repeat each Element) as $*@pack_element("[[UUID]]") each Element // CHECK: [[METATYPE:%.*]] = metatype $@thick (@pack_element("[[UUID]]") each Element).Type -// CHECK: [[WITNESS_METHOD:%.*]] = witness_method $@pack_element("[[UUID]]") each Element, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool, [[OPEN_PACK_ELT]] : $Builtin.SILToken : $@convention(witness_method: Equatable) <τ_0_0 where τ_0_0 : Equatable, τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> Bool -// CHECK: apply [[WITNESS_METHOD]]<@pack_element("[[UUID]]") each Element>([[STACK_LEFT]], [[STACK_RIGHT]], [[METATYPE]]) : $@convention(witness_method: Equatable) <τ_0_0 where τ_0_0 : Equatable, τ_0_0 : ~Copyable> (@in_guaranteed τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> Bool +// CHECK: [[WITNESS_METHOD:%.*]] = witness_method $@pack_element("[[UUID]]") each Element, #Equatable."==" : (Self.Type) -> (borrowing Self, borrowing Self) -> Bool, [[OPEN_PACK_ELT]] : $Builtin.SILToken : $@convention(witness_method: Equatable) <τ_0_0 where τ_0_0 : Equatable, τ_0_0 : ~Copyable, τ_0_0 : ~Escapable> (@in_guaranteed τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> Bool +// CHECK: apply [[WITNESS_METHOD]]<@pack_element("[[UUID]]") each Element>([[STACK_LEFT]], [[STACK_RIGHT]], [[METATYPE]]) : $@convention(witness_method: Equatable) <τ_0_0 where τ_0_0 : Equatable, τ_0_0 : ~Copyable, τ_0_0 : ~Escapable> (@in_guaranteed τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> Bool // // CHECK: } // end sil function '$s14pack_iteration11equalTuples3lhs3rhsSbxxQp_t_xxQp_ttRvzSQRzlF' func equalTuples(lhs: (repeat each Element), rhs: (repeat each Element)) -> Bool { diff --git a/test/SILGen/synthesized_conformance_enum.swift b/test/SILGen/synthesized_conformance_enum.swift index 2bb082957bc64..29064c85cebb9 100644 --- a/test/SILGen/synthesized_conformance_enum.swift +++ b/test/SILGen/synthesized_conformance_enum.swift @@ -77,7 +77,7 @@ extension NoValues: Codable {} // Witness tables for Enum // CHECK-LABEL: sil_witness_table hidden Enum: Equatable module synthesized_conformance_enum { -// CHECK-NEXT: method #Equatable."==": (Self.Type) -> (borrowing Self, borrowing Self) -> Bool : @$s28synthesized_conformance_enum4EnumOyxGSQAASQRzlSQ2eeoiySbx_xtFZTW // protocol witness for static Equatable.== infix(_:_:) in conformance Enum +// CHECK-NEXT: method #Equatable."==": (Self.Type) -> (borrowing Self, borrowing Self) -> Bool : @$s28synthesized_conformance_enum4EnumOyxGSQAASQRzlSQ2eeoiySbx_xtFZTW // protocol witness for static Equatable.== infix(_:_:) in conformance Enum // CHECK-NEXT: conditional_conformance (T: Equatable): dependent // CHECK-NEXT: } diff --git a/test/SILGen/synthesized_conformance_struct.swift b/test/SILGen/synthesized_conformance_struct.swift index 185e4a345f5bf..08d8bb5bb650c 100644 --- a/test/SILGen/synthesized_conformance_struct.swift +++ b/test/SILGen/synthesized_conformance_struct.swift @@ -63,7 +63,7 @@ extension Struct: Codable where T: Codable {} // Witness tables // CHECK-LABEL: sil_witness_table hidden Struct: Equatable module synthesized_conformance_struct { -// CHECK-NEXT: method #Equatable."==": (Self.Type) -> (borrowing Self, borrowing Self) -> Bool : @$s30synthesized_conformance_struct6StructVyxGSQAASQRzlSQ2eeoiySbx_xtFZTW // protocol witness for static Equatable.== infix(_:_:) in conformance Struct +// CHECK-NEXT: method #Equatable."==": (Self.Type) -> (borrowing Self, borrowing Self) -> Bool : @$s30synthesized_conformance_struct6StructVyxGSQAASQRzlSQ2eeoiySbx_xtFZTW // protocol witness for static Equatable.== infix(_:_:) in conformance Struct // CHECK-NEXT: conditional_conformance (T: Equatable): dependent // CHECK-NEXT: } diff --git a/test/SourceKit/DocSupport/doc_clang_module.swift.response b/test/SourceKit/DocSupport/doc_clang_module.swift.response index 65403b31201a7..aca088c26496d 100644 --- a/test/SourceKit/DocSupport/doc_clang_module.swift.response +++ b/test/SourceKit/DocSupport/doc_clang_module.swift.response @@ -5253,9 +5253,9 @@ var FooSubUnnamedEnumeratorA1: Int { get } { key.kind: source.lang.swift.decl.function.operator.infix, key.name: "!=(_:_:)", - key.usr: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum1", - key.original_usr: "s:SQsRi_zrlE2neoiySbx_xtFZ", - key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum1static func != (lhs: borrowing FooEnum1, rhs: borrowing FooEnum1) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", + key.usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum1", + key.original_usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ", + key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum1static func != (lhs: borrowing FooEnum1, rhs: borrowing FooEnum1) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", key.offset: 288, key.length: 77, key.fully_annotated_decl: "@_preInverseGenerics static func != (lhs: borrowing FooEnum1, rhs: borrowing FooEnum1) -> Bool", @@ -5384,9 +5384,9 @@ var FooSubUnnamedEnumeratorA1: Int { get } { key.kind: source.lang.swift.decl.function.operator.infix, key.name: "!=(_:_:)", - key.usr: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum2", - key.original_usr: "s:SQsRi_zrlE2neoiySbx_xtFZ", - key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum2static func != (lhs: borrowing FooEnum2, rhs: borrowing FooEnum2) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", + key.usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum2", + key.original_usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ", + key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum2static func != (lhs: borrowing FooEnum2, rhs: borrowing FooEnum2) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", key.offset: 654, key.length: 77, key.fully_annotated_decl: "@_preInverseGenerics static func != (lhs: borrowing FooEnum2, rhs: borrowing FooEnum2) -> Bool", @@ -5522,9 +5522,9 @@ var FooSubUnnamedEnumeratorA1: Int { get } { key.kind: source.lang.swift.decl.function.operator.infix, key.name: "!=(_:_:)", - key.usr: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum3", - key.original_usr: "s:SQsRi_zrlE2neoiySbx_xtFZ", - key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum3static func != (lhs: borrowing FooEnum3, rhs: borrowing FooEnum3) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", + key.usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum3", + key.original_usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ", + key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooEnum3static func != (lhs: borrowing FooEnum3, rhs: borrowing FooEnum3) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", key.offset: 1053, key.length: 77, key.fully_annotated_decl: "@_preInverseGenerics static func != (lhs: borrowing FooEnum3, rhs: borrowing FooEnum3) -> Bool", @@ -5633,9 +5633,9 @@ var FooSubUnnamedEnumeratorA1: Int { get } { key.kind: source.lang.swift.decl.function.operator.infix, key.name: "!=(_:_:)", - key.usr: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooComparisonResult", - key.original_usr: "s:SQsRi_zrlE2neoiySbx_xtFZ", - key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooComparisonResultstatic func != (lhs: borrowing FooComparisonResult, rhs: borrowing FooComparisonResult) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", + key.usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooComparisonResult", + key.original_usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ", + key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooComparisonResultstatic func != (lhs: borrowing FooComparisonResult, rhs: borrowing FooComparisonResult) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", key.offset: 1424, key.length: 99, key.fully_annotated_decl: "@_preInverseGenerics static func != (lhs: borrowing FooComparisonResult, rhs: borrowing FooComparisonResult) -> Bool", @@ -5710,9 +5710,9 @@ var FooSubUnnamedEnumeratorA1: Int { get } { key.kind: source.lang.swift.decl.function.operator.infix, key.name: "!=(_:_:)", - key.usr: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooRuncingOptions", - key.original_usr: "s:SQsRi_zrlE2neoiySbx_xtFZ", - key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooRuncingOptionsstatic func != (lhs: borrowing FooRuncingOptions, rhs: borrowing FooRuncingOptions) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", + key.usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooRuncingOptions", + key.original_usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ", + key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooRuncingOptionsstatic func != (lhs: borrowing FooRuncingOptions, rhs: borrowing FooRuncingOptions) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", key.offset: 1716, key.length: 95, key.fully_annotated_decl: "@_preInverseGenerics static func != (lhs: borrowing FooRuncingOptions, rhs: borrowing FooRuncingOptions) -> Bool", @@ -7660,9 +7660,9 @@ var FooSubUnnamedEnumeratorA1: Int { get } { key.kind: source.lang.swift.decl.function.operator.infix, key.name: "!=(_:_:)", - key.usr: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@ABAuthorizationStatus", - key.original_usr: "s:SQsRi_zrlE2neoiySbx_xtFZ", - key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@ABAuthorizationStatusstatic func != (lhs: borrowing ABAuthorizationStatus, rhs: borrowing ABAuthorizationStatus) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", + key.usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@ABAuthorizationStatus", + key.original_usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ", + key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@ABAuthorizationStatusstatic func != (lhs: borrowing ABAuthorizationStatus, rhs: borrowing ABAuthorizationStatus) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", key.offset: 7953, key.length: 103, key.fully_annotated_decl: "@_preInverseGenerics static func != (lhs: borrowing ABAuthorizationStatus, rhs: borrowing ABAuthorizationStatus) -> Bool", @@ -7808,9 +7808,9 @@ var FooSubUnnamedEnumeratorA1: Int { get } { key.kind: source.lang.swift.decl.function.operator.infix, key.name: "!=(_:_:)", - key.usr: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooSubEnum1", - key.original_usr: "s:SQsRi_zrlE2neoiySbx_xtFZ", - key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooSubEnum1static func != (lhs: borrowing FooSubEnum1, rhs: borrowing FooSubEnum1) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", + key.usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooSubEnum1", + key.original_usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ", + key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooSubEnum1static func != (lhs: borrowing FooSubEnum1, rhs: borrowing FooSubEnum1) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", key.offset: 8354, key.length: 83, key.fully_annotated_decl: "@_preInverseGenerics static func != (lhs: borrowing FooSubEnum1, rhs: borrowing FooSubEnum1) -> Bool", diff --git a/test/SourceKit/DocSupport/doc_clang_module.swift.sub.response b/test/SourceKit/DocSupport/doc_clang_module.swift.sub.response index 0403f7c37bcb1..ac4c897f9ae33 100644 --- a/test/SourceKit/DocSupport/doc_clang_module.swift.sub.response +++ b/test/SourceKit/DocSupport/doc_clang_module.swift.sub.response @@ -462,9 +462,9 @@ var FooSubUnnamedEnumeratorA1: Int { get } { key.kind: source.lang.swift.decl.function.operator.infix, key.name: "!=(_:_:)", - key.usr: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooSubEnum1", - key.original_usr: "s:SQsRi_zrlE2neoiySbx_xtFZ", - key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooSubEnum1static func != (lhs: borrowing FooSubEnum1, rhs: borrowing FooSubEnum1) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", + key.usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooSubEnum1", + key.original_usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ", + key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooSubEnum1static func != (lhs: borrowing FooSubEnum1, rhs: borrowing FooSubEnum1) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", key.offset: 294, key.length: 83, key.fully_annotated_decl: "@_preInverseGenerics static func != (lhs: borrowing FooSubEnum1, rhs: borrowing FooSubEnum1) -> Bool", diff --git a/test/SourceKit/DocSupport/doc_swift_module.swift.response b/test/SourceKit/DocSupport/doc_swift_module.swift.response index 3abe0d9920281..89b20aaf0c5b9 100644 --- a/test/SourceKit/DocSupport/doc_swift_module.swift.response +++ b/test/SourceKit/DocSupport/doc_swift_module.swift.response @@ -147,7 +147,7 @@ struct S1 { } } -extension S1.SE where cake.S1.SE : ~Copyable { +extension S1.SE where cake.S1.SE : ~Copyable, cake.S1.SE : ~Escapable { static func != (_ lhs: borrowing cake.S1.SE, _ rhs: borrowing cake.S1.SE) -> Bool } @@ -1497,426 +1497,455 @@ func shouldPrintAnyAsKeyword(x x: Any) key.offset: 1837, key.length: 8 }, + { + key.kind: source.lang.swift.syntaxtype.typeidentifier, + key.offset: 1847, + key.length: 4 + }, + { + key.kind: source.lang.swift.ref.struct, + key.name: "S1", + key.usr: "s:4cake2S1V", + key.offset: 1852, + key.length: 2 + }, + { + key.kind: source.lang.swift.ref.enum, + key.name: "SE", + key.usr: "s:4cake2S1V2SEO", + key.offset: 1855, + key.length: 2 + }, + { + key.kind: source.lang.swift.syntaxtype.operator, + key.offset: 1860, + key.length: 1 + }, + { + key.kind: source.lang.swift.syntaxtype.typeidentifier, + key.offset: 1861, + key.length: 9 + }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 1853, + key.offset: 1878, key.length: 6 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 1860, + key.offset: 1885, key.length: 4 }, { key.kind: source.lang.swift.syntaxtype.operator, - key.offset: 1865, + key.offset: 1890, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.argument, - key.offset: 1869, + key.offset: 1894, key.length: 1 }, { key.kind: source.lang.swift.syntaxtype.parameter, - key.offset: 1871, + key.offset: 1896, key.length: 3 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 1876, + key.offset: 1901, key.length: 9 }, { key.kind: source.lang.swift.syntaxtype.typeidentifier, - key.offset: 1886, + key.offset: 1911, key.length: 4 }, { key.kind: source.lang.swift.ref.struct, key.name: "S1", key.usr: "s:4cake2S1V", - key.offset: 1891, + key.offset: 1916, key.length: 2 }, { key.kind: source.lang.swift.ref.enum, key.name: "SE", key.usr: "s:4cake2S1V2SEO", - key.offset: 1894, + key.offset: 1919, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.argument, - key.offset: 1898, + key.offset: 1923, key.length: 1 }, { key.kind: source.lang.swift.syntaxtype.parameter, - key.offset: 1900, + key.offset: 1925, key.length: 3 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 1905, + key.offset: 1930, key.length: 9 }, { key.kind: source.lang.swift.syntaxtype.typeidentifier, - key.offset: 1915, + key.offset: 1940, key.length: 4 }, { key.kind: source.lang.swift.ref.struct, key.name: "S1", key.usr: "s:4cake2S1V", - key.offset: 1920, + key.offset: 1945, key.length: 2 }, { key.kind: source.lang.swift.ref.enum, key.name: "SE", key.usr: "s:4cake2S1V2SEO", - key.offset: 1923, + key.offset: 1948, key.length: 2 }, { key.kind: source.lang.swift.ref.struct, key.name: "Bool", key.usr: "s:Sb", - key.offset: 1930, + key.offset: 1955, key.length: 4 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 1938, + key.offset: 1963, key.length: 6 }, { key.kind: source.lang.swift.syntaxtype.identifier, - key.offset: 1945, + key.offset: 1970, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.typeidentifier, - key.offset: 1950, + key.offset: 1975, key.length: 4 }, { key.kind: source.lang.swift.ref.protocol, key.name: "P3", key.usr: "s:4cake2P3P", - key.offset: 1955, + key.offset: 1980, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 1965, + key.offset: 1990, key.length: 9 }, { key.kind: source.lang.swift.syntaxtype.identifier, - key.offset: 1975, + key.offset: 2000, key.length: 1 }, { key.kind: source.lang.swift.syntaxtype.typeidentifier, - key.offset: 1979, + key.offset: 2004, key.length: 4 }, { key.kind: source.lang.swift.ref.struct, key.name: "S2", key.usr: "s:4cake2S2V", - key.offset: 1984, + key.offset: 2009, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 1990, + key.offset: 2015, key.length: 6 }, { key.kind: source.lang.swift.syntaxtype.identifier, - key.offset: 1997, + key.offset: 2022, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.identifier, - key.offset: 2000, + key.offset: 2025, key.length: 7 }, { key.kind: source.lang.swift.syntaxtype.typeidentifier, - key.offset: 2011, + key.offset: 2036, key.length: 4 }, { key.kind: source.lang.swift.ref.protocol, key.name: "P5", key.usr: "s:4cake2P5P", - key.offset: 2016, + key.offset: 2041, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 2019, + key.offset: 2044, key.length: 5 }, { key.kind: source.lang.swift.ref.generic_type_param, key.name: "Wrapped", key.usr: "s:4cake2S3V7Wrappedxmfp", - key.offset: 2025, + key.offset: 2050, key.length: 7 }, { key.kind: source.lang.swift.syntaxtype.typeidentifier, - key.offset: 2035, + key.offset: 2060, key.length: 4 }, { key.kind: source.lang.swift.ref.protocol, key.name: "P5", key.usr: "s:4cake2P5P", - key.offset: 2040, + key.offset: 2065, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 2050, + key.offset: 2075, key.length: 9 }, { key.kind: source.lang.swift.syntaxtype.identifier, - key.offset: 2060, + key.offset: 2085, key.length: 7 }, { key.kind: source.lang.swift.ref.generic_type_param, key.name: "Wrapped", key.usr: "s:4cake2S3V7Wrappedxmfp", - key.offset: 2070, + key.offset: 2095, key.length: 7 }, { key.kind: source.lang.swift.ref.associatedtype, key.name: "Element", key.usr: "s:4cake2P5P7ElementQa", - key.offset: 2078, + key.offset: 2103, key.length: 7 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 2089, + key.offset: 2114, key.length: 9 }, { key.kind: source.lang.swift.ref.struct, key.name: "S3", key.usr: "s:4cake2S3V", - key.offset: 2099, + key.offset: 2124, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 2102, + key.offset: 2127, key.length: 5 }, { key.kind: source.lang.swift.ref.generic_type_param, key.name: "Wrapped", key.usr: "s:4cake2S3V7Wrappedxmfp", - key.offset: 2108, + key.offset: 2133, key.length: 7 }, { key.kind: source.lang.swift.syntaxtype.typeidentifier, - key.offset: 2118, + key.offset: 2143, key.length: 4 }, { key.kind: source.lang.swift.ref.protocol, key.name: "P6", key.usr: "s:4cake2P6P", - key.offset: 2123, + key.offset: 2148, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 2133, + key.offset: 2158, key.length: 3 }, { key.kind: source.lang.swift.syntaxtype.identifier, - key.offset: 2137, + key.offset: 2162, key.length: 4 }, { key.kind: source.lang.swift.ref.generic_type_param, key.name: "Wrapped", key.usr: "s:4cake2S3V7Wrappedxmfp", - key.offset: 2143, + key.offset: 2168, key.length: 7 }, { key.kind: source.lang.swift.ref.associatedtype, key.name: "Element", key.usr: "s:4cake2P5P7ElementQa", - key.offset: 2151, + key.offset: 2176, key.length: 7 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 2162, + key.offset: 2187, key.length: 3 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 2171, + key.offset: 2196, key.length: 4 }, { key.kind: source.lang.swift.syntaxtype.identifier, - key.offset: 2176, + key.offset: 2201, key.length: 6 }, { key.kind: source.lang.swift.syntaxtype.identifier, - key.offset: 2183, + key.offset: 2208, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.identifier, - key.offset: 2187, + key.offset: 2212, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.argument, - key.offset: 2191, + key.offset: 2216, key.length: 1 }, { key.kind: source.lang.swift.syntaxtype.parameter, - key.offset: 2193, + key.offset: 2218, key.length: 2 }, { key.kind: source.lang.swift.ref.generic_type_param, key.name: "T1", key.usr: "s:4cake6genfoo1x1yyx_q_tAA4ProtRzAA2C1CRb_Si7ElementRtzr0_lF2T1L_xmfp", - key.offset: 2197, + key.offset: 2222, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.argument, - key.offset: 2201, + key.offset: 2226, key.length: 1 }, { key.kind: source.lang.swift.syntaxtype.parameter, - key.offset: 2203, + key.offset: 2228, key.length: 2 }, { key.kind: source.lang.swift.ref.generic_type_param, key.name: "T2", key.usr: "s:4cake6genfoo1x1yyx_q_tAA4ProtRzAA2C1CRb_Si7ElementRtzr0_lF2T2L_q_mfp", - key.offset: 2207, + key.offset: 2232, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 2211, + key.offset: 2236, key.length: 5 }, { key.kind: source.lang.swift.ref.generic_type_param, key.name: "T1", key.usr: "s:4cake6genfoo1x1yyx_q_tAA4ProtRzAA2C1CRb_Si7ElementRtzr0_lF2T1L_xmfp", - key.offset: 2217, + key.offset: 2242, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.typeidentifier, - key.offset: 2222, + key.offset: 2247, key.length: 4 }, { key.kind: source.lang.swift.ref.protocol, key.name: "Prot", key.usr: "s:4cake4ProtP", - key.offset: 2227, + key.offset: 2252, key.length: 4 }, { key.kind: source.lang.swift.ref.generic_type_param, key.name: "T2", key.usr: "s:4cake6genfoo1x1yyx_q_tAA4ProtRzAA2C1CRb_Si7ElementRtzr0_lF2T2L_q_mfp", - key.offset: 2233, + key.offset: 2258, key.length: 2 }, { key.kind: source.lang.swift.syntaxtype.typeidentifier, - key.offset: 2238, + key.offset: 2263, key.length: 4 }, { key.kind: source.lang.swift.ref.class, key.name: "C1", key.usr: "s:4cake2C1C", - key.offset: 2243, + key.offset: 2268, key.length: 2 }, { key.kind: source.lang.swift.ref.generic_type_param, key.name: "T1", key.usr: "s:4cake6genfoo1x1yyx_q_tAA4ProtRzAA2C1CRb_Si7ElementRtzr0_lF2T1L_xmfp", - key.offset: 2247, + key.offset: 2272, key.length: 2 }, { key.kind: source.lang.swift.ref.associatedtype, key.name: "Element", key.usr: "s:4cake4ProtP7ElementQa", - key.offset: 2250, + key.offset: 2275, key.length: 7 }, { key.kind: source.lang.swift.syntaxtype.operator, - key.offset: 2258, + key.offset: 2283, key.length: 2 }, { key.kind: source.lang.swift.ref.struct, key.name: "Int", key.usr: "s:Si", - key.offset: 2261, + key.offset: 2286, key.length: 3 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 2266, + key.offset: 2291, key.length: 4 }, { key.kind: source.lang.swift.syntaxtype.identifier, - key.offset: 2271, + key.offset: 2296, key.length: 23 }, { key.kind: source.lang.swift.syntaxtype.argument, - key.offset: 2295, + key.offset: 2320, key.length: 1 }, { key.kind: source.lang.swift.syntaxtype.parameter, - key.offset: 2297, + key.offset: 2322, key.length: 1 }, { key.kind: source.lang.swift.syntaxtype.keyword, - key.offset: 2300, + key.offset: 2325, key.length: 3 } ] @@ -2280,9 +2309,9 @@ func shouldPrintAnyAsKeyword(x x: Any) { key.kind: source.lang.swift.decl.function.operator.infix, key.name: "!=(_:_:)", - key.usr: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake2C1C0B5CasesO", - key.original_usr: "s:SQsRi_zrlE2neoiySbx_xtFZ", - key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake2C1C0B5CasesOstatic func != (lhs: borrowing cake.C1.C1Cases, rhs: borrowing cake.C1.C1Cases) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", + key.usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake2C1C0B5CasesO", + key.original_usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ", + key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake2C1C0B5CasesOstatic func != (lhs: borrowing cake.C1.C1Cases, rhs: borrowing cake.C1.C1Cases) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", key.offset: 721, key.length: 91, key.fully_annotated_decl: "@_preInverseGenerics static func != (lhs: borrowing C1.C1Cases, rhs: borrowing C1.C1Cases) -> Bool", @@ -2383,9 +2412,9 @@ func shouldPrintAnyAsKeyword(x x: Any) { key.kind: source.lang.swift.decl.function.operator.infix, key.name: "!=(_:_:)", - key.usr: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake6MyEnumO", - key.original_usr: "s:SQsRi_zrlE2neoiySbx_xtFZ", - key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake6MyEnumOstatic func != (lhs: borrowing cake.MyEnum, rhs: borrowing cake.MyEnum) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", + key.usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake6MyEnumO", + key.original_usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ", + key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake6MyEnumOstatic func != (lhs: borrowing cake.MyEnum, rhs: borrowing cake.MyEnum) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", key.offset: 994, key.length: 83, key.fully_annotated_decl: "@_preInverseGenerics static func != (lhs: borrowing MyEnum, rhs: borrowing MyEnum) -> Bool", @@ -2731,8 +2760,8 @@ func shouldPrintAnyAsKeyword(x x: Any) { key.kind: source.lang.swift.decl.extension.enum, key.offset: 1801, - key.length: 135, - key.fully_annotated_decl: "extension S1.SE where S1.SE : ~Copyable", + key.length: 160, + key.fully_annotated_decl: "extension S1.SE where S1.SE : ~Copyable, S1.SE : ~Escapable", key.extends: { key.kind: source.lang.swift.ref.enum, key.name: "SE", @@ -2742,10 +2771,10 @@ func shouldPrintAnyAsKeyword(x x: Any) { key.kind: source.lang.swift.decl.function.operator.infix, key.name: "!=(_:_:)", - key.usr: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake2S1V2SEO", - key.original_usr: "s:SQsRi_zrlE2neoiySbx_xtFZ", - key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake2S1V2SEOstatic func != (lhs: borrowing cake.S1.SE, rhs: borrowing cake.S1.SE) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", - key.offset: 1853, + key.usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake2S1V2SEO", + key.original_usr: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ", + key.doc.full_as_xml: "!=(_:_:)s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:4cake2S1V2SEOstatic func != (lhs: borrowing cake.S1.SE, rhs: borrowing cake.S1.SE) -> BoolReturns a Boolean value indicating whether two values are not equal.lhsinA value to compare.rhsinAnother value to compare.Inequality is the inverse of equality. For any values a and b, a != b implies that a == b is false.This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.", + key.offset: 1878, key.length: 81, key.fully_annotated_decl: "@_preInverseGenerics static func != (lhs: borrowing S1.SE, rhs: borrowing S1.SE) -> Bool", key.entities: [ @@ -2753,14 +2782,14 @@ func shouldPrintAnyAsKeyword(x x: Any) key.kind: source.lang.swift.decl.var.local, key.keyword: "_", key.name: "lhs", - key.offset: 1886, + key.offset: 1911, key.length: 10 }, { key.kind: source.lang.swift.decl.var.local, key.keyword: "_", key.name: "rhs", - key.offset: 1915, + key.offset: 1940, key.length: 10 } ] @@ -2771,7 +2800,7 @@ func shouldPrintAnyAsKeyword(x x: Any) key.kind: source.lang.swift.decl.struct, key.name: "S2", key.usr: "s:4cake2S2V", - key.offset: 1938, + key.offset: 1963, key.length: 50, key.fully_annotated_decl: "struct S2 : P3", key.conforms: [ @@ -2786,7 +2815,7 @@ func shouldPrintAnyAsKeyword(x x: Any) key.kind: source.lang.swift.decl.typealias, key.name: "T", key.usr: "s:4cake2S2V1Ta", - key.offset: 1965, + key.offset: 1990, key.length: 21, key.fully_annotated_decl: "typealias S2.T = S2", key.conforms: [ @@ -2813,7 +2842,7 @@ func shouldPrintAnyAsKeyword(x x: Any) key.description: "Wrapped : P5" } ], - key.offset: 1990, + key.offset: 2015, key.length: 97, key.fully_annotated_decl: "struct S3<Wrapped> : P5 where Wrapped : P5", key.conforms: [ @@ -2828,7 +2857,7 @@ func shouldPrintAnyAsKeyword(x x: Any) key.kind: source.lang.swift.decl.typealias, key.name: "Element", key.usr: "s:4cake2S3V7Elementa", - key.offset: 2050, + key.offset: 2075, key.length: 35, key.fully_annotated_decl: "typealias S3<Wrapped>.Element = Wrapped.Element", key.conforms: [ @@ -2853,7 +2882,7 @@ func shouldPrintAnyAsKeyword(x x: Any) key.description: "Wrapped : P6" } ], - key.offset: 2089, + key.offset: 2114, key.length: 80, key.fully_annotated_decl: "extension S3 where Wrapped : P6", key.extends: { @@ -2867,7 +2896,7 @@ func shouldPrintAnyAsKeyword(x x: Any) key.name: "null", key.usr: "s:4cake2P6PAAE4null7ElementQzSgvp::SYNTHESIZED::s:4cake2S3V", key.original_usr: "s:4cake2P6PAAE4null7ElementQzSgvp", - key.offset: 2133, + key.offset: 2158, key.length: 34, key.fully_annotated_decl: "var null: Wrapped.Element? { get }" } @@ -2896,7 +2925,7 @@ func shouldPrintAnyAsKeyword(x x: Any) key.description: "T1.Element == Int" } ], - key.offset: 2171, + key.offset: 2196, key.length: 93, key.fully_annotated_decl: "func genfoo<T1, T2>(x ix: T1, y iy: T2) where T1 : Prot, T2 : C1, T1.Element == Int", key.entities: [ @@ -2904,14 +2933,14 @@ func shouldPrintAnyAsKeyword(x x: Any) key.kind: source.lang.swift.decl.var.local, key.keyword: "x", key.name: "ix", - key.offset: 2197, + key.offset: 2222, key.length: 2 }, { key.kind: source.lang.swift.decl.var.local, key.keyword: "y", key.name: "iy", - key.offset: 2207, + key.offset: 2232, key.length: 2 } ] @@ -2920,7 +2949,7 @@ func shouldPrintAnyAsKeyword(x x: Any) key.kind: source.lang.swift.decl.function.free, key.name: "shouldPrintAnyAsKeyword(x:)", key.usr: "s:4cake23shouldPrintAnyAsKeyword1xyyp_tF", - key.offset: 2266, + key.offset: 2291, key.length: 38, key.fully_annotated_decl: "func shouldPrintAnyAsKeyword(x: Any)", key.entities: [ @@ -2928,7 +2957,7 @@ func shouldPrintAnyAsKeyword(x x: Any) key.kind: source.lang.swift.decl.var.local, key.keyword: "x", key.name: "x", - key.offset: 2300, + key.offset: 2325, key.length: 3 } ] diff --git a/test/SymbolGraph/Module/ThirdOrder.swift b/test/SymbolGraph/Module/ThirdOrder.swift index 6f7abc58d0e7b..a5a3aeb58cefa 100644 --- a/test/SymbolGraph/Module/ThirdOrder.swift +++ b/test/SymbolGraph/Module/ThirdOrder.swift @@ -11,8 +11,8 @@ @_exported import B -// BASE-NOT: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:1A10SomeStructV1BE05InnerB0V" -// EXT-DAG: "s:SQsRi_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:1A10SomeStructV1BE05InnerB0V" +// BASE-NOT: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:1A10SomeStructV1BE05InnerB0V" +// EXT-DAG: "s:SQsRi_zRi0_zrlE2neoiySbx_xtFZ::SYNTHESIZED::s:1A10SomeStructV1BE05InnerB0V" // BASE-NOT: "s:1A10SomeStructV1BE05InnerB0V06NestedB0V" // EXT-DAG: "s:1A10SomeStructV1BE05InnerB0V06NestedB0V" diff --git a/test/api-digester/Outputs/stability-stdlib-source-base.swift.expected b/test/api-digester/Outputs/stability-stdlib-source-base.swift.expected index 6a7345ca8847a..a0f972039e58f 100644 --- a/test/api-digester/Outputs/stability-stdlib-source-base.swift.expected +++ b/test/api-digester/Outputs/stability-stdlib-source-base.swift.expected @@ -90,7 +90,6 @@ Protocol Encodable has added inherited protocol Copyable Protocol Encodable has added inherited protocol Escapable Protocol Encoder has added inherited protocol Copyable Protocol Encoder has added inherited protocol Escapable -Protocol Equatable has added inherited protocol Escapable Protocol Error has added inherited protocol Copyable Protocol Error has added inherited protocol Escapable Protocol ExpressibleByArrayLiteral has added inherited protocol Copyable @@ -378,11 +377,11 @@ Accessor UnsafeMutableBufferPointer.indices.Get() has generic signature change f Func type(of:) has generic signature change from to Func type(of:) has parameter 0 changing from Default to Shared -// Equatable: ~Copyable -Func Equatable.!=(_:_:) has generic signature change from to +// Equatable: ~Copyable & ~Escapable +Func Equatable.!=(_:_:) has generic signature change from to Func Equatable.!=(_:_:) has parameter 0 changing from Default to Shared Func Equatable.!=(_:_:) has parameter 1 changing from Default to Shared -Func Equatable.==(_:_:) has generic signature change from to +Func Equatable.==(_:_:) has generic signature change from to Func Equatable.==(_:_:) has parameter 0 changing from Default to Shared Func Equatable.==(_:_:) has parameter 1 changing from Default to Shared @@ -400,4 +399,3 @@ Func Comparable.>(_:_:) has parameter 1 changing from Default to Shared Func Comparable.>=(_:_:) has generic signature change from to Func Comparable.>=(_:_:) has parameter 0 changing from Default to Shared Func Comparable.>=(_:_:) has parameter 1 changing from Default to Shared - diff --git a/test/api-digester/stability-stdlib-abi-without-asserts.test b/test/api-digester/stability-stdlib-abi-without-asserts.test index 1ccb4291c8fb6..e143eb31dfa97 100644 --- a/test/api-digester/stability-stdlib-abi-without-asserts.test +++ b/test/api-digester/stability-stdlib-abi-without-asserts.test @@ -208,7 +208,6 @@ Protocol Encodable has added inherited protocol Copyable Protocol Encodable has added inherited protocol Escapable Protocol Encoder has added inherited protocol Copyable Protocol Encoder has added inherited protocol Escapable -Protocol Equatable has added inherited protocol Escapable Protocol Error has added inherited protocol Copyable Protocol Error has added inherited protocol Escapable Protocol ExpressibleByArrayLiteral has added inherited protocol Copyable @@ -882,12 +881,12 @@ Enum DecodingError has added a conformance to an existing protocol CustomDebugSt Enum EncodingError has added a conformance to an existing protocol CustomDebugStringConvertible // Equatable: ~Copyable -Func Equatable.!=(_:_:) has generic signature change from to -Func Equatable.!=(_:_:) has mangled name changing from 'static (extension in Swift):Swift.Equatable.!= infix(A, A) -> Swift.Bool' to 'static (extension in Swift):Swift.Equatable< where A: ~Swift.Copyable>.!= infix(A, A) -> Swift.Bool' +Func Equatable.!=(_:_:) has generic signature change from to +Func Equatable.!=(_:_:) has mangled name changing from 'static (extension in Swift):Swift.Equatable.!= infix(A, A) -> Swift.Bool' to 'static (extension in Swift):Swift.Equatable< where A: ~Swift.Copyable, A: ~Swift.Escapable>.!= infix(A, A) -> Swift.Bool' Func Equatable.!=(_:_:) has parameter 0 changing from Default to Shared Func Equatable.!=(_:_:) has parameter 1 changing from Default to Shared Func Equatable.!=(_:_:) is now with @_preInverseGenerics -Func Equatable.==(_:_:) has generic signature change from to +Func Equatable.==(_:_:) has generic signature change from to Func Equatable.==(_:_:) has parameter 0 changing from Default to Shared Func Equatable.==(_:_:) has parameter 1 changing from Default to Shared diff --git a/test/stdlib/NoncopyableEquatable.swift b/test/stdlib/NoncopyableEquatable.swift index d2cf584e0657c..80c16c0d9d18d 100644 --- a/test/stdlib/NoncopyableEquatable.swift +++ b/test/stdlib/NoncopyableEquatable.swift @@ -9,28 +9,44 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -// RUN: %target-run-simple-swift +// RUN: %target-run-simple-swift(-enable-experimental-feature Lifetimes) // REQUIRES: executable_test +// REQUIRES: swift_feature_Lifetimes import StdlibUnittest let NoncopyableEquatableTests = TestSuite("NoncopyableEquatable") -struct Noncopyable: ~Copyable { +struct Noncopyable: ~Copyable, ~Escapable { var wrapped: Wrapped + + @_lifetime(copy wrapped) + init(wrapping wrapped: consuming Wrapped) { + self.wrapped = wrapped + } +} + +struct Nonescapable: ~Escapable { + let wrapped: Int +} + +extension Nonescapable: Equatable { + static func ==(lhs: Self, rhs: Self) -> Bool { lhs.wrapped == rhs.wrapped } } -extension Noncopyable: Equatable where Wrapped: Equatable & ~Copyable { +extension Noncopyable: Equatable where Wrapped: Equatable & ~Copyable & ~Escapable { static func ==(lhs: borrowing Self, rhs: borrowing Self) -> Bool { lhs.wrapped == rhs.wrapped } } -extension Equatable where Self: ~Copyable { +extension Equatable where Self: ~Copyable & ~Escapable { func isSame(as other: borrowing Self) -> Bool { self == other } } -func isNotSame(_ lhs: borrowing T, _ rhs: borrowing T) -> Bool { +extension Noncopyable: Escapable where Wrapped: Escapable & ~Copyable { } + +func isNotSame(_ lhs: borrowing T, _ rhs: borrowing T) -> Bool { lhs != rhs } @@ -44,9 +60,9 @@ extension InlineArray where Element: Equatable & ~Copyable { NoncopyableEquatableTests.test("equating noncopyables") { // TODO: update StdLibUnitTest to work with ~Copyable Equtable - let a = Noncopyable(wrapped: 1) - let b = Noncopyable(wrapped: 2) - let c = Noncopyable(wrapped: 1) + let a = Noncopyable(wrapping: 1) + let b = Noncopyable(wrapping: 2) + let c = Noncopyable(wrapping: 1) expectFalse(a.isSame(as: b)) expectTrue(a.isSame(as: c)) @@ -54,14 +70,14 @@ NoncopyableEquatableTests.test("equating noncopyables") { expectTrue(isNotSame(a,b)) - let nc2 = Noncopyable(wrapped: Noncopyable(wrapped: "1")) + let nc2 = Noncopyable(wrapping: Noncopyable(wrapping: "1")) expectTrue(nc2 == nc2) - expectTrue(nc2 != .init(wrapped: .init(wrapped: "2"))) + expectTrue(nc2 != .init(wrapping: .init(wrapping: "2"))) guard #available(SwiftStdlib 6.2, *) else { return } let array: [3 of Noncopyable] = [a,b,c] - let d = Noncopyable(wrapped: 2) + let d = Noncopyable(wrapping: 2) let i = array.firstIndex(of: d) expectNotNil(i) @@ -77,7 +93,21 @@ NoncopyableEquatableTests.test("equating noncopyables") { // this works though: expectTrue(d == array[i]) - expectNil(array.firstIndex(of: .init(wrapped: 3))) + expectNil(array.firstIndex(of: .init(wrapping: 3))) } +NoncopyableEquatableTests.test("equating nonescapables") { + let nc1 = Noncopyable(wrapping: .init(wrapped: 1)) + let nc2 = Noncopyable(wrapping: .init(wrapped: 1)) + let nc3 = Noncopyable(wrapping: .init(wrapped: 2)) + + expectTrue(nc1 == nc2) + expectFalse(nc1 == nc3) + expectTrue(nc1.isSame(as: nc2)) + expectFalse(nc1.isSame(as: nc3)) + expectTrue(isNotSame(nc1, nc3)) + expectFalse(isNotSame(nc1, nc2)) +} + + runAllTests()