mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* [cxx-interop] Add Hashable conformance to imported enums Previously, imported enums only conformed to RawRepresentable and Equatable, so they could not be used as members of a Set or keys of a Dictionary. This patch adds Hashable conformance to give them that ability, as well as some test cases to clarify the expected behavior. Existing test cases are updated to reflect this new conformance. rdar://129713687
521 lines
17 KiB
Plaintext
521 lines
17 KiB
Plaintext
import FooHelper
|
|
|
|
func fooSubFunc1(_ a: Int32) -> Int32
|
|
|
|
struct FooSubEnum1 : Hashable, Equatable, RawRepresentable {
|
|
|
|
init(_ rawValue: UInt32)
|
|
|
|
init(rawValue rawValue: UInt32)
|
|
|
|
var rawValue: UInt32
|
|
|
|
@inlinable var hashValue: Int { get }
|
|
|
|
@inlinable func hash(into hasher: inout Hasher)
|
|
|
|
static func != (_ lhs: FooSubEnum1, _ rhs: FooSubEnum1) -> Bool
|
|
}
|
|
|
|
var FooSubEnum1X: FooSubEnum1 { get }
|
|
|
|
var FooSubEnum1Y: FooSubEnum1 { get }
|
|
|
|
var FooSubUnnamedEnumeratorA1: Int { get }
|
|
|
|
|
|
[
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 0,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 7,
|
|
key.length: 9
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 18,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 23,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.argument,
|
|
key.offset: 35,
|
|
key.length: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.parameter,
|
|
key.offset: 37,
|
|
key.length: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "Int32",
|
|
key.usr: "s:s5Int32V",
|
|
key.offset: 40,
|
|
key.length: 5
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "Int32",
|
|
key.usr: "s:s5Int32V",
|
|
key.offset: 50,
|
|
key.length: 5
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 57,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 64,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.protocol,
|
|
key.name: "Hashable",
|
|
key.usr: "s:SH",
|
|
key.offset: 78,
|
|
key.length: 8
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.protocol,
|
|
key.name: "Equatable",
|
|
key.usr: "s:SQ",
|
|
key.offset: 88,
|
|
key.length: 9
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.protocol,
|
|
key.name: "RawRepresentable",
|
|
key.usr: "s:SY",
|
|
key.offset: 99,
|
|
key.length: 16
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 123,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.argument,
|
|
key.offset: 128,
|
|
key.length: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.parameter,
|
|
key.offset: 130,
|
|
key.length: 8
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "UInt32",
|
|
key.usr: "s:s6UInt32V",
|
|
key.offset: 140,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 153,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.argument,
|
|
key.offset: 158,
|
|
key.length: 8
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.parameter,
|
|
key.offset: 167,
|
|
key.length: 8
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "UInt32",
|
|
key.usr: "s:s6UInt32V",
|
|
key.offset: 177,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 190,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 194,
|
|
key.length: 8
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "UInt32",
|
|
key.usr: "s:s6UInt32V",
|
|
key.offset: 204,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
|
|
key.offset: 216,
|
|
key.length: 10
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 227,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 231,
|
|
key.length: 9
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "Int",
|
|
key.usr: "s:Si",
|
|
key.offset: 242,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 248,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
|
|
key.offset: 259,
|
|
key.length: 10
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 270,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 275,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.argument,
|
|
key.offset: 280,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.parameter,
|
|
key.offset: 285,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 293,
|
|
key.length: 5
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "Hasher",
|
|
key.usr: "s:s6HasherV",
|
|
key.offset: 299,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 312,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 319,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.operator,
|
|
key.offset: 324,
|
|
key.length: 2
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.argument,
|
|
key.offset: 328,
|
|
key.length: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.parameter,
|
|
key.offset: 330,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "FooSubEnum1",
|
|
key.usr: "c:@E@FooSubEnum1",
|
|
key.offset: 335,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.argument,
|
|
key.offset: 348,
|
|
key.length: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.parameter,
|
|
key.offset: 350,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "FooSubEnum1",
|
|
key.usr: "c:@E@FooSubEnum1",
|
|
key.offset: 355,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "Bool",
|
|
key.usr: "s:Sb",
|
|
key.offset: 371,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 379,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 383,
|
|
key.length: 12
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "FooSubEnum1",
|
|
key.usr: "c:@E@FooSubEnum1",
|
|
key.offset: 397,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 411,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 418,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 422,
|
|
key.length: 12
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "FooSubEnum1",
|
|
key.usr: "c:@E@FooSubEnum1",
|
|
key.offset: 436,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 450,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 457,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 461,
|
|
key.length: 25
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.name: "Int",
|
|
key.usr: "s:Si",
|
|
key.offset: 488,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 494,
|
|
key.length: 3
|
|
}
|
|
]
|
|
[
|
|
{
|
|
key.kind: source.lang.swift.decl.function.free,
|
|
key.name: "fooSubFunc1(_:)",
|
|
key.usr: "c:@F@fooSubFunc1",
|
|
key.offset: 18,
|
|
key.length: 37,
|
|
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooSubFunc1</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>a</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.function.returntype></decl.function.free>",
|
|
key.entities: [
|
|
{
|
|
key.kind: source.lang.swift.decl.var.local,
|
|
key.keyword: "_",
|
|
key.name: "a",
|
|
key.offset: 40,
|
|
key.length: 5
|
|
}
|
|
],
|
|
key.modulename: "Foo.FooSub"
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.struct,
|
|
key.name: "FooSubEnum1",
|
|
key.usr: "c:@E@FooSubEnum1",
|
|
key.offset: 57,
|
|
key.length: 320,
|
|
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>FooSubEnum1</decl.name> : <ref.protocol usr=\"s:SH\">Hashable</ref.protocol>, <ref.protocol usr=\"s:SQ\">Equatable</ref.protocol>, <ref.protocol usr=\"s:SY\">RawRepresentable</ref.protocol></decl.struct>",
|
|
key.conforms: [
|
|
{
|
|
key.kind: source.lang.swift.ref.protocol,
|
|
key.name: "Hashable",
|
|
key.usr: "s:SH"
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.protocol,
|
|
key.name: "Equatable",
|
|
key.usr: "s:SQ"
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.protocol,
|
|
key.name: "RawRepresentable",
|
|
key.usr: "s:SY"
|
|
}
|
|
],
|
|
key.entities: [
|
|
{
|
|
key.kind: source.lang.swift.decl.function.constructor,
|
|
key.name: "init(_:)",
|
|
key.usr: "s:So11FooSubEnum1VyABs6UInt32Vcfc",
|
|
key.offset: 123,
|
|
key.length: 24,
|
|
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>rawValue</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
|
|
key.entities: [
|
|
{
|
|
key.kind: source.lang.swift.decl.var.local,
|
|
key.keyword: "_",
|
|
key.name: "rawValue",
|
|
key.offset: 140,
|
|
key.length: 6
|
|
}
|
|
]
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.function.constructor,
|
|
key.name: "init(rawValue:)",
|
|
key.usr: "s:So11FooSubEnum1V8rawValueABs6UInt32V_tcfc",
|
|
key.offset: 153,
|
|
key.length: 31,
|
|
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>rawValue</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
|
|
key.entities: [
|
|
{
|
|
key.kind: source.lang.swift.decl.var.local,
|
|
key.keyword: "rawValue",
|
|
key.name: "rawValue",
|
|
key.offset: 177,
|
|
key.length: 6
|
|
}
|
|
]
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.var.instance,
|
|
key.name: "rawValue",
|
|
key.usr: "s:So11FooSubEnum1V8rawValues6UInt32Vvp",
|
|
key.offset: 190,
|
|
key.length: 20,
|
|
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>rawValue</decl.name>: <decl.var.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.type></decl.var.instance>"
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.var.instance,
|
|
key.name: "hashValue",
|
|
key.usr: "s:SYsSHRzSH8RawValueSYRpzrlE04hashB0Sivp::SYNTHESIZED::c:@E@FooSubEnum1",
|
|
key.original_usr: "s:SYsSHRzSH8RawValueSYRpzrlE04hashB0Sivp",
|
|
key.offset: 216,
|
|
key.length: 37,
|
|
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.attribute.builtin><syntaxtype.attribute.name>@inlinable</syntaxtype.attribute.name></syntaxtype.attribute.builtin> <syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>hashValue</decl.name>: <decl.var.type><ref.struct usr=\"s:Si\">Int</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.instance>"
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.function.method.instance,
|
|
key.name: "hash(into:)",
|
|
key.usr: "s:SYsSHRzSH8RawValueSYRpzrlE4hash4intoys6HasherVz_tF::SYNTHESIZED::c:@E@FooSubEnum1",
|
|
key.original_usr: "s:SYsSHRzSH8RawValueSYRpzrlE4hash4intoys6HasherVz_tF",
|
|
key.offset: 259,
|
|
key.length: 47,
|
|
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.attribute.builtin><syntaxtype.attribute.name>@inlinable</syntaxtype.attribute.name></syntaxtype.attribute.builtin> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>hash</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>into</decl.var.parameter.argument_label> <decl.var.parameter.name>hasher</decl.var.parameter.name>: <syntaxtype.keyword>inout</syntaxtype.keyword> <decl.var.parameter.type><ref.struct usr=\"s:s6HasherV\">Hasher</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.method.instance>",
|
|
key.entities: [
|
|
{
|
|
key.kind: source.lang.swift.decl.var.local,
|
|
key.keyword: "into",
|
|
key.name: "hasher",
|
|
key.offset: 299,
|
|
key.length: 6
|
|
}
|
|
]
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.function.operator.infix,
|
|
key.name: "!=(_:_:)",
|
|
key.usr: "s:SQsE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooSubEnum1",
|
|
key.original_usr: "s:SQsE2neoiySbx_xtFZ",
|
|
key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:SQsE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@FooSubEnum1</USR><Declaration>static func != (lhs: FooSubEnum1, rhs: FooSubEnum1) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
|
|
key.offset: 312,
|
|
key.length: 63,
|
|
key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!= </decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooSubEnum1\">FooSubEnum1</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooSubEnum1\">FooSubEnum1</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
|
|
key.entities: [
|
|
{
|
|
key.kind: source.lang.swift.decl.var.local,
|
|
key.keyword: "_",
|
|
key.name: "lhs",
|
|
key.offset: 335,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.var.local,
|
|
key.keyword: "_",
|
|
key.name: "rhs",
|
|
key.offset: 355,
|
|
key.length: 11
|
|
}
|
|
]
|
|
}
|
|
],
|
|
key.modulename: "Foo.FooSub"
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.var.global,
|
|
key.name: "FooSubEnum1X",
|
|
key.usr: "c:@E@FooSubEnum1@FooSubEnum1X",
|
|
key.offset: 379,
|
|
key.length: 37,
|
|
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FooSubEnum1X</decl.name>: <decl.var.type><ref.struct usr=\"c:@E@FooSubEnum1\">FooSubEnum1</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>",
|
|
key.modulename: "Foo.FooSub"
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.var.global,
|
|
key.name: "FooSubEnum1Y",
|
|
key.usr: "c:@E@FooSubEnum1@FooSubEnum1Y",
|
|
key.offset: 418,
|
|
key.length: 37,
|
|
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FooSubEnum1Y</decl.name>: <decl.var.type><ref.struct usr=\"c:@E@FooSubEnum1\">FooSubEnum1</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>",
|
|
key.modulename: "Foo.FooSub"
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.var.global,
|
|
key.name: "FooSubUnnamedEnumeratorA1",
|
|
key.usr: "c:@Ea@FooSubUnnamedEnumeratorA1@FooSubUnnamedEnumeratorA1",
|
|
key.offset: 457,
|
|
key.length: 42,
|
|
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FooSubUnnamedEnumeratorA1</decl.name>: <decl.var.type><ref.struct usr=\"s:Si\">Int</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>",
|
|
key.modulename: "Foo.FooSub"
|
|
}
|
|
]
|