swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.69k stars 10.39k forks source link

Overload bug on Linux(Ubuntu) #72038

Closed zunda-pixel closed 8 months ago

zunda-pixel commented 9 months ago

Description

swift-http-types(package) has overload named URLSession.data(for request: HTTPRequest) And my project has overload named URLSession.data(for request: some Request)

This combination can be build on macOS, but not Linux(Ubuntu)

Sample Project: https://github.com/zunda-pixel/swift-bug-overload

Error Log

/swift-bug-same-argument/Sources/Library1/Library1.swift:25:27: error: instance method 'data(for:)' requires that 'HTTPRequest' conform to 'Request'
    return try await self.data(for: request)
                          ^
/swift-bug-same-argument/Sources/Library1/Library1.swift:18:15: note: where 'some Request' = 'HTTPRequest'
  public func data(for request: some Request) async throws -> (Data, HTTPResponse) {
              ^
error: fatalError
Error: Process completed with exit code 1.

Reproduction

import Foundation
import HTTPTypes
import HTTPTypesFoundation

#if canImport(FoundationNetworking)
  import FoundationNetworking
#endif

extension URLSession {
  public func data(for request: some Request) async throws -> (Data, HTTPResponse) {
    let request = HTTPRequest(
      method: request.method,
      url: request.url,
      headerFields: request.headers
    )
    return try await self.data(for: request)
  }
}

Expected behavior

can be build on Linux(Ubuntu)

Environment

swift 5.9.2

Additional information

No response

zunda-pixel commented 8 months ago

this issue is wrong... I didn't know that Swift for Linux doesn't have Concurrency Method URLSession.