-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfoverloadingFeature: Overloading symbol namesFeature: Overloading symbol namestype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistype inferenceFeature: type inferenceFeature: type inference
Description
The following code produces the error: member 'attributed' in 'Decimal.FormatStyle' produces result of type 'Decimal.FormatStyle.Attributed', but context expects 'Decimal.FormatStyle
public func formatted(_ formatStyle: Decimal.FormatStyle) -> String {
Decimal(1).formatted(formatStyle)
}
public func formatted(_ formatStyle: Decimal.FormatStyle.Attributed) -> AttributedString {
Decimal(1).formatted(formatStyle)
}
formatted(.number.attributed)
But this code works fine:
public func formatted(_ formatStyle: IntegerFormatStyle<Int>) -> String {
1.formatted(formatStyle)
}
public func formatted(_ formatStyle: IntegerFormatStyle<Int>.Attributed) -> AttributedString {
1.formatted(formatStyle)
}
formatted(IntegerFormatStyle<Int>.number.attributed)
Environment
-
Swift compiler version info: swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0 -
Xcode version info: Version 14.2 (14C18)
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfoverloadingFeature: Overloading symbol namesFeature: Overloading symbol namestype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistype inferenceFeature: type inferenceFeature: type inference