Open
Description
I have a bizarre unboxing issue in my test cases. If I make a call to wtf()
below, everything compiles and the test runs correctly. If I comment out wtf()
I get a Type 'any Unit' (aka 'any Unit') cannot conform to 'Unit'
.
static var testValues: [(unit: any Unit, abbreviated: String, narrow: String, wide: String)] {
[
(EnergyUnit.kilowattHours, "kW·hs", "kWh", "kilowatt-hours"),
]
}
func test_formatted__Unit_FormatStyle() {
func test(unit: some Unit, abbreviated: String, narrow: String, wide: String) {
XCTAssertEqual(unit.formatted(.unit(width: .abbreviated, locale: locale)), abbreviated)
XCTAssertEqual(unit.formatted(.unit(width: .narrow, locale: locale)), narrow)
XCTAssertEqual(unit.formatted(.unit(width: .wide, locale: locale)), wide)
}
func wtf(unit: some Unit) {
}
// Returns a properly formatted string
Self.testValues.forEach {
wtf(unit: $0.unit) // comment this out and the code fails to compile
test(unit: $0.unit, abbreviated: $0.abbreviated, narrow: $0.narrow, wide: $0.wide)
}
}
Environment
swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
Xcode 14.3
Build version 14E222b
Metadata
Metadata
Assignees
Labels
A deviation from expected or documented behavior. Also: expected but undesirable behavior.Feature: closuresThe Swift compiler itselfFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesFeature → existentials: implicit opening of existentials when passed to parameters of generic typeFeature: tuplesArea → compiler: Semantic analysisBug: Unexpected error