Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in softwaremill/sttp - ignored overloaded member #19006

Closed
WojciechMazur opened this issue Nov 20, 2023 · 1 comment · Fixed by #19012
Closed

Regression in softwaremill/sttp - ignored overloaded member #19006

WojciechMazur opened this issue Nov 20, 2023 · 1 comment · Fixed by #19012
Assignees
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore

Comments

@WojciechMazur
Copy link
Contributor

Open Community Builder failure based on the following projects:

Compiler version

3.4.0-RC1-bin-20231117-5bb6f0d-NIGHTLY

Bisect points to 171773d

Minimized code

import java.util.Map.Entry;
import java.util.function.BiConsumer;
import java.lang.Iterable

trait HttpHeaders extends Iterable[Entry[String, String]] {
  def forEach(action: BiConsumer[String, String]): Unit = ???
}

@main def Test =
  val headers: HttpHeaders = ???
  headers.forEach((a, b) => ???)

Output

-- [E086] Syntax Error: /Users/wmazur/projects/dotty/bisect/main.scala:11:25 ---
11 |  headers.forEach((a, b) => ???)
   |                  ^^^^^^^^^^^^^
   |                  Wrong number of parameters, expected: 1
   |

Expectation

Should compile. Compiler should use the overloaded variant of forEach method taking a BiConsumer instead of Consumer[Entry[String,String] defined in Java stdlib.

@WojciechMazur WojciechMazur added itype:bug area:typer regression This worked in a previous version but doesn't anymore labels Nov 20, 2023
@WojciechMazur
Copy link
Contributor Author

Another reproducer found in dependency of the 2 libraries: http4s/http4s-armeria. Slightly different scenario.

import java.util.function.Function

trait HttpClient
trait HttpRequest
trait HttpResponse
trait ClientRequestContext

trait DecoratingHttpClientFunction {
  def execute(delegate: HttpClient, ctx: ClientRequestContext, req: HttpRequest): HttpResponse
}

class AbstractClientOptionsBuilder:
  def decorator(fn: Function[? <: HttpClient, ? <: HttpClient]): AbstractClientOptionsBuilder = ???
  def decorator(fn: DecoratingHttpClientFunction): AbstractClientOptionsBuilder = ???

class WebClientBuilder extends AbstractClientOptionsBuilder:
  override def decorator(fn: Function[? <: HttpClient, ? <: HttpClient]): WebClientBuilder = ???
  override def decorator(fn: DecoratingHttpClientFunction): WebClientBuilder = ???

class ArmeriaClientBuilder[F[_]]:
  type DecoratingFunction = (HttpClient, ClientRequestContext, HttpRequest) => HttpResponse
  def clientBuilder: WebClientBuilder = ???

  def withDecorator(decorator: DecoratingFunction): ArmeriaClientBuilder[F] = {
    clientBuilder.decorator(decorator(_, _, _))
    this
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants