Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[swift5] Fix Xcode 16 compilation crash with Extensions.swift generation #19564

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,12 @@ extension KeyedEncodingContainerProtocol {
}

{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

internal mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

internal mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ extension KeyedEncodingContainerProtocol {
}

public mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
var mutableValue = value
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
try encode(stringValue, forKey: key)
let decimalNumber = NSDecimalNumber(decimal: value)
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.locale = Locale(identifier: "en_US")
let formattedString = numberFormatter.string(from: decimalNumber) ?? "\(value)"
try encode(formattedString, forKey: key)
}

public mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
Expand Down
Loading