Closed
Description
Minimized code
In this PR: typelevel/cats#3515
part of the diff worked in scala 2, but not 3.
def ap[A, B](f: () => A => B)(fa: () => A): () => B =
() => f().apply(fa())
The error message on 0.24.0:
[error] -- [E050] Type Error: /home/oscarboykin/oss/cats/core/src/main/scala/cats/instances/function.scala:84:14
[error] 84 | () => f().apply(fa())
[error] | ^
[error] | value f does not take parameters
[error] one error found
[error] (coreJVM / Compile / compileIncremental) Compilation failed
changing the code to:
def ap[A, B](f: () => A => B)(fa: () => A): () => B =
() => {
val fnAB = f()
fnAB(fa())
}
fixed the matter, but the original code was accepted by scala 2. There may be some language change in scala 3 that made this code illegal, but if that's the case I think a clearer error message would help greatly.