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

Revert part of Simplify defn.FunctionOf.unapply #19012

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading