swiftlang / swiftlang/swift-java
Property in Protocol extension with a Self constraint can produce uncompilable bridge
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 1.2k
- Forks
- 123
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 16
Description
Reproduction
Found while running #486 on Alamofire. I think the gist of the issue is the following:
public protocol DownloadResponseSerializerProtocol {
associatedtype SerializedObject
}
public struct URLResponseSerializer: DownloadResponseSerializerProtocol {
public typealias SerializedObject = String
}
extension DownloadResponseSerializerProtocol where Self == URLResponseSerializer {
public var url: URLResponseSerializer { fatalError("...") }
}
this code as of 5764bc2a1b706056121109dc0ab14fd3d771cbc5 fails the Swift bridge compilation with:
error: property 'url' requires the types 'Self' and 'URLResponseSerializer' be equivalent
16 | @_cdecl("swiftjava_MySwiftLibrary_DownloadResponseSerializerProtocol_url$get")
17 | public func swiftjava_MySwiftLibrary_DownloadResponseSerializerProtocol_url$get(_ self: UnsafeRawPointer, _ _result: UnsafeMutableRawPointer) {
18 | _result.assumingMemoryBound(to: URLResponseSerializer.self).initialize(to: self.assumingMemoryBound(to: DownloadResponseSerializerProtocol.self).pointee.url)
| `- error: property 'url' requires the types 'Self' and 'URLResponseSerializer' be equivalent
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the protocol and constrained extension in the reproduction, then inspect the Swift bridge generation that emits swiftjava_MySwiftLibrary_DownloadResponseSerializerProtocol_url$get. Confirm the generated bridge handles the Self == URLResponseSerializer constraint without producing the reported compiler error, and validate the original reproduction against commit 5764bc2a1b706056121109dc0ab14fd3d771cbc5.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, swift
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100