Skip to content

Commit

Permalink
Revert part of 171773d
Browse files Browse the repository at this point in the history
Fixes #19006
  • Loading branch information
nicolasstucki committed Nov 21, 2023
1 parent 7af5cfe commit 22f9265
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,10 @@ trait Applications extends Compatibility {
// the arity of that function, otherise -1.
def paramCount(ref: TermRef) =
val formals = ref.widen.firstParamTypes
if formals.length > idx then defn.functionArity(formals(idx))
if formals.length > idx then
formals(idx).dealias match
case defn.FunctionNOf(args, _, _) => args.length
case _ => -1
else -1

val numArgs = args.length
Expand Down
11 changes: 11 additions & 0 deletions tests/pos/i19006a.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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) => ???)
27 changes: 27 additions & 0 deletions tests/pos/i19006b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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
}

0 comments on commit 22f9265

Please sign in to comment.