Skip to content

Commit e0a0e30

Browse files
2 parents 39ec69f + 5456fb1 commit e0a0e30

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,10 @@ trait Applications extends Compatibility {
20032003
// the arity of that function, otherise -1.
20042004
def paramCount(ref: TermRef) =
20052005
val formals = ref.widen.firstParamTypes
2006-
if formals.length > idx then defn.functionArity(formals(idx))
2006+
if formals.length > idx then
2007+
formals(idx).dealias match
2008+
case defn.FunctionNOf(args, _, _) => args.length
2009+
case _ => -1
20072010
else -1
20082011

20092012
val numArgs = args.length

tests/pos/i19006a.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import java.util.Map.Entry;
2+
import java.util.function.BiConsumer;
3+
import java.lang.Iterable
4+
5+
trait HttpHeaders extends Iterable[Entry[String, String]] {
6+
def forEach(action: BiConsumer[String, String]): Unit = ???
7+
}
8+
9+
@main def Test =
10+
val headers: HttpHeaders = ???
11+
headers.forEach((a, b) => ???)

tests/pos/i19006b.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.util.function.Function
2+
3+
trait HttpClient
4+
trait HttpRequest
5+
trait HttpResponse
6+
trait ClientRequestContext
7+
8+
trait DecoratingHttpClientFunction {
9+
def execute(delegate: HttpClient, ctx: ClientRequestContext, req: HttpRequest): HttpResponse
10+
}
11+
12+
class AbstractClientOptionsBuilder:
13+
def decorator(fn: Function[? <: HttpClient, ? <: HttpClient]): AbstractClientOptionsBuilder = ???
14+
def decorator(fn: DecoratingHttpClientFunction): AbstractClientOptionsBuilder = ???
15+
16+
class WebClientBuilder extends AbstractClientOptionsBuilder:
17+
override def decorator(fn: Function[? <: HttpClient, ? <: HttpClient]): WebClientBuilder = ???
18+
override def decorator(fn: DecoratingHttpClientFunction): WebClientBuilder = ???
19+
20+
class ArmeriaClientBuilder[F[_]]:
21+
type DecoratingFunction = (HttpClient, ClientRequestContext, HttpRequest) => HttpResponse
22+
def clientBuilder: WebClientBuilder = ???
23+
24+
def withDecorator(decorator: DecoratingFunction): ArmeriaClientBuilder[F] = {
25+
clientBuilder.decorator(decorator(_, _, _))
26+
this
27+
}

0 commit comments

Comments
 (0)