Scala 2.13 regression: type param affecting overload
See original GitHub issueCompiler version
3.0.0
Minimized code (ver 1)
final class HookComponentBuilder[Ctx, CtxFn[_]] {
def asd[A](f: Ctx => A): A = ???
def asd[A](f: CtxFn[A]): A = ???
}
object HookCtx {
case class P1[P, H1](props: P, hook1: H1)
}
object HookCtxFn {
sealed trait P1[P, H1] { type Fn[A] = (P, H1) => A }
}
object Test {
val b: HookComponentBuilder[HookCtx.P1[String, Int], HookCtxFn.P1[String, Int]#Fn] = ???
b.asd($ => $.props.length + $.hook1)
b.asd((props, hook1) => props.length + hook1)
}
Minimized code (ver 2)
Changing HookCtxFn.P1
to a type lambda…
final class HookComponentBuilder[Ctx, CtxFn[_]] {
def asd[A](f: Ctx => A): A = ???
def asd[A](f: CtxFn[A]): A = ???
}
object HookCtx {
case class P1[P, H1](props: P, hook1: H1)
}
object HookCtxFn {
type P1[P, H1] = [A] =>> (P, H1) => A
}
object Test {
val b: HookComponentBuilder[HookCtx.P1[String, Int], HookCtxFn.P1[String, Int]] = ???
b.asd($ => $.props.length + $.hook1)
b.asd((props, hook1) => props.length + hook1)
}
Output
[error] 18 | b.asd((props, hook1) => props.length + hook1)
[error] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error] | Wrong number of parameters, expected: 1
Expectation
It should compile. It does with Scala 2.13
Workaround
Inlining HookCtxFn.P1
makes it work.
final class HookComponentBuilder[Ctx, CtxFn[_]] {
def asd[A](f: Ctx => A): A = ???
def asd[A](f: CtxFn[A]): A = ???
}
object HookCtx {
case class P1[P, H1](props: P, hook1: H1)
}
object Test {
val b: HookComponentBuilder[HookCtx.P1[String, Int], [A] =>> (String, Int) => A] = ???
b.asd($ => $.props.length + $.hook1)
b.asd((props, hook1) => props.length + hook1)
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Change in behavior in 2.13 for implicit overloads · Issue #11662
This code compiles on Scala 2.10, 2.11, and 2.12: class Foo(xs: ... match argument types (List[String]) and expected result type Foo.
Read more >Changes in Overload Resolution - Scala 3 - EPFL
Overload resolution in Scala 3 improves on Scala 2 in three ways. First, it takes all argument lists into account instead of just...
Read more >sbt Reference Manual — Combined Pages
Compiles and runs all tests. console, Starts the Scala interpreter with a classpath including the compiled sources and all dependencies. To return to...
Read more >scala - Why "avoid method overloading"? - Stack Overflow
There is a greater chance that ambiguity will arise when trying to apply implicit views to adapt the arguments to the parameter types:...
Read more >Changelog — Finagle 22.4.0 documentation
finagle-core: Removed the stack param WhenNoNodesOpenParam from LoadBalancerFactory ... Affected clients may now see tracing enabled by default via the Java ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the minimization! I will take another look.
Also did a quick test to see if all 4 representations are identical. They are:
So this must be just a
.dealias
needed somewhere in overload resolution?