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
512 lines
11 KiB
Plaintext
512 lines
11 KiB
Plaintext
import FooHelper
|
|
|
|
public func fooSubFunc1(_ a: Int32) -> Int32
|
|
|
|
public struct FooSubEnum1 : Hashable, Equatable, RawRepresentable {
|
|
|
|
public init(_ rawValue: UInt32)
|
|
|
|
public init(rawValue: UInt32)
|
|
|
|
public var rawValue: UInt32
|
|
}
|
|
|
|
public var FooSubEnum1X: FooSubEnum1 { get }
|
|
|
|
public var FooSubEnum1Y: FooSubEnum1 { get }
|
|
|
|
public 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.attribute.builtin,
|
|
key.offset: 18,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 25,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 30,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 42,
|
|
key.length: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 44,
|
|
key.length: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 47,
|
|
key.length: 5
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 57,
|
|
key.length: 5
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
|
|
key.offset: 64,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 71,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 78,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 92,
|
|
key.length: 8
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 102,
|
|
key.length: 9
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 113,
|
|
key.length: 16
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
|
|
key.offset: 137,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 144,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 149,
|
|
key.length: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 151,
|
|
key.length: 8
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 161,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
|
|
key.offset: 174,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 181,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 186,
|
|
key.length: 8
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 196,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
|
|
key.offset: 209,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 216,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 220,
|
|
key.length: 8
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 230,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
|
|
key.offset: 240,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 247,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 251,
|
|
key.length: 12
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 265,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 279,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
|
|
key.offset: 286,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 293,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 297,
|
|
key.length: 12
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 311,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 325,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
|
|
key.offset: 332,
|
|
key.length: 6
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 339,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 343,
|
|
key.length: 25
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 370,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 376,
|
|
key.length: 3
|
|
}
|
|
]
|
|
[
|
|
{
|
|
key.kind: source.lang.swift.ref.module,
|
|
key.offset: 7,
|
|
key.length: 9
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.offset: 47,
|
|
key.length: 5,
|
|
key.is_system: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.offset: 57,
|
|
key.length: 5,
|
|
key.is_system: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.protocol,
|
|
key.offset: 92,
|
|
key.length: 8,
|
|
key.is_system: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.protocol,
|
|
key.offset: 102,
|
|
key.length: 9,
|
|
key.is_system: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.protocol,
|
|
key.offset: 113,
|
|
key.length: 16,
|
|
key.is_system: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.offset: 161,
|
|
key.length: 6,
|
|
key.is_system: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.offset: 196,
|
|
key.length: 6,
|
|
key.is_system: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.offset: 230,
|
|
key.length: 6,
|
|
key.is_system: 1
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.offset: 265,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.offset: 311,
|
|
key.length: 11
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.ref.struct,
|
|
key.offset: 370,
|
|
key.length: 3,
|
|
key.is_system: 1
|
|
}
|
|
]
|
|
[
|
|
{
|
|
key.kind: source.lang.swift.decl.function.free,
|
|
key.accessibility: source.lang.swift.accessibility.public,
|
|
key.name: "fooSubFunc1(_:)",
|
|
key.offset: 25,
|
|
key.length: 37,
|
|
key.typename: "Int32",
|
|
key.nameoffset: 30,
|
|
key.namelength: 23,
|
|
key.attributes: [
|
|
{
|
|
key.offset: 18,
|
|
key.length: 6,
|
|
key.attribute: source.decl.attribute.public
|
|
}
|
|
],
|
|
key.substructure: [
|
|
{
|
|
key.kind: source.lang.swift.decl.var.parameter,
|
|
key.name: "a",
|
|
key.offset: 42,
|
|
key.length: 10,
|
|
key.typename: "Int32"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.struct,
|
|
key.accessibility: source.lang.swift.accessibility.public,
|
|
key.name: "FooSubEnum1",
|
|
key.offset: 71,
|
|
key.length: 167,
|
|
key.nameoffset: 78,
|
|
key.namelength: 11,
|
|
key.bodyoffset: 131,
|
|
key.bodylength: 106,
|
|
key.inheritedtypes: [
|
|
{
|
|
key.name: "Hashable"
|
|
},
|
|
{
|
|
key.name: "Equatable"
|
|
},
|
|
{
|
|
key.name: "RawRepresentable"
|
|
}
|
|
],
|
|
key.attributes: [
|
|
{
|
|
key.offset: 64,
|
|
key.length: 6,
|
|
key.attribute: source.decl.attribute.public
|
|
}
|
|
],
|
|
key.elements: [
|
|
{
|
|
key.kind: source.lang.swift.structure.elem.typeref,
|
|
key.offset: 92,
|
|
key.length: 8
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.structure.elem.typeref,
|
|
key.offset: 102,
|
|
key.length: 9
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.structure.elem.typeref,
|
|
key.offset: 113,
|
|
key.length: 16
|
|
}
|
|
],
|
|
key.substructure: [
|
|
{
|
|
key.kind: source.lang.swift.decl.function.method.instance,
|
|
key.accessibility: source.lang.swift.accessibility.public,
|
|
key.name: "init(_:)",
|
|
key.offset: 144,
|
|
key.length: 24,
|
|
key.nameoffset: 144,
|
|
key.namelength: 24,
|
|
key.attributes: [
|
|
{
|
|
key.offset: 137,
|
|
key.length: 6,
|
|
key.attribute: source.decl.attribute.public
|
|
}
|
|
],
|
|
key.substructure: [
|
|
{
|
|
key.kind: source.lang.swift.decl.var.parameter,
|
|
key.name: "rawValue",
|
|
key.offset: 149,
|
|
key.length: 18,
|
|
key.typename: "UInt32"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.function.method.instance,
|
|
key.accessibility: source.lang.swift.accessibility.public,
|
|
key.name: "init(rawValue:)",
|
|
key.offset: 181,
|
|
key.length: 22,
|
|
key.nameoffset: 181,
|
|
key.namelength: 22,
|
|
key.attributes: [
|
|
{
|
|
key.offset: 174,
|
|
key.length: 6,
|
|
key.attribute: source.decl.attribute.public
|
|
}
|
|
],
|
|
key.substructure: [
|
|
{
|
|
key.kind: source.lang.swift.decl.var.parameter,
|
|
key.name: "rawValue",
|
|
key.offset: 186,
|
|
key.length: 16,
|
|
key.typename: "UInt32",
|
|
key.nameoffset: 186,
|
|
key.namelength: 8
|
|
}
|
|
]
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.var.instance,
|
|
key.accessibility: source.lang.swift.accessibility.public,
|
|
key.setter_accessibility: source.lang.swift.accessibility.public,
|
|
key.name: "rawValue",
|
|
key.offset: 216,
|
|
key.length: 20,
|
|
key.typename: "UInt32",
|
|
key.nameoffset: 220,
|
|
key.namelength: 8,
|
|
key.attributes: [
|
|
{
|
|
key.offset: 209,
|
|
key.length: 6,
|
|
key.attribute: source.decl.attribute.public
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.var.global,
|
|
key.accessibility: source.lang.swift.accessibility.public,
|
|
key.name: "FooSubEnum1X",
|
|
key.offset: 247,
|
|
key.length: 37,
|
|
key.typename: "FooSubEnum1",
|
|
key.nameoffset: 251,
|
|
key.namelength: 12,
|
|
key.bodyoffset: 278,
|
|
key.bodylength: 5,
|
|
key.attributes: [
|
|
{
|
|
key.offset: 240,
|
|
key.length: 6,
|
|
key.attribute: source.decl.attribute.public
|
|
}
|
|
]
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.var.global,
|
|
key.accessibility: source.lang.swift.accessibility.public,
|
|
key.name: "FooSubEnum1Y",
|
|
key.offset: 293,
|
|
key.length: 37,
|
|
key.typename: "FooSubEnum1",
|
|
key.nameoffset: 297,
|
|
key.namelength: 12,
|
|
key.bodyoffset: 324,
|
|
key.bodylength: 5,
|
|
key.attributes: [
|
|
{
|
|
key.offset: 286,
|
|
key.length: 6,
|
|
key.attribute: source.decl.attribute.public
|
|
}
|
|
]
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.decl.var.global,
|
|
key.accessibility: source.lang.swift.accessibility.public,
|
|
key.name: "FooSubUnnamedEnumeratorA1",
|
|
key.offset: 339,
|
|
key.length: 42,
|
|
key.typename: "Int",
|
|
key.nameoffset: 343,
|
|
key.namelength: 25,
|
|
key.bodyoffset: 375,
|
|
key.bodylength: 5,
|
|
key.attributes: [
|
|
{
|
|
key.offset: 332,
|
|
key.length: 6,
|
|
key.attribute: source.decl.attribute.public
|
|
}
|
|
]
|
|
}
|
|
]
|