Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/quicktype-core/src/language/Swift/SwiftRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1183,14 +1183,9 @@ encoder.dateEncodingStrategy = .formatted(formatter)`);
}`);

if (this._options.objcSupport === false) {
this.ensureBlankLine();
this.emitMultiline(` public var hashValue: Int {
return 0
}`);

this.ensureBlankLine();
this.emitMultiline(` public func hash(into hasher: inout Hasher) {
// No-op
hasher.combine(0)
}`);
}

Expand Down
4 changes: 3 additions & 1 deletion test/unit/swift-json-null-hashable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const schema = JSON.stringify({
required: ["value"],
});

test("emits hash(into:) for JSONNull by default", async () => {
test("emits modern Hashable implementation for JSONNull by default", async () => {
const schemaInput = new JSONSchemaInput(undefined);
await schemaInput.addSource({ name: "TopLevel", schema });

Expand All @@ -24,4 +24,6 @@ test("emits hash(into:) for JSONNull by default", async () => {
const output = result.lines.join("\n");

expect(output).toContain("public func hash(into hasher: inout Hasher)");
expect(output).toContain("hasher.combine(0)");
expect(output).not.toContain("public var hashValue: Int");
});
Loading