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
Compilation error invoking overloaded function with explicit type parameter #10074
Comments
Imported From: https://issues.scala-lang.org/browse/SI-10074?orig=1
|
@SethTisue said: object A {
f[Int]{case _ => 1}
def f[T](f: Any => T) = ()
def f[T](f: Any => T, v: Int) = ()
} |
@SethTisue said: |
@som-snytt said: But the behavior has history on its side. $ scala29
Welcome to Scala version 2.9.3 (OpenJDK 64-Bit Server VM, Java 1.6.0_38).
Type in expressions to have them evaluated.
Type :help for more information.
scala> object Y {
| def f[A](g: PartialFunction[Any, A]): A = g(42)
| def f[A](i: Int, g: PartialFunction[Any, A]): A = g(i)
| }
defined module Y
scala> Y.f { case _ => 17 }
res0: Int = 17
scala> Y.f[Int] { case _ => 17 }
<console>:9: error: missing parameter type for expanded function
The argument types of an anonymous function must be fully known. (SLS 8.5)
Expected type was: ?
Y.f[Int] { case _ => 17 }
^
<console>:9: error: overloaded method value f with alternatives:
(i: Int,g: PartialFunction[Any,Int])Int <and>
(g: PartialFunction[Any,Int])Int
cannot be applied to (<error> => Int)
Y.f[Int] { case _ => 17 }
^
|
@som-snytt said: |
@retronym said (edited on Nov 22, 2016 12:15:23 AM UTC): def preSelectOverloaded(fun: Tree): Tree = {
if (fun.hasSymbolField && fun.symbol.isOverloaded) {
We have:
After filtering, we can end up with a new symbol: either a single method symbol, or a new overloaded symbol with fewer alternatives. This needs to be assigned back to the tree The fix is conceptually easy enough ("generalize that code a little!") but there are a lot of details to line up. I took a hacky attempt at it : https://github.com/scala/scala/compare/2.12.x...retronym:ticket/10074?expand=1 but I'm not planning to pursue this right now. |
Kirill Yankov (manonthegithub) said (edited on Nov 22, 2016 4:20:34 PM UTC): object A{
fun[Int]{
case _ => 1
}
def fun[T](f: PartialFunction[Any, T]): T = {
f(1)
}
def fun[T](v: Int)(f: PartialFunction[Any, T]) = {
f(v)
}
} |
Partial progression from 2.12, M5, almost RC1:
where
|
Trying to compile specified file results an error:
[error] The argument types of an anonymous function must be fully known. (SLS 8.5)
[error] Expected type was: ?
[error] a.overloadedF[Int]{
If you omit type parameter in method invocation or remove second overloaded function, everything works fine.
The text was updated successfully, but these errors were encountered: