-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed as duplicate of#59391
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.triage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
The code I've included does not compile, though I believe it should. Switching some
to any
in the return type of losesTypeInfoButShouldnt()
causes the code to compile.
Reproduction
protocol Foo<T> {
associatedtype T
var content: T { get }
}
final class Bar<T>: Foo {
init() throws { }
var content: T { fatalError() }
}
extension Foo where T: Sequence {
// If you switch `some` to `any` in the return type then it compiles
func losesTypeInfoButShouldnt() -> some Foo<T.Element> {
try! Bar<T.Element>()
}
}
func demo(bar: Bar<[Int]>) {
let _: Int = bar.losesTypeInfoButShouldnt().content
}
Expected behavior
I expect it to compile
Environment
Xcode 16.3, Swift 6.1
Additional information
No response
ValentinWalter
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.triage neededThis issue needs more specific labelsThis issue needs more specific labels